本文整理汇总了PHP中Enlight_Event_EventArgs::setReturn方法的典型用法代码示例。如果您正苦于以下问题:PHP Enlight_Event_EventArgs::setReturn方法的具体用法?PHP Enlight_Event_EventArgs::setReturn怎么用?PHP Enlight_Event_EventArgs::setReturn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enlight_Event_EventArgs
的用法示例。
在下文中一共展示了Enlight_Event_EventArgs::setReturn方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOnFilterCollectors
public function testOnFilterCollectors()
{
$container = Shopware()->Container();
$debug = $this->getDebugClass();
$eventManager = $container->get('events');
$utils = new Utils();
$arguments = new \Enlight_Event_EventArgs(['utils' => $utils, 'eventManager' => $eventManager]);
$arguments->setReturn([]);
$collectors = $debug->onFilterCollectors($arguments);
$this->assertCount(count($arguments->getReturn()), $collectors);
$arguments->setReturn([new EventCollector($eventManager, $utils)]);
$collectors = $debug->onFilterCollectors($arguments);
$this->assertCount(count($arguments->getReturn()), $collectors);
$this->assertInstanceOf('\\Shopware\\Plugins\\ShopwareClockwork\\Clockwork\\Components\\Collector\\EventCollector', $collectors[0]);
$arguments->setReturn([new TemplateCollector($container->get('template'), $utils, $container->get('kernel')->getRootDir())]);
$collectors = $debug->onFilterCollectors($arguments);
$this->assertCount(count($arguments->getReturn()), $collectors);
$this->assertInstanceOf('\\Shopware\\Plugins\\ShopwareClockwork\\Clockwork\\Components\\Collector\\TemplateCollector', $collectors[0]);
$arguments->setReturn([new EventCollector($eventManager, $utils), new TemplateCollector($container->get('template'), $utils, $container->get('kernel')->getRootDir())]);
$collectors = $debug->onFilterCollectors($arguments);
$this->assertCount(count($arguments->getReturn()), $collectors);
$this->assertInstanceOf('\\Shopware\\Plugins\\ShopwareClockwork\\Clockwork\\Components\\Collector\\EventCollector', $collectors[0]);
$this->assertInstanceOf('\\Shopware\\Plugins\\ShopwareClockwork\\Clockwork\\Components\\Collector\\TemplateCollector', $collectors[1]);
$info = [1, 2, 3];
$arguments->setReturn($info);
$collectors = $debug->onFilterCollectors($arguments);
$this->assertCount(count($arguments->getReturn()), $collectors);
$this->assertSame($info, $collectors);
}
示例2: filter
/**
* @param string $event
* @param mixed $value
* @param null $eventArgs
* @return mixed
* @throws Enlight_Event_Exception
*/
public function filter($event, $value, $eventArgs = null)
{
if (isset($eventArgs) && is_array($eventArgs)) {
$eventArgs = new Enlight_Event_EventArgs($eventArgs);
} elseif (!isset($eventArgs)) {
$eventArgs = new Enlight_Event_EventArgs();
} elseif (!$eventArgs instanceof Enlight_Event_EventArgs) {
throw new Enlight_Event_Exception('Parameter "eventArgs" must be an instance of "Enlight_Event_EventArgs"');
}
$eventArgs->setReturn($value);
$this->getPluginBootstrap()->addEvent($event, 'filter', $this->getListeners($event), $eventArgs);
return $this->events->filter($event, $value, $eventArgs);
}
示例3: filter
/**
* Checks if the event has registered listeners.
* If the event has listeners this listeners will be executed with the given event arguments.
* The event arguments have to been an array or an instance of the Enlight_Event_EventArgs class.
* If the given arguments not an array or an instance of the Enlight_Event_EventArgs class enlight
* throw an Enlight_Event_Exception.
* Before the listener will be executed the the flag "processed" will be set to false in the event arguments.
* After all event listeners has been executed the "processed" flag will be set to true.
*
* The return value of the execute method will be set in the event arguments return value.
*
* @throws Enlight_Event_Exception
*
* @param string $event
* @param mixed $value
* @param Enlight_Event_EventArgs|array|null $eventArgs
*
* @return mixed
*/
public function filter($event, $value, $eventArgs = null)
{
if (!$this->hasListeners($event)) {
return $value;
}
if (isset($eventArgs) && is_array($eventArgs)) {
$eventArgs = new Enlight_Event_EventArgs($eventArgs);
} elseif (!isset($eventArgs)) {
$eventArgs = new Enlight_Event_EventArgs();
} elseif (!$eventArgs instanceof Enlight_Event_EventArgs) {
throw new Enlight_Event_Exception('Parameter "eventArgs" must be an instance of "Enlight_Event_EventArgs"');
}
$eventArgs->setReturn($value);
$eventArgs->setName($event);
$eventArgs->setProcessed(false);
foreach ($this->getListeners($event) as $listener) {
if (null !== ($return = $listener->execute($eventArgs))) {
$eventArgs->setReturn($return);
}
}
$eventArgs->setProcessed(true);
return $eventArgs->getReturn();
}
示例4: insertOrderAttribute
/**
* Adds an Attribte to s_order for sepa
*
* @param Enlight_Event_EventArgs $args
* @return string
*/
public function insertOrderAttribute(Enlight_Event_EventArgs $args)
{
$subject = $args->getSubject();
if ($subject->sUserData['additional']['payment']['name'] === "paymilldebit") {
$sepaDays = (int) $this->Config()->get('paymillSepaDate');
if ($sepaDays < 0) {
$sepaDays = 0;
}
$timeStamp = strtotime("+" . $sepaDays . " DAYS");
$attributeSql = preg_replace('/attribute6/', 'attribute6, paymill_sepa_date', $args->getReturn());
$attributeSql = preg_replace('/\\)$/', ",{$timeStamp} )", $attributeSql);
$args->setReturn($attributeSql);
}
}
示例5: onInvalidateCacheId
/**
* Callback for Shopware_Plugins_HttpCache_InvalidateCacheId-Event
*
* This events should be used to invalidate cacheIds without having
* to check if the http-cache-plugin is installed and enabled.
*
* <code>
* Shopware()->Events()->notify(
* 'Shopware_Plugins_HttpCache_InvalidateCacheId',
* array('cacheId' => 'a123')
* );
* </code>
*
* @param \Enlight_Event_EventArgs $args
*/
public function onInvalidateCacheId(\Enlight_Event_EventArgs $args)
{
$cacheId = $args->get('cacheId');
if (!$cacheId) {
$args->setReturn(false);
return;
}
$result = $this->invalidateCacheId($cacheId);
$args->setReturn($result);
}
示例6: event_Shopware_Modules_Order_SaveOrderAttributes_FilterSQL
/**
* transfer attribute data from temp order to new finalized order, shopware doesn't do it automatically
* the temp order contains already the pushed transaction status data
*
* @param \Enlight_Event_EventArgs $args
* @return string
*/
public function event_Shopware_Modules_Order_SaveOrderAttributes_FilterSQL(\Enlight_Event_EventArgs $args)
{
$sql = $args->getReturn();
$sOrder = $args->getSubject();
$db = $sOrder->sSYSTEM->sDB_CONNECTION;
$helper = $this->Application()->PayoneMain()->getHelper();
//temporaryId
$tempId = $sOrder->sSYSTEM->sSESSION_ID;
$tempOrder = Shopware()->Models()->getRepository('Shopware\\Models\\Order\\Order')->findOneBy(array('temporaryId' => $tempId));
if (!$tempOrder) {
return;
}
$attributes = $helper->getOrCreateAttribute($tempOrder);
//inject insert SQL
$sql = str_replace("INSERT INTO s_order_attributes (", "INSERT INTO s_order_attributes " . "(mopt_payone_txid, mopt_payone_status, mopt_payone_sequencenumber, " . "mopt_payone_is_authorized, mopt_payone_is_finally_captured, mopt_payone_clearing_data, ", $sql);
$sql = str_replace(" VALUES (", " VALUES (" . $db->quote($attributes->getMoptPayoneTxid()) . ', ' . $db->quote($attributes->getMoptPayoneStatus()) . ', ' . $db->quote($attributes->getMoptPayoneSequencenumber()) . ', ' . $db->quote($attributes->getMoptPayoneIsAuthorized()) . ', ' . $db->quote($attributes->getMoptPayoneIsFinallyCaptured()) . ', ' . $db->quote($attributes->getMoptPayoneClearingData()) . ', ', $sql);
$args->setReturn($sql);
}