本文整理汇总了PHP中Mage::dispatchEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::dispatchEvent方法的具体用法?PHP Mage::dispatchEvent怎么用?PHP Mage::dispatchEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage
的用法示例。
在下文中一共展示了Mage::dispatchEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initControllerRouters
/**
*
*/
public function initControllerRouters($observer)
{
$request = $observer->getEvent()->getFront()->getRequest();
$identifier = trim($request->getPathInfo(), '/');
$condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
Mage::dispatchEvent('brand_controller_router_match_before', array('router' => $this, 'condition' => $condition));
$identifier = $condition->getIdentifier();
if ($condition->getRedirectUrl()) {
Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
$request->setDispatched(true);
return true;
}
if (!$condition->getContinue()) {
return false;
}
$route = trim(Mage::getStoreConfig('ves_brand/general_setting/route'));
if ($identifier) {
if (preg_match("#^" . $route . "(\\.html)?\$#", $identifier, $match)) {
$request->setModuleName('venusbrand')->setControllerName('brand')->setActionName('index');
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
return true;
}
return true;
}
return false;
}
示例2: save
/**
* Save config section
* Require set: section, website, store and groups
*
* @return Mage_Adminhtml_Model_Config_Data
*/
public function save()
{
Mage::dispatchEvent('searchanise_adminhtml_config_data_save_before', array('object' => $this));
$ret = parent::save();
Mage::dispatchEvent('searchanise_adminhtml_config_data_save_after', array('object' => $ret));
return $ret;
}
示例3: preDispatch
/**
* Controller pre-dispatch method
*
* @return Mage_XmlConnect_Controller_AdminAction
*/
public function preDispatch()
{
Mage::getSingleton('adminhtml/url')->turnOffSecretKey();
// override admin store design settings via stores section
Mage::getDesign()->setArea($this->_currentArea)->setPackageName((string) Mage::getConfig()->getNode('stores/admin/design/package/name'))->setTheme((string) Mage::getConfig()->getNode('stores/admin/design/theme/default'));
foreach (array('layout', 'template', 'skin', 'locale') as $type) {
$value = (string) Mage::getConfig()->getNode("stores/admin/design/theme/{$type}");
if ($value) {
Mage::getDesign()->setTheme($type, $value);
}
}
$this->getLayout()->setArea($this->_currentArea);
Mage::dispatchEvent('adminhtml_controller_action_predispatch_start', array());
Mage_Core_Controller_Varien_Action::preDispatch();
if ($this->getRequest()->isDispatched() && $this->getRequest()->getActionName() !== 'denied' && !$this->_isAllowed()) {
$this->_forward('denied');
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
return $this;
}
if (is_null(Mage::getSingleton('adminhtml/session')->getLocale())) {
Mage::getSingleton('adminhtml/session')->setLocale(Mage::app()->getLocale()->getLocaleCode());
}
$this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
if ($this->_isCheckCookieRequired()) {
$this->_checkCookie();
}
return $this;
}
示例4: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->detectMagento($output, true);
$noReinitOption = $input->getOption('no-reinit');
if (!$noReinitOption) {
$this->banUseCache();
}
if (!$this->initMagento()) {
return;
}
\Mage::app()->loadAreaPart('adminhtml', 'events');
\Mage::dispatchEvent('adminhtml_cache_flush_all', array('output' => $output));
$result = \Mage::app()->getCacheInstance()->flush();
if ($result) {
$output->writeln('<info>Cache cleared</info>');
} else {
$output->writeln('<error>Failed to clear Cache</error>');
}
if (!$noReinitOption) {
$this->reinitCache();
}
/* Since Magento 1.10 we have an own cache handler for FPC */
if ($this->isEnterpriseFullPageCachePresent()) {
$result = \Enterprise_PageCache_Model_Cache::getCacheInstance()->flush();
if ($result) {
$output->writeln('<info>FPC cleared</info>');
} else {
$output->writeln('<error>Failed to clear FPC</error>');
}
}
}
示例5: getStoreAttributes
public function getStoreAttributes()
{
$storeAttribute = new Varien_Object(array('store_attribute' => array('name', 'affiliate_type', 'status', 'description', 'commission_type', 'commission', 'sec_commission', 'sec_commission_type', 'secondary_commission', 'discount_type', 'discount', 'sec_discount', 'sec_discount_type', 'secondary_discount', 'customer_group_ids', 'show_in_welcome', 'use_tier_config', 'max_level', 'tier_commission', 'use_sec_tier', 'sec_tier_commission')));
/** Thanhpv - add even $this->_eventPrefix . '_get_store_attributes' (2012-10-11) */
Mage::dispatchEvent($this->_eventPrefix . '_get_store_attributes', array($this->_eventObject => $this, 'attributes' => $storeAttribute));
return $storeAttribute->getStoreAttribute();
}
示例6: setup
/**
* Setup GermanSetup as if a user sends the adminhtml form
* See method _getDefaultParams for possible params
*
* @param array $params
* @return FireGento_GermanSetup_Model_Setup
*/
public function setup($params = array())
{
$defaultParams = $this->_getDefaultParams();
$params = array_merge($defaultParams, $params);
Mage::register('setup_country', $params['country']);
if ($params['systemconfig']) {
Mage::getSingleton('germansetup/setup_systemconfig')->setup();
}
if ($params['cms']) {
Mage::getSingleton('germansetup/setup_cms')->setup();
}
if ($params['agreements']) {
Mage::getSingleton('germansetup/setup_agreements')->setup();
}
if ($params['email']) {
Mage::getSingleton('germansetup/setup_email')->setup($params['email_locale'], $params['overwrite_emails']);
}
if ($params['tax']) {
Mage::getSingleton('germansetup/setup_tax')->setup();
$this->_updateProductTaxClasses($params);
}
// Set a config flag to indicate that the setup has been initialized and refresh config cache.
Mage::getModel('eav/entity_setup', 'core_setup')->setConfigData('germansetup/is_initialized', '1');
Mage::app()->getCacheInstance()->cleanType('config');
Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
return $this;
}
示例7: match
/**
* Validate and Match Manufacturer Page and modify request
*
* @param Zend_Controller_Request_Http $request
* @return bool
*/
public function match(Zend_Controller_Request_Http $request)
{
if (!Mage::isInstalled()) {
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
exit;
}
$router = 'manufacturers';
$identifier = trim(str_replace('/manufacturers/', '', $request->getPathInfo()), '/');
$condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
Mage::dispatchEvent('manufacturer_controller_router_match_before', array('router' => $this, 'condition' => $condition));
$identifier = $condition->getIdentifier();
if ($condition->getRedirectUrl()) {
Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
$request->setDispatched(true);
return true;
}
if (!$condition->getContinue()) {
return false;
}
$manufacturer = Mage::getModel('zeon_manufacturer/manufacturer');
$manufacturerId = $manufacturer->checkIdentifier($identifier, Mage::app()->getStore()->getId());
if (trim($identifier) && $manufacturerId) {
$request->setModuleName('manufacturers')->setControllerName('index')->setActionName('view')->setParam('manufacturer_id', $manufacturerId);
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $router . '/' . $identifier);
return true;
}
return false;
}
示例8: _prepareForm
protected function _prepareForm()
{
/** @var $model Mage_Cms_Model_Page */
$model = Mage::registry('cms_page');
/*
* Checking if user have permissions to save information
*/
if ($this->_isAllowedAction('save')) {
$isElementDisabled = false;
} else {
$isElementDisabled = true;
}
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('page_');
$fieldset = $form->addFieldset('content_fieldset', array('legend' => Mage::helper('cms')->__('Content'), 'class' => 'fieldset-wide'));
$wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('tab_id' => $this->getTabId()));
$fieldset->addField('content_heading', 'text', array('name' => 'content_heading', 'label' => Mage::helper('cms')->__('Content Heading'), 'title' => Mage::helper('cms')->__('Content Heading'), 'disabled' => $isElementDisabled));
$contentField = $fieldset->addField('content', 'editor', array('name' => 'content', 'style' => 'height:36em;', 'required' => true, 'disabled' => $isElementDisabled, 'config' => $wysiwygConfig));
// Setting custom renderer for content field to remove label column
$renderer = $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element')->setTemplate('cms/page/edit/form/renderer/content.phtml');
$contentField->setRenderer($renderer);
$form->setValues($model->getData());
$this->setForm($form);
Mage::dispatchEvent('adminhtml_cms_page_edit_tab_content_prepare_form', array('form' => $form));
return parent::_prepareForm();
}
示例9: saveAction
public function saveAction()
{
$data = $this->getRequest()->getParams();
$data['api_key'] = trim($data['api_key']);
$model = Mage::getModel('pdfpro/key');
$data['store_ids'] = implode(',', $data['store_ids']);
$data['customer_group_ids'] = implode(',', $data['customer_group_ids']);
$model->setData($data)->setId($this->getRequest()->getParam('id'));
Mage::dispatchEvent('ves_pdfpro_apikey_form_save_before', array('model' => $model));
try {
$model->save();
Mage::dispatchEvent('ves_pdfpro_apikey_form_save_after', array('model' => $model));
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('pdfpro')->__('The API Key has been saved.'));
Mage::getSingleton('adminhtml/session')->setGroupData(false);
if ($this->getRequest()->getParam('back')) {
$this->_redirect('*/*/edit', array('id' => $model->getId()));
return;
}
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setGroupData($data);
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
return;
}
}
示例10: _prepareForm
/**
* Prepare Mail Target Rule Edit form
*
* @return Enterprise_TargetRule_Block_Adminhtml_Targetrule_Edit_Tab_Main
*/
protected function _prepareForm()
{
/* @var $model Enterprise_TargetRule_Model_Rule */
$model = Mage::registry('current_target_rule');
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('rule_');
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('enterprise_targetrule')->__('General Rule Information')));
if ($model->getId()) {
$fieldset->addField('rule_id', 'hidden', array('name' => 'rule_id'));
}
$fieldset->addField('name', 'text', array('name' => 'name', 'label' => Mage::helper('enterprise_targetrule')->__('Rule Name'), 'required' => true));
$fieldset->addField('sort_order', 'text', array('name' => 'sort_order', 'label' => Mage::helper('enterprise_targetrule')->__('Priority')));
$fieldset->addField('is_active', 'select', array('label' => Mage::helper('enterprise_targetrule')->__('Status'), 'name' => 'is_active', 'required' => true, 'options' => array('1' => Mage::helper('enterprise_targetrule')->__('Active'), '0' => Mage::helper('enterprise_targetrule')->__('Inactive'))));
if (!$model->getId()) {
$model->setData('is_active', '1');
}
$fieldset->addField('apply_to', 'select', array('label' => Mage::helper('enterprise_targetrule')->__('Apply To'), 'name' => 'apply_to', 'required' => true, 'options' => Mage::getSingleton('enterprise_targetrule/rule')->getAppliesToOptions(true)));
// TODO: fix possible issues with date format
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$fieldset->addField('from_date', 'date', array('name' => 'from_date', 'label' => Mage::helper('enterprise_targetrule')->__('From Date'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso));
$fieldset->addField('to_date', 'date', array('name' => 'to_date', 'label' => Mage::helper('enterprise_targetrule')->__('To Date'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso));
$fieldset->addField('positions_limit', 'text', array('name' => 'positions_limit', 'label' => Mage::helper('enterprise_targetrule')->__('Result Limit'), 'note' => Mage::helper('enterprise_targetrule')->__('Maximum number of products that can be matched by this Rule. Capped to 20.')));
Mage::dispatchEvent('targetrule_edit_tab_main_after_prepare_form', array('model' => $model, 'form' => $form, 'block' => $this));
$form->setValues($model->getData());
if ($model->isReadonly()) {
foreach ($fieldset->getElements() as $element) {
$element->setReadonly(true, true);
}
}
$this->setForm($form);
return parent::_prepareForm();
}
示例11: _afterSave
/**
* Cleanup blocks HTML cache if value has been changed
*
* @return Enterprise_WebsiteRestriction_Model_System_Config_Backend_Active
*/
protected function _afterSave()
{
if ($this->isValueChanged()) {
Mage::dispatchEvent('clean_cache_by_tags', array('tags' => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)));
}
return parent::_afterSave();
}
示例12: mergeCategories
/**
* @param bool $deleteSource
*
* @return bool
*/
public function mergeCategories($deleteSource = false)
{
$this->_deleteSource = $deleteSource;
try {
// Check if both categories exist
if (!$this->_source->getId() || !$this->_target->getId()) {
return false;
}
$this->_moveProducts();
$this->_moveChildrenCategories();
// Just delete a category which is not parent of the target
if ($this->_deleteSource && !in_array($this->_source->getId(), $this->_target->getParentIds())) {
$this->_source->delete();
}
/** @var $index Mage_Index_Model_Process */
$index = Mage::getModel('index/process')->load('catalog_category_product', 'indexer_code');
if ($index->getId() && $index->getMode() == Mage_Index_Model_Process::MODE_REAL_TIME) {
$index->reindexEverything();
}
Mage::dispatchEvent('mkleine_category_merge_finished', array('source_category' => $this->_source, 'target_category' => $this->_target));
return true;
} catch (Exception $e) {
Mage::logException($e);
return false;
}
}
示例13: initControllerRouters
/**
*
*/
public function initControllerRouters($observer)
{
Mage::getSingleton('core/session', array('name' => 'adminhtml'));
if (!is_null(Mage::registry("_singleton/admin/session"))) {
if (Mage::getSingleton('admin/session')->isLoggedIn()) {
/*Is admin*/
//do stuff
return;
}
}
$request = $observer->getEvent()->getFront()->getRequest();
if (!Mage::app()->isInstalled()) {
/*
Mage::app()->getFrontController()->getResponse()
->setRedirect(Mage::getUrl('install'))
->sendResponse();
*/
return;
}
$identifier = trim($request->getPathInfo(), '/');
$condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
Mage::dispatchEvent('blog_controller_router_match_before', array('router' => $this, 'condition' => $condition));
$identifier = $condition->getIdentifier();
$identifier = trim($identifier, "/");
if ($condition->getRedirectUrl()) {
Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
$request->setDispatched(true);
return true;
}
if (!$condition->getContinue()) {
return false;
}
$route = trim(Mage::getStoreConfig('ves_blog/general_setting/route'));
if ($identifier) {
if (preg_match("#^" . $route . "(\\.html)?\$#", $identifier, $match)) {
$request->setModuleName('venusblog')->setControllerName('index')->setActionName('index');
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
return true;
} elseif (str_replace('/rss', '', str_replace($route, '', $identifier)) == '') {
$request->setModuleName('venusblog')->setControllerName('rss')->setActionName('index');
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
return true;
} elseif (preg_match("#" . $route . "/tag/(\\w+)\\.?#", $identifier, $match)) {
if (count($match) <= 1) {
return false;
}
$request->setModuleName('venusblog')->setControllerName('list')->setActionName('show')->setParam("tag", $match[1]);
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
return true;
} elseif (preg_match("#" . $route . "/archive/(\\w+)\\.?#", $identifier, $match)) {
if (count($match) <= 1) {
return false;
}
$request->setModuleName('venusblog')->setControllerName('list')->setActionName('show')->setParam("archive", $match[1]);
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
return true;
}
}
return false;
}
示例14: match
public function match(Zend_Controller_Request_Http $request)
{
if (!Mage::isInstalled()) {
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
exit;
}
$identifier = trim($request->getPathInfo(), '/');
$condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true));
Mage::dispatchEvent('magicproduct_controller_router_match_before', array('router' => $this, 'condition' => $condition));
$identifier = $condition->getIdentifier();
if ($condition->getRedirectUrl()) {
Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse();
$request->setDispatched(true);
return true;
}
if (!$condition->getContinue()) {
return false;
}
if (!in_array($identifier, $this->router)) {
return false;
}
$request->setModuleName('magicproduct')->setControllerName('index')->setActionName('product')->setParam('type', $identifier);
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
return true;
}
示例15: _initVendor
/**
* Initialize requested vendor object
*
* @return Ced_CsMarketplace_Model_Vendor
*/
protected function _initVendor()
{
Mage::dispatchEvent('csmarketplace_controller_vshops_init_before', array('controller_action' => $this));
if (!Mage::helper('csmarketplace/acl')->isEnabled()) {
return false;
}
$shopUrl = Mage::getModel('csmarketplace/vendor')->getShopUrlKey($this->getRequest()->getParam('shop_url', ''));
if (!strlen($shopUrl)) {
return false;
}
$vendor = Mage::getModel('csmarketplace/vendor')->setStoreId(Mage::app()->getStore()->getId())->loadByAttribute('shop_url', $shopUrl);
if (!Mage::helper('csmarketplace')->canShow($vendor)) {
return false;
} else {
if (!Mage::helper('csmarketplace')->isShopEnabled($vendor)) {
return false;
}
}
//Mage::getSingleton('catalog/session')->setLastVisitedCategoryId($category->getId());
Mage::register('current_vendor', $vendor);
//Mage::register('current_entity_key', $category->getPath());
try {
Mage::dispatchEvent('csmarketplace_controller_vshops_init_after', array('vendor' => $vendor, 'controller_action' => $this));
} catch (Mage_Core_Exception $e) {
Mage::logException($e);
return false;
}
return $vendor;
}