本文整理汇总了PHP中Varien_Event::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event::setName方法的具体用法?PHP Varien_Event::setName怎么用?PHP Varien_Event::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event
的用法示例。
在下文中一共展示了Varien_Event::setName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
}
示例3: testDispatchEventDoesNotCallApiIfNoMessages
public function testDispatchEventDoesNotCallApiIfNoMessages()
{
$e = new Varien_Event();
$e->setName('triggerCode');
$observer = new Varien_Event_Observer();
$observer->setEvent($e);
$events = $this->getEventCollection();
$this->observer->expects($this->once())->method('getEvents')->with('event', 'triggerCode')->will($this->returnValue($events));
$messages = array();
$this->messageProcessor->expects($this->once())->method('processEvents')->with($events, $observer)->will($this->returnValue($messages));
$this->esendexApi->expects($this->never())->method('sendMultipleMessages');
$this->observer->dispatchEvent($observer);
}
示例4: 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;
}