testd85
9.11.2014 - 04:10
получаю следующую ошибку
PHP Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in site.com/app/code/community/EbayEnterprise/Affiliate/Helper/Data.php on line 41
вот эти строки в Data.php
37 public function getAllProgramIds()
38 {
39 $config = Mage::helper('eems_affiliate/config');
40 return array_unique(array_filter(array_map(
41 function ($website) use ($config) {
42 return $config->getProgramId($website->getDefaultStore());
43 },
44 Mage::app()->getWebsites()
45 )));
46 }
этот код для версии php 5.3 - как его переделать для php 5.2.17?
обновить php не предлагать/
Спасибо.
testd85
это метод класса или функция?
_____________
Промокод предоставляет скидку на заказ домена и/или хостинга reg.ru
BFCC-3895-8804-9ED2
create-function
_____________
Промокод предоставляет скидку на заказ домена и/или хостинга reg.ru
BFCC-3895-8804-9ED2
testd85
9.11.2014 - 04:57
Вот целый код файла data.php
<?php
class EbayEnterprise_Affiliate_Helper_Data extends Mage_Core_Helper_Abstract
{
/**
* Build the beacon url given an array keys
* @param array $params
* @return string
*/
public function buildBeaconUrl(array $params)
{
return Mage::helper('eems_affiliate/config')->getBeaconBaseUrl() . '?' .
http_build_query($params);
}
/**
* Get all unique configured program ids. Program ids may only be set at the
* website level, so only get the program id for the default store for
* each website.
* @return array
*/
public function getAllProgramIds()
{
$config = Mage::helper('eems_affiliate/config');
return array_unique(array_filter(array_map(
function ($website) use ($config) {
return $config->getProgramId($website->getDefaultStore());
},
Mage::app()->getWebsites()
)));
}
/**
* Get a single store view for a program id. As program ids are configured
* only at the global or website level, the store view selecetd will be
* the default store view for the scope the configuration is set at. When
* set globally, the default store view for the Magento instance will be
* selected. When set at a website level, the default store view for that
* website will be used.
* @param string $programId
* @return Mage_Core_Model_Store|null
*/
public function getStoreForProgramId($programId)
{
$config = Mage::helper('eems_affiliate/config');
// Check for the default store view to be this program id first, will match
// when the program id is set at the global level.
$defaultStoreView = Mage::app()->getDefaultStoreView();
$defaultProgramId = $config->getProgramId($defaultStoreView);
if ($programId === $defaultProgramId) {
return $defaultStoreView;
}
// When set at the website level, use the first website encountered
// with a matching program id
foreach (Mage::app()->getWebsites() as $website) {
$storeView = $website->getDefaultStore();
if ($config->getProgramId($storeView) === $programId) {
return $storeView;
}
}
return null;
}
/**
* Get all store views that have a program id that matches the given
* program id
* @param string $programId
* @return Mage_Core_Model_Store[]
*/
public function getAllStoresForProgramId($programId)
{
$config = Mage::helper('eems_affiliate/config');
return array_filter(
Mage::app()->getStores(),
function ($store) use ($config, $programId) {
return $config->getProgramId($store) === $programId;
}
);
}
/**
* take a boolean value and return the string 'yes' or 'no' when the boolean
* value is true or false
* @param bool $value
* @return string
* @codeCoverageIgnore
*/
public function parseBoolToYesNo($value)
{
return $value?'yes':'no';
}
}
testd85
9.11.2014 - 05:00
честно говоря я ноль в кодах - помогите пожалуйста если есть время или возможноть. Спасибо заранее. Извините если что не так.
testd85попробуй так
public function getAllProgramIds() {
$config = Mage::helper('eems_affiliate/config');
return array_unique(
array_filter(
array_map(
create_function('$config,$website','return $config->getProgramId($website->getDefaultStore());'),
Mage::app()->getWebsites()
)
)
);
}
_____________
Промокод предоставляет скидку на заказ домена и/или хостинга reg.ru
BFCC-3895-8804-9ED2
Или так, $website вроде глобальная.
public function getAllProgramIds() {
global $website;
$config = Mage::helper('eems_affiliate/config');
return array_unique(
array_filter(
array_map(
create_function('$config,$website','return $config->getProgramId($website->getDefaultStore());'),
Mage::app()->getWebsites()
)
)
);
}
_____________
Промокод предоставляет скидку на заказ домена и/или хостинга reg.ru
BFCC-3895-8804-9ED2
Arh, а почему вы ему не предлагаете использовать анонимные функции?
_____________
Люди, имеющие низкий уровень квалификации, делают ошибочные выводы, принимают неудачные решения и при этом неспособны осознавать свои ошибки в силу низкого уровня своей квалификации
cheeОни же с 5.3 только появились, а он просит запустить код на 5.2
http://php.net/manual/ru/functions.anonymous.php Цитата |
5.3.0 Появление анонимных функций. |
_____________
Промокод предоставляет скидку на заказ домена и/или хостинга reg.ru
BFCC-3895-8804-9ED2
testd85
9.11.2014 - 15:46
Цитата (Arh @ 9.11.2014 - 05:13) |
Или так, $website вроде глобальная.
public function getAllProgramIds() { global $website; $config = Mage::helper('eems_affiliate/config'); return array_unique( array_filter( array_map( create_function('$config,$website','return $config->getProgramId($website->getDefaultStore());'), Mage::app()->getWebsites() ) ) ); } |
Спасибо теперь работает, только дальше еще появилась аналогичная ошибка в конце кода в строке 89
85 public function getAllStoresForProgramId($programId)
86 {
87 $config = Mage::helper('eems_affiliate/config');
88 return array_filter(
89 Mage::app()->getStores(),
90 function ($store) use ($config, $programId) {
91 return $config->getProgramId($store) === $programId;
92 }
93 );
}
помогите еще чуть-чуть.
Заранее спасибо.
testd85
9.11.2014 - 16:27
вот код от 85 строки до конца
public function getAllStoresForProgramId($programId)
{
$config = Mage::helper('eems_affiliate/config');
return array_filter(
Mage::app()->getStores(),
function ($store) use ($config, $programId) {
return $config->getProgramId($store) === $programId;
}
);
}
@param @return @codeCoverageIgnore
public function parseBoolToYesNo($value)
{
return $value?'yes':'no';
}
}
testd85там тоже используется анонимная функция
function ($store) use ($config, $programId) {
return $config->getProgramId($store) === $programId;
}
_____________
Промокод предоставляет скидку на заказ домена и/или хостинга reg.ru
BFCC-3895-8804-9ED2
testd85
9.11.2014 - 20:16
Цитата (Arh @ 9.11.2014 - 18:29) |
testd85 там тоже используется анонимная функция
function ($store) use ($config, $programId) { return $config->getProgramId($store) === $programId; } |
так будет верно ли я ошибаюсь?
public function getAllStoresForProgramId($programId)
{
$config = Mage::helper('eems_affiliate/config');
return array_filter(
Mage::app()->getStores(),
create_function('$store,$config,$programId','return $config->getProgramId($store) === $programId;')
}
);
еще добавьте global $store
_____________
Промокод предоставляет скидку на заказ домена и/или хостинга reg.ru
BFCC-3895-8804-9ED2
testd85
9.11.2014 - 20:32
Цитата (Arh @ 9.11.2014 - 20:19) |
еще добавьте global $store |
сделал так
public function getAllStoresForProgramId($programId)
{
$config = Mage::helper('eems_affiliate/config');
return array_filter(
Mage::app()->getStores(),
90 строка global $store
create_function('$store,$config,$programId','return $config->getProgramId($store) === $programId;')
}
);
теперь новая ошибка
PHP Parse error: syntax error, unexpected T_GLOBAL in site.com/app/code/community/EbayEnterprise/Affiliate/Helper/Data.php on line 90
Быстрый ответ:
Powered by dgreen
Здесь расположена полная версия этой страницы.