本文整理汇总了PHP中Varien_Event_Observer::addData方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::addData方法的具体用法?PHP Varien_Event_Observer::addData怎么用?PHP Varien_Event_Observer::addData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::addData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatchEvent
/**
* @see Mage_Core_Model_App::dispatchEvent($eventName, $args)
*/
public function dispatchEvent($eventName, $args)
{
$event = new Varien_Event($args);
$event->setName($eventName);
$observer = new Varien_Event_Observer();
$observer->setData(array('event' => $event));
$observer->addData($args);
$this->_bar->update($observer->getEvent());
return parent::dispatchEvent($eventName, $args);
}
示例2: testScheduleOrderSync
/**
* @test
* @loadFixture
*/
public function testScheduleOrderSync()
{
$model = Mage::getModel("klevu_search/observer");
$order = Mage::getModel("sales/order")->load(1);
$event = new Varien_Event();
$event->addData(array("event_name" => "sales_order_place_after", "order" => $order));
$observer = new Varien_Event_Observer();
$observer->addData(array("event" => $event));
$model->scheduleOrderSync($observer);
$this->assertEquals(array(array("order_item_id" => "2")), $this->getOrderSyncQueue());
$this->assertEquals(1, $this->getOrderSyncCronScheduleCollection()->getSize(), "Failed to assert that scheduleOrderSync() schedules the Order Sync cron when called.");
}
示例3: dispatchEvent
/**
* @param $model string model syntax or class name (codex_module/observer or Codex_Module_Model_Observer)
* @param $method string the exact method name (as defined in confix.xml)
* @param $eventName string the original name of the event
* @param array $args array
*/
public static function dispatchEvent($model, $method, $eventName, array $args = array())
{
$event = new Varien_Event($args);
$event->setName($eventName);
$observer = new Varien_Event_Observer();
$observer->setData(array('event' => $event));
$observer->addData($args);
$object = Mage::getModel($model);
if (method_exists($object, $method)) {
$object->{$method}($observer);
}
}
示例4: helperGenerateObserver
/**
* Generates observer object
*
* @param array $eventData
* @param string $eventName
*
* @return Varien_Event_Observer
*/
public function helperGenerateObserver($eventData, $eventName = null)
{
$event = new Varien_Event($eventData);
$observer = new Varien_Event_Observer();
$observer->setEvent($event);
if ($eventName) {
$event->setName($eventName);
$observer->setEventName($eventName);
}
$observer->addData($eventData);
return $observer;
}
示例5: dispatchEvent
public function dispatchEvent($eventName, $args)
{
$eventName = strtolower($eventName);
foreach ($this->_events as $area => $events) {
if (!isset($events[$eventName])) {
$eventConfig = $this->getConfig()->getEventConfig($area, $eventName);
if (!$eventConfig) {
$this->_events[$area][$eventName] = false;
continue;
}
$observers = array();
foreach ($eventConfig->observers->children() as $obsName => $obsConfig) {
$observers[$obsName] = array('type' => (string) $obsConfig->type, 'model' => $obsConfig->class ? (string) $obsConfig->class : $obsConfig->getClassName(), 'method' => (string) $obsConfig->method, 'args' => (array) $obsConfig->args);
}
$events[$eventName]['observers'] = $observers;
$this->_events[$area][$eventName]['observers'] = $observers;
}
if (false === $events[$eventName]) {
continue;
} else {
$event = new Varien_Event($args);
$event->setName($eventName);
$observer = new Varien_Event_Observer();
}
foreach ($events[$eventName]['observers'] as $obsName => $obs) {
$observer->setData(array('event' => $event));
Varien_Profiler::start('OBSERVER: ' . $obsName);
switch ($obs['type']) {
case 'disabled':
break;
case 'object':
case 'model':
$method = $obs['method'];
$observer->addData($args);
$object = Mage::getModel($obs['model']);
$this->_callObserverMethod($object, $method, $observer);
break;
default:
$method = $obs['method'];
$observer->addData($args);
$object = Mage::getSingleton($obs['model']);
$this->_callObserverMethod($object, $method, $observer);
break;
}
Varien_Profiler::stop('OBSERVER: ' . $obsName);
}
}
return $this;
}