本文整理汇总了PHP中Magento\Framework\Event\Observer::getEventName方法的典型用法代码示例。如果您正苦于以下问题:PHP Observer::getEventName方法的具体用法?PHP Observer::getEventName怎么用?PHP Observer::getEventName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Event\Observer
的用法示例。
在下文中一共展示了Observer::getEventName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetEventName
public function testSetEventName()
{
$name = 'eventName';
$this->observer->setEventName($name);
$result = $this->observer->getData('event_name');
$this->assertEquals($result, $this->observer->getEventName($name));
}
示例2: addObserver
/**
* Register an observer
*
* If observer has event_name property it will be registered for this specific event.
* If not it will be registered as global observer
*
* @param Observer $observer
* @return $this
*/
public function addObserver(Observer $observer)
{
$eventName = $observer->getEventName();
if ($eventName) {
$this->getEventByName($eventName)->addObserver($observer);
} else {
$this->getGlobalObservers()->addObserver($observer);
}
return $this;
}
示例3: eavAttributeChange
/**
* Update all attribute-dependant index
*
* @param \Magento\Framework\Event\Observer $observer
* @return \Magento\CatalogSearch\Model\Fulltext\Observer
*/
public function eavAttributeChange(\Magento\Framework\Event\Observer $observer)
{
$attribute = $observer->getEvent()->getAttribute();
/* @var $attribute \Magento\Eav\Model\Entity\Attribute */
$entityType = $this->_eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY);
/* @var $entityType \Magento\Eav\Model\Entity\Type */
if ($attribute->getEntityTypeId() != $entityType->getId()) {
return $this;
}
$delete = $observer->getEventName() == 'eav_entity_attribute_delete_after';
if (!$delete && !$attribute->dataHasChangedFor('is_searchable')) {
return $this;
}
$showNotice = false;
if ($delete) {
if ($attribute->getIsSearchable()) {
$showNotice = true;
}
} elseif ($attribute->dataHasChangedFor('is_searchable')) {
$showNotice = true;
}
if ($showNotice) {
$url = $this->_backendUrl->getUrl('adminhtml/system_cache');
$this->messageManager->addNotice(__('Attribute setting change related with Search Index. Please run <a href="%1">Rebuild Search Index</a> process.', $url));
}
return $this;
}