Skip to content

Commit

Permalink
compatibility php 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
martinknor committed Mar 24, 2016
1 parent 3f9f950 commit 81918a2
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/Command/FeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FeedCommand extends Command {
/** @var array */
private $config;

public function __construct(array $config = [], Nette\DI\Container $container)
public function __construct(array $config = array(), Nette\DI\Container $container)
{
parent::__construct();

Expand Down
10 changes: 5 additions & 5 deletions src/DI/FeedExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
*/
class FeedExtension extends Nette\DI\CompilerExtension {
/** @var array */
private $defaults = [
private $defaults = array(
'exportsDir' => '%wwwDir%',
'exports' => []
];
'exports' => array()
);

public function loadConfiguration()
{
Expand All @@ -25,7 +25,7 @@ public function loadConfiguration()
$config = $this->getConfig($this->defaults);

$builder->addDefinition($this->prefix('storage'))
->setClass('\Mk\Feed\Storage', [$config['exportsDir']]);
->setClass('\Mk\Feed\Storage', array($config['exportsDir']));

foreach ($config['exports'] as $export => $class) {
if (!class_exists($class)) {
Expand All @@ -37,7 +37,7 @@ public function loadConfiguration()

if (class_exists('\Symfony\Component\Console\Command\Command')) {
$builder->addDefinition($this->prefix('command'))
->setClass('Mk\Feed\Command\FeedCommand', [$config])
->setClass('Mk\Feed\Command\FeedCommand', array($config))
->addTag('kdyby.console.command');
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/Generators/BaseGenerator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Mk\Feed\Generators;

use Latte\Engine;
use Mk\Feed\Storage;
use Nette\Object;
use Mk\Feed\FileEmptyException;
Expand Down Expand Up @@ -63,8 +64,8 @@ public function addItem(IItem $item)
throw new ItemIncompletedException('Item is not complete');
}

$latte = new \Latte\Engine;
$xmlItem = $latte->renderToString($this->getTemplate('item'), ['item' => $item]);
$latte = new Engine;
$xmlItem = $latte->renderToString($this->getTemplate('item'), array('item' => $item));
fwrite($this->handle, $xmlItem);
}

Expand All @@ -83,7 +84,7 @@ public function save($filename)
$this->generate();

if (!$this->prepared) {
throw new FileEmptyException('File ' . $this->file . ' has not been opened');
throw new FileEmptyException('File has not any items');
}

$this->prepareTemplate('footer');
Expand Down
14 changes: 7 additions & 7 deletions src/Generators/Google/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ class Item extends BaseItem {
AVAILABILITY_IN_STOCK = 'in stock',
AVAILABILITY_OUT_OF_STOCK = 'out of stock';

static $conditions = [
static $conditions = array(
self::CONDITION_NEW,
self::CONDITION_REFURBISHED,
self::CONDITION_USED,
];
);

static $availabilities = [
static $availabilities = array(
self::AVAILABILITY_PREORDER,
self::AVAILABILITY_IN_STOCK,
self::AVAILABILITY_OUT_OF_STOCK,
];
);

/** @var string @required */
protected $id;
Expand All @@ -45,7 +45,7 @@ class Item extends BaseItem {
protected $googleProductCategory;

/** @var ProductType[] */
protected $productTypes = [];
protected $productTypes = array();

/** @var string @required */
protected $link;
Expand All @@ -54,7 +54,7 @@ class Item extends BaseItem {
protected $mobileLink;

/** @var Image[] */
protected $images = [];
protected $images = array();

/** @var string|null */
protected $condition = self::CONDITION_NEW;
Expand Down Expand Up @@ -338,7 +338,7 @@ public function setIdentifierExists($identifierExists)
*/
public function getAvailabilityDate()
{
return $this->availabilityDate instanceof \DateTime ? $this->availabilityDate->format('c') : $this->availabilityDate;;
return $this->availabilityDate instanceof \DateTime ? $this->availabilityDate->format('c') : $this->availabilityDate;
}

/**
Expand Down
14 changes: 9 additions & 5 deletions src/Generators/Heureka/CategoriesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Mk\Feed\Generators\Heureka;

use Nette\Caching\Cache;

use Nette\Caching\IStorage;

class CategoriesHelper {

Expand All @@ -12,7 +12,7 @@ class CategoriesHelper {
/** @var \Nette\Caching\Cache */
private $cache;

function __construct(\Nette\Caching\IStorage $storage = null)
function __construct(IStorage $storage = null)
{
if ($storage) {
$this->cache = new Cache($storage, __CLASS__);
Expand All @@ -21,7 +21,7 @@ function __construct(\Nette\Caching\IStorage $storage = null)

public function getCategories()
{
$categories = [];
$categories = array();
if (!$this->cache || !($categories = $this->cache->load('categories'))) {
$xml = file_get_contents(self::CATEGORY_URL);
$dom = new \DOMDocument();
Expand All @@ -32,8 +32,12 @@ public function getCategories()
$_categories = $xpath->query(".//CATEGORY");

foreach ($_categories as $category) {
$id = isset($xpath->query($category->getNodePath().'/CATEGORY_ID')[0]) ? (int)$xpath->query($category->getNodePath().'/CATEGORY_ID')[0]->nodeValue : null;
$_cat = isset($xpath->query($category->getNodePath().'/CATEGORY_FULLNAME')[0]) ? (string)$xpath->query($category->getNodePath().'/CATEGORY_FULLNAME')[0]->nodeValue : null;
$categoryIdElement = $xpath->query($category->getNodePath().'/CATEGORY_ID');
$id = isset($categoryIdElement[0]) ? (int)$categoryIdElement[0]->nodeValue : null;

$categoryFullNameElement = $xpath->query($category->getNodePath().'/CATEGORY_FULLNAME');
$_cat = isset($categoryFullNameElement[0]) ? (string)$categoryFullNameElement[0]->nodeValue : null;

if($id && $_cat) {
$_cat = str_replace('Heureka.cz | ', '', $_cat);
$categories[$id] = $_cat;
Expand Down
4 changes: 2 additions & 2 deletions src/Generators/Heureka/Delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Delivery extends Nette\Object {
UPS = 'UPS',
VLASTNI_PREPRAVA = 'VLASTNI_PREPRAVA';

static $ids = [
static $ids = array(
self::CESKA_POSTA,
self::CESKA_POSTA_NA_POSTU,
self::CSAD_LOGISTIK_OSTRAVA,
Expand All @@ -57,7 +57,7 @@ class Delivery extends Nette\Object {
self::TOPTRANS,
self::UPS,
self::VLASTNI_PREPRAVA,
];
);

/** @var string */
private $id;
Expand Down
10 changes: 5 additions & 5 deletions src/Generators/Heureka/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Item extends BaseItem {
protected $url;

/** @var Image[] */
protected $images = [];
protected $images = array();

/** @var string|null */
protected $videoUrl;
Expand All @@ -41,7 +41,7 @@ class Item extends BaseItem {
protected $itemType;

/** @var Parameter[] */
protected $parameters = [];
protected $parameters = array();

/** @var string|null */
protected $manufacturer;
Expand All @@ -62,19 +62,19 @@ class Item extends BaseItem {
protected $deliveryDate;

/** @var Delivery[] */
protected $deliveries = [];
protected $deliveries = array();

/** @var string|null */
protected $itemGroupId;

/** @var array */
protected $accessories = [];
protected $accessories = array();

/** @var float */
protected $dues = 0;

/** @var Gift[] */
protected $gifts = [];
protected $gifts = array();

/**
* @return float
Expand Down
9 changes: 5 additions & 4 deletions src/Generators/Zbozi/CategoriesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


use Nette\Caching\Cache;
use Nette\Caching\IStorage;
use Sergiors\Importing\Loader\Excel5FileLoader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\DelegatingLoader;
Expand All @@ -16,7 +17,7 @@ class CategoriesHelper {
/** @var \Nette\Caching\Cache */
private $cache;

function __construct(\Nette\Caching\IStorage $storage = null)
function __construct(IStorage $storage = null)
{
if ($storage) {
$this->cache = new Cache($storage, __CLASS__);
Expand All @@ -25,14 +26,14 @@ function __construct(\Nette\Caching\IStorage $storage = null)

public function getCategories()
{
$categories = [];
$categories = array();
if (!$this->cache || !($categories = $this->cache->load('categories'))) {
$file = sys_get_temp_dir() . '/file.xls';
file_put_contents($file, file_get_contents(self::CATEGORY_URL));

$loaders = [
$loaders = array(
new Excel5FileLoader(new FileLocator()),
];
);

$resolver = new LoaderResolver($loaders);
$loader = new DelegatingLoader($resolver);
Expand Down
4 changes: 2 additions & 2 deletions src/Generators/Zbozi/ExtraMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExtraMessage extends Nette\Object {
FREE_STORE_PICKUP = 'free_store_pickup',
VOUCHER = 'voucher';

static $types = [
static $types = array(
self::EXTENDED_WARRANTY,
self::FREE_ACCESSORIES,
self::FREE_CASE,
Expand All @@ -29,7 +29,7 @@ class ExtraMessage extends Nette\Object {
self::FREE_INSTALLATION,
self::FREE_STORE_PICKUP,
self::VOUCHER,
];
);

/** @var string */
protected $type;
Expand Down
4 changes: 2 additions & 2 deletions src/Generators/Zbozi/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Item extends BaseItem {
/** @var int|null */
protected $categoryId;
/** @var CategoryText[] */
protected $categoryTexts = [];
protected $categoryTexts = array();
/** @var string|null */
protected $product;
/** @var string|null */
Expand All @@ -68,7 +68,7 @@ class Item extends BaseItem {
/** @var float|null */
protected $maxCpcSearch;
/** @var Parameter[] */
protected $parameters = [];
protected $parameters = array();

#product database
/** @var string|null */
Expand Down

0 comments on commit 81918a2

Please sign in to comment.