本文整理汇总了PHP中Enlight_Event_EventArgs::getEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP Enlight_Event_EventArgs::getEntity方法的具体用法?PHP Enlight_Event_EventArgs::getEntity怎么用?PHP Enlight_Event_EventArgs::getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enlight_Event_EventArgs
的用法示例。
在下文中一共展示了Enlight_Event_EventArgs::getEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refreshArticle
/**
* Refresh the top seller data of a single article.
* @param Enlight_Event_EventArgs $arguments
*/
public function refreshArticle(Enlight_Event_EventArgs $arguments)
{
if (!$this->isTopSellerActivated()) {
return;
}
/**@var $article \Shopware\Models\Article\Article*/
$article = $arguments->getEntity();
if (!$article instanceof \Shopware\Models\Article\Article) {
return;
}
if (!$article->getId() > 0) {
return;
}
$this->TopSeller()->refreshTopSellerForArticleId($article->getId());
}
示例2: onPostPersist
/**
* @param Enlight_Event_EventArgs $eventArgs
*/
public function onPostPersist(Enlight_Event_EventArgs $eventArgs)
{
if(empty($this->Config()->proxyBan)) {
return;
}
if($this->proxyUrl === null || $this->request->getHeader('Surrogate-Capability') === false) {
return;
}
$entity = $eventArgs->get('entity');
if ($entity instanceof \Doctrine\ORM\Proxy\Proxy) {
$entityName = get_parent_class($entity);
} else {
$entityName = get_class($eventArgs->getEntity());
}
$categoryIds = array();
$articleIds = array();
switch ($entityName) {
case 'Shopware\Models\Article\Article':
$articleIds[] = $entity->getId();
foreach ($entity->getCategories() as $category) {
$categoryIds[] = $category->getId();
}
break;
case 'Shopware\Models\Category\Category':
$categoryIds[] = $entity->getId();
break;
case 'Shopware\Models\Banner\Banner':
$categoryIds[] = $entity->getCategoryId();
break;
}
$client = new Zend_Http_Client(null, array(
'useragent' => 'Shopware/' . Shopware()->Config()->version,
'timeout' => 5,
));
try {
foreach ($categoryIds as $categoryId) {
$client->setUri(
$this->proxyUrl . urlencode('c-' . $categoryId)
)->request('BAN');
}
foreach ($articleIds as $articleId) {
$client->setUri(
$this->proxyUrl . urlencode('a-' . $articleId)
)->request('BAN');
}
} catch(Exception $e) { }
}