本文整理汇总了PHP中Magento\Framework\Event\ManagerInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ManagerInterface类的具体用法?PHP ManagerInterface怎么用?PHP ManagerInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ManagerInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateAndGetTranslations
/**
* Clears cache and updates translations file
*
* @return array
*/
public function updateAndGetTranslations()
{
$this->eventManager->dispatch('adminhtml_cache_flush_system');
$translations = $this->translateResource->getTranslationArray(null, $this->localeResolver->getLocale());
$this->fileManager->updateTranslationFileContent(json_encode($translations));
return $translations;
}
示例2: send
/**
* Send email to customer
*
* @param Order $order
* @param bool $notify
* @param string $comment
* @return bool
*/
public function send(Order $order, $notify = true, $comment = '')
{
$transport = ['order' => $order, 'comment' => $comment, 'billing' => $order->getBillingAddress(), 'store' => $order->getStore(), 'formattedShippingAddress' => $this->getFormattedShippingAddress($order), 'formattedBillingAddress' => $this->getFormattedBillingAddress($order)];
$this->eventManager->dispatch('email_order_comment_set_template_vars_before', ['sender' => $this, 'transport' => $transport]);
$this->templateContainer->setTemplateVars($transport);
return $this->checkAndSend($order, $notify);
}
示例3: testProcessRelations
public function testProcessRelations()
{
$this->relationProcessorMock->expects($this->once())->method('processRelation')->with($this->salesModelMock);
$this->salesModelMock->expects($this->once())->method('getEventPrefix')->willReturn('sales_event_prefix');
$this->eventManagerMock->expects($this->once())->method('dispatch')->with('sales_event_prefix_process_relation', ['object' => $this->salesModelMock]);
$this->entityRelationComposite->processRelations($this->salesModelMock);
}
示例4: resetSearchResults
/**
* Reset search results
*
* @return $this
*/
public function resetSearchResults()
{
$connection = $this->getConnection();
$connection->update($this->getTable('search_query'), ['is_processed' => 0], ['is_processed != 0']);
$this->_eventManager->dispatch('catalogsearch_reset_search_result');
return $this;
}
示例5: dispatch
/**
* Dispatch request
*
* @param RequestInterface $request
* @return ResponseInterface
* @throws NotFoundException
*/
public function dispatch(RequestInterface $request)
{
$this->_request = $request;
$profilerKey = 'CONTROLLER_ACTION:' . $request->getFullActionName();
$eventParameters = ['controller_action' => $this, 'request' => $request];
$this->_eventManager->dispatch('controller_action_predispatch', $eventParameters);
$this->_eventManager->dispatch('controller_action_predispatch_' . $request->getRouteName(), $eventParameters);
$this->_eventManager->dispatch('controller_action_predispatch_' . $request->getFullActionName(), $eventParameters);
\Magento\Framework\Profiler::start($profilerKey);
$result = null;
if ($request->isDispatched() && !$this->_actionFlag->get('', self::FLAG_NO_DISPATCH)) {
\Magento\Framework\Profiler::start('action_body');
$result = $this->execute();
\Magento\Framework\Profiler::start('postdispatch');
if (!$this->_actionFlag->get('', self::FLAG_NO_POST_DISPATCH)) {
$this->_eventManager->dispatch('controller_action_postdispatch_' . $request->getFullActionName(), $eventParameters);
$this->_eventManager->dispatch('controller_action_postdispatch_' . $request->getRouteName(), $eventParameters);
$this->_eventManager->dispatch('controller_action_postdispatch', $eventParameters);
}
\Magento\Framework\Profiler::stop('postdispatch');
\Magento\Framework\Profiler::stop('action_body');
}
\Magento\Framework\Profiler::stop($profilerKey);
return $result ?: $this->_response;
}
示例6: getAvailableFrontendTypes
/**
* @return \Magento\Framework\Object
*/
private function getAvailableFrontendTypes()
{
$availableFrontendTypes = $this->objectFactory->create();
$availableFrontendTypes->setData(['values' => ['select']]);
$this->eventManager->dispatch('product_suggested_attribute_frontend_type_init_after', ['types_dto' => $availableFrontendTypes]);
return $availableFrontendTypes;
}
示例7: aroundUpdateAttributes
/**
* @param Action $subject
* @param \Closure $proceed
* @param array $productIds
* @param array $attrData
* @param int $storeId
* @return Action
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundUpdateAttributes(Action $subject, \Closure $proceed, $productIds, $attrData, $storeId)
{
$returnValue = $proceed($productIds, $attrData, $storeId);
$this->cacheContext->registerEntities(Product::CACHE_TAG, $productIds);
$this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]);
return $returnValue;
}
示例8: launch
/**
* Run application
*
* @return ResponseInterface
*/
public function launch()
{
$this->_state->setAreaCode('crontab');
$this->_eventManager->dispatch('default');
$this->_response->setCode(0);
return $this->_response;
}
示例9: executeFull
/**
* Execute full indexation
*
* @return void
*/
public function executeFull()
{
$this->indexBuilder->reindexFull();
$this->_eventManager->dispatch('clean_cache_by_tags', ['object' => $this]);
//TODO: remove after fix fpc. MAGETWO-50668
$this->getCacheManager()->clean($this->getIdentities());
}
示例10: resetSearchResults
/**
* Reset search results
*
* @return $this
*/
public function resetSearchResults()
{
$adapter = $this->_getWriteAdapter();
$adapter->update($this->getTable('search_query'), ['is_processed' => 0]);
$this->_eventManager->dispatch('catalogsearch_reset_search_result');
return $this;
}
示例11: convert
/**
* @param Address $object
* @param array $data
* @return OrderInterface
*/
public function convert(Address $object, $data = [])
{
$orderData = $this->objectCopyService->getDataFromFieldset(
'quote_convert_address',
'to_order',
$object
);
/**
* @var $order \Magento\Sales\Model\Order
*/
$order = $this->orderFactory->create();
$this->dataObjectHelper->populateWithArray(
$order,
array_merge($orderData, $data),
'\Magento\Sales\Api\Data\OrderInterface'
);
$order->setStoreId($object->getQuote()->getStoreId())
->setQuoteId($object->getQuote()->getId())
->setIncrementId($object->getQuote()->getReservedOrderId());
$this->objectCopyService->copyFieldsetToTarget('sales_convert_quote', 'to_order', $object->getQuote(), $order);
$this->eventManager->dispatch(
'sales_convert_quote_to_order',
['order' => $order, 'quote' => $object->getQuote()]
);
return $order;
}
示例12: afterDelete
/**
* @param DesignConfigRepository $subject
* @param DesignConfigInterface $designConfig
* @return DesignConfigInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterDelete(DesignConfigRepository $subject, DesignConfigInterface $designConfig)
{
$website = in_array($designConfig->getScope(), [ScopeInterface::SCOPE_WEBSITE, ScopeInterface::SCOPE_WEBSITES]) ? $this->storeManager->getWebsite($designConfig->getScopeId()) : '';
$store = in_array($designConfig->getScope(), [ScopeInterface::SCOPE_STORE, ScopeInterface::SCOPE_STORES]) ? $this->storeManager->getStore($designConfig->getScopeId()) : '';
$this->eventManager->dispatch('admin_system_config_changed_section_design', ['website' => $website, 'store' => $store]);
return $designConfig;
}
示例13: copyFieldsetToTarget
/**
* Copy data from object|array to object|array containing fields from fieldset matching an aspect.
*
* Contents of $aspect are a field name in target object or array.
* If targetField attribute is not provided - will be used the same name as in the source object or array.
*
* @param string $fieldset
* @param string $aspect
* @param array|\Magento\Framework\Object $source
* @param array|\Magento\Framework\Object $target
* @param string $root
* @return array|\Magento\Framework\Object|null the value of $target
*
* @api
*/
public function copyFieldsetToTarget($fieldset, $aspect, $source, $target, $root = 'global')
{
if (!$this->_isFieldsetInputValid($source, $target)) {
return null;
}
$fields = $this->_fieldsetConfig->getFieldset($fieldset, $root);
if ($fields === null) {
return $target;
}
$targetIsArray = is_array($target);
foreach ($fields as $code => $node) {
if (empty($node[$aspect])) {
continue;
}
$value = $this->_getFieldsetFieldValue($source, $code);
$targetCode = (string) $node[$aspect];
$targetCode = $targetCode == '*' ? $code : $targetCode;
if ($targetIsArray) {
$target[$targetCode] = $value;
} else {
$target->setDataUsingMethod($targetCode, $value);
}
}
$eventName = sprintf('core_copy_fieldset_%s_%s', $fieldset, $aspect);
$this->_eventManager->dispatch($eventName, ['target' => $target, 'source' => $source, 'root' => $root]);
return $target;
}
示例14: testGetHtmlTxnIdIsNull
public function testGetHtmlTxnIdIsNull()
{
$this->eventManagerMock->expects($this->once())->method('dispatch');
$this->transaction->setData('txn_id', 'test');
$this->assertEquals('test', $this->transaction->getHtmlTxnId());
$this->assertEquals(null, $this->transaction->getData('html_txn_id'));
}
示例15: getProductCollection
/**
* @return $this|\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
*/
public function getProductCollection()
{
/** @var $reviewModel \Magento\Review\Model\Review */
$reviewModel = $this->reviewFactory->create();
$collection = $reviewModel->getProductCollection()->addStatusFilter($reviewModel->getPendingStatus())->addAttributeToSelect('name', 'inner')->setDateOrder();
$this->eventManager->dispatch('rss_catalog_review_collection_select', ['collection' => $collection]);
return $collection;
}