Skip to content

Commit

Permalink
Merge branch 'pr/13'
Browse files Browse the repository at this point in the history
  • Loading branch information
martinknor committed Jun 26, 2020
2 parents 05a7d4e + 414c76d commit a429637
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 124 deletions.
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
}
],
"require": {


"php": ">=5.6",
"nette/di": "~2.4.0 || ^2.5.0 || ^3.0.0",
"nette/utils": "~2.4.0 || ^2.5.0 || ^3.0.0",
"latte/latte": "^2.4 || ~2.6.0",
"contributte/console": "^0.8.0"
"nette/di": "~2.4.0",
"nette/utils": ">=2.4.0",
"latte/latte": ">=2.4.0",
"kdyby/console": ">=2.6.0",
"sergiors/importing": "1.0.1"
},
"require-dev": {
"nette/tester": "@dev"
Expand Down
48 changes: 3 additions & 45 deletions src/Generators/BaseGenerator.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Mk\Feed\Generators;

use Latte\Engine;
use Mk\Feed\Storage;
use Nette\SmartObject;
use Mk\Feed\FileEmptyException;
use Mk\Feed\ItemIncompletedException;

Expand All @@ -14,8 +14,7 @@
*/
abstract class BaseGenerator implements IGenerator {

/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;
use SmartObject;

/** @var bool true if some products added */
private $prepared = false;
Expand All @@ -26,18 +25,6 @@ abstract class BaseGenerator implements IGenerator {
/** @var \Mk\Feed\Storage */
private $storage;

/** @var array */
private $config;

/** @var string */
private $link;

/** @var string */
private $description;

/** @var string */
private $storeName;

/**
* BaseGenerator constructor.
* @param \Mk\Feed\Storage $storage
Expand All @@ -47,30 +34,6 @@ public function __construct(Storage $storage)
$this->storage = $storage;
}

/**
* @param string $link
*/
public function setLink(string $link): void {
$this->link = $link;
}

/**
* @param string $description
*/
public function setDescription(string $description): void {
$this->description = $description;
}

/**
* @param string $storeName
*/
public function setStoreName(string $storeName): void {
$this->storeName = $storeName;
}




/**
* @param $name
* @return string path to template
Expand All @@ -84,7 +47,6 @@ abstract protected function getTemplate($name);
protected function prepare()
{
$this->handle = tmpfile();

$this->prepareTemplate('header');
$this->prepared = true;
}
Expand Down Expand Up @@ -143,15 +105,11 @@ public function save($filename)
*/
protected function prepareTemplate($template)
{

$latte = new Engine;
$content = $latte->renderToString($this->getTemplate($template), array('storeName' => $this->storeName, 'description' => $this->description, 'link' => $this->link));
$file = $this->getTemplate($template);
$footerHandle = fopen('safe://' . $file, 'r');
$footer = fread($footerHandle, filesize($file));
fclose($footerHandle);
fwrite($this->handle, $content);
// fwrite($this->handle, $footer);
fwrite($this->handle, $footer);
}

}
8 changes: 3 additions & 5 deletions src/Generators/BaseItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
abstract class BaseItem implements Mk\Feed\Generators\IItem
{

/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;
use Nette\SmartObject;

/**
* Validate item
* @return bool return true if item is valid
*/
public function validate() {

$reflection = new Nette\Reflection\ClassType(get_called_class());
$reflection = $this->getReflection();

foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $v) {
if ($v->getAnnotation('required')) {
Expand All @@ -33,5 +32,4 @@ public function validate() {

return TRUE;
}

}
5 changes: 2 additions & 3 deletions src/Generators/Google/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
use Mk, Nette;

/**
* @property $url
* Class Image
* @author Martin Knor <[email protected]>
* @package Mk\Feed\Generators\Google
*/
class Image
{
/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;

use Nette\SmartObject;

/** @var string */
private $url;
Expand Down
6 changes: 2 additions & 4 deletions src/Generators/Google/ProductType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
use Nette;

/**
* @property $text
* Class ProductType
* @author Martin Knor <[email protected]>
* @package Mk\Feed\Generators\Google
*/
class ProductType {
class ProductType{

/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;
use Nette\SmartObject;

/** @var string */
protected $text;
Expand Down
16 changes: 2 additions & 14 deletions src/Generators/Heureka/Delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
*/
class Delivery{

/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;
use Nette\SmartObject;

CONST CESKA_POSTA = 'CESKA_POSTA',
CESKA_POSTA_NA_POSTU = 'CESKA_POSTA_NA_POSTU',
CESKA_POSTA_DOPORUCENA_ZASILKA = 'CESKA_POSTA_DOPORUCENA_ZASILKA',
CSAD_LOGISTIK_OSTRAVA = 'CSAD_LOGISTIK_OSTRAVA',
DPD = 'DPD',
DHL = 'DHL',
Expand All @@ -36,17 +34,11 @@ class Delivery{
TNT = 'TNT',
TOPTRANS = 'TOPTRANS',
UPS = 'UPS',
ULOZENKA = 'ULOZENKA',
VLASTNI_PREPRAVA = 'VLASTNI_PREPRAVA',
ZASILKOVNA = 'ZASILKOVNA',

SLOVENSKA_POSTA = 'SLOVENSKA_POSTA';

VLASTNI_PREPRAVA = 'VLASTNI_PREPRAVA';

static $ids = array(
self::CESKA_POSTA,
self::CESKA_POSTA_NA_POSTU,
self::CESKA_POSTA_DOPORUCENA_ZASILKA,
self::CSAD_LOGISTIK_OSTRAVA,
self::DPD,
self::DHL,
Expand All @@ -66,11 +58,7 @@ class Delivery{
self::TNT,
self::TOPTRANS,
self::UPS,
self::ULOZENKA,
self::VLASTNI_PREPRAVA,
self::ZASILKOVNA,

self::SLOVENSKA_POSTA,
);

/** @var string */
Expand Down
5 changes: 2 additions & 3 deletions src/Generators/Heureka/Gift.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
* @author Martin Knor <[email protected]>
* @package Mk\Feed\Generators\Heureka
*/
class Gift {
class Gift{

/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;
use Nette\SmartObject;

/** @var string */
protected $name;
Expand Down
4 changes: 2 additions & 2 deletions src/Generators/Heureka/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*/
class Image
{
/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;

use Nette\SmartObject;

/** @var string */
private $url;
Expand Down
30 changes: 3 additions & 27 deletions src/Generators/Heureka/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,22 @@
* @author Martin Knor <[email protected]>
* @package Mk\Feed\Generators\Heureka
*/
class Parameter {
class Parameter{

/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;
use Nette\SmartObject;

protected $name;
protected $value;
protected $unit;
protected $percentage;

/**
* Parameter constructor.
* @param $name
* @param $value
* @param $unit
*/
public function __construct($name, $value, $unit = null, $percentage = null)
public function __construct($name, $value)
{
$this->name = $name;
$this->value = $value;

$this->unit = $unit;
$this->percentage = $percentage;
}

/**
Expand All @@ -50,21 +43,4 @@ public function getValue()
return $this->value;
}

/**
* @return mixed
*/
public function getUnit() {
return $this->unit;
}

/**
* @return null
*/
public function getPercentage() {
return $this->percentage;
}




}
6 changes: 3 additions & 3 deletions src/Generators/Zbozi/CategoryText.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
* @author Martin Knor <[email protected]>
* @package Mk\Feed\Generators\Zbozi
*/
class CategoryText {
class CategoryText{

use Nette\SmartObject;

/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;

/** @var string */
protected $text;
Expand Down
6 changes: 3 additions & 3 deletions src/Generators/Zbozi/ExtraMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* @author Martin Knor <[email protected]>
* @package Mk\Feed\Generators\Zbozi
*/
class ExtraMessage {
/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;
class ExtraMessage{

use Nette\SmartObject;

CONST EXTENDED_WARRANTY = 'extended_warranty',
FREE_ACCESSORIES = 'free_accessories',
Expand Down
5 changes: 2 additions & 3 deletions src/Generators/Zbozi/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

use Mk, Nette;

class Image {
class Image{

/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;
use Nette\SmartObject;

private $url;

Expand Down
5 changes: 2 additions & 3 deletions src/Generators/Zbozi/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
* @package Mk\Feed\Generators\Zbozi
* @see http://napoveda.seznam.cz/cz/zbozi/specifikace-xml-pro-obchody/specifikace-xml-feedu/#PARAM
*/
class Parameter {
class Parameter{

/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;
use Nette\SmartObject;

protected $name;
protected $value;
Expand Down
5 changes: 2 additions & 3 deletions src/Generators/Zbozi/ShopDepot.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

use Mk, Nette;

class ShopDepot {
class ShopDepot{

/* Použití smartobject viz php 7.2 to nette 2.4 */
use \Nette\SmartObject;
use Nette\SmartObject;

private $id;

Expand Down

0 comments on commit a429637

Please sign in to comment.