本文整理匯總了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;
}