/** * Returns the locale object for the context * * @param \MShop_Context_Item_Interface $context Context object * @return \MShop_Locale_Item_Interface Locale item object */ protected function getLocale(\MShop_Context_Item_Interface $context) { if (!isset(self::$locale)) { $session = $context->getSession(); $config = $context->getConfig(); $sitecode = $config->get('mshop/locale/site', 'default'); $name = $config->get('typo3/param/name/site', 'loc-site'); if ($this->request->hasArgument($name) === true) { $sitecode = $this->request->getArgument($name); } $langid = $config->get('mshop/locale/language', ''); $name = $config->get('typo3/param/name/language', 'loc-language'); if (isset($GLOBALS['TSFE']->config['config']['language'])) { $langid = $GLOBALS['TSFE']->config['config']['language']; } if ($this->request->hasArgument($name) === true) { $langid = $this->request->getArgument($name); } $currency = $config->get('mshop/locale/currency', ''); $name = $config->get('typo3/param/name/currency', 'loc-currency'); if ($this->request->hasArgument($name) === true) { $currency = $this->request->getArgument($name); } $localeManager = \MShop_Locale_Manager_Factory::createManager($context); self::$locale = $localeManager->bootstrap($sitecode, $langid, $currency); } return self::$locale; }
/** * Adds the decorators to the controller object. * * @param MShop_Context_Item_Interface $context Context instance with necessary objects * @param Controller_ExtJS_Common_Interface $controller Controller object * @param string $domain Domain name in lower case, e.g. "product" * @return Controller_ExtJS_Common_Interface Controller object */ protected static function _addControllerDecorators(MShop_Context_Item_Interface $context, Controller_ExtJS_Interface $controller, $domain) { if (!is_string($domain) || $domain === '') { throw new Controller_ExtJS_Exception(sprintf('Invalid domain "%1$s"', $domain)); } $subdomains = explode('/', $domain); $domain = $localClass = $subdomains[0]; if (count($subdomains) > 1) { $localClass = str_replace(' ', '_', ucwords(implode(' ', $subdomains))); } $config = $context->getConfig(); $decorators = $config->get('controller/extjs/common/decorators/default', array()); $excludes = $config->get('controller/extjs/' . $domain . '/decorators/excludes', array()); foreach ($decorators as $key => $name) { if (in_array($name, $excludes)) { unset($decorators[$key]); } } $classprefix = 'Controller_ExtJS_Common_Decorator_'; $controller = self::_addDecorators($context, $controller, $decorators, $classprefix); $classprefix = 'Controller_ExtJS_Common_Decorator_'; $decorators = $config->get('controller/extjs/' . $domain . '/decorators/global', array()); $controller = self::_addDecorators($context, $controller, $decorators, $classprefix); $classprefix = 'Controller_ExtJS_' . $localClass . '_Decorator_'; $decorators = $config->get('controller/extjs/' . $domain . '/decorators/local', array()); $controller = self::_addDecorators($context, $controller, $decorators, $classprefix); return $controller; }
/** * Creates the type manager using the given context object. * * @param MShop_Context_Item_Interface $context Context object with required objects * * @throws MShop_Exception if no configuration is available */ public function __construct(MShop_Context_Item_Interface $context) { $conf = $context->getConfig(); $confpath = $this->_getConfigPath(); $this->_config = array('insert' => $conf->get($confpath . 'insert'), 'update' => $conf->get($confpath . 'update'), 'delete' => $conf->get($confpath . 'delete'), 'search' => $conf->get($confpath . 'search'), 'count' => $conf->get($confpath . 'count'), 'newid' => $conf->get($confpath . 'newid')); $this->_searchConfig = $this->_getSearchConfig(); $required = array('count', 'delete', 'insert', 'newid', 'search', 'update'); $isList = array_keys($this->_config); foreach ($required as $key) { if (!in_array($key, $isList)) { throw new MShop_Exception(sprintf('Configuration of necessary SQL statement for "%1$s" not available', $key)); } } parent::__construct($context); $this->_context = $context; if (($entry = reset($this->_searchConfig)) === false) { throw new MShop_Exception(sprintf('Search configuration not available')); } if (($pos = strrpos($entry['code'], '.')) == false) { throw new MShop_Exception(sprintf('Search configuration for "%1$s" not available', $entry['code'])); } if (($this->_prefix = substr($entry['code'], 0, $pos + 1)) === false) { throw new MShop_Exception(sprintf('Search configuration for "%1$s" not available', $entry['code'])); } }
/** * Creates a new controller specified by the given name. * * @param MShop_Context_Item_Interface $context Context object required by controllers * @param string|null $name Name of the controller or "Default" if null * @return Controller_Common_Order_Interface New order controller object * @throws Controller_Common_Exception */ public static function createController(MShop_Context_Item_Interface $context, $name = null) { /** classes/controller/common/order/name * Class name of the used order common controller implementation * * Each default common controller can be replace by an alternative imlementation. * To use this implementation, you have to set the last part of the class * name as configuration value so the controller factory knows which class it * has to instantiate. * * For example, if the name of the default class is * * Controller_Common_Order_Default * * and you want to replace it with your own version named * * Controller_Common_Order_Myorder * * then you have to set the this configuration option: * * classes/controller/common/order/name = Myorder * * The value is the last part of your own class name and it's case sensitive, * so take care that the configuration value is exactly named like the last * part of the class name. * * The allowed characters of the class name are A-Z, a-z and 0-9. No other * characters are possible! You should always start the last part of the class * name with an upper case character and continue only with lower case characters * or numbers. Avoid chamel case names like "MyOrder"! * * @param string Last part of the class name * @since 2014.07 * @category Developer */ if ($name === null) { $name = $context->getConfig()->get('classes/controller/common/order/name', 'Default'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? 'Controller_Common_Order_' . $name : '<not a string>'; throw new Controller_Common_Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); } $iface = 'Controller_Common_Order_Interface'; $classname = 'Controller_Common_Order_' . $name; if (isset(self::$_objects[$classname])) { return self::$_objects[$classname]; } if (class_exists($classname) === false) { throw new Controller_Common_Exception(sprintf('Class "%1$s" not available', $classname)); } $controller = new $classname($context); if (!$controller instanceof $iface) { throw new Controller_Common_Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $interface)); } return $controller; }
/** * Creates a new controller specified by the given name. * * @param MShop_Context_Item_Interface $context Context object required by controllers * @param Arcavias $arcavias Arcavias object * @param string|null $name Name of the controller or "Default" if null * @return Controller_Jobs_Interface New controller object */ public static function createController(MShop_Context_Item_Interface $context, Arcavias $arcavias, $name = null) { /** classes/controller/jobs/service/delivery/process/name * Class name of the used service delivery process scheduler controller implementation * * @param string Last part of the class name * @since 2014.03 * @category Developer * @deprecated Use classes/controller/jobs/order/service/delivery/name instead */ if ($name === null) { $name = $context->getConfig()->get('classes/controller/jobs/service/delivery/process/name', 'Default'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? 'Controller_Jobs_Service_Delivery_Process_' . $name : '<not a string>'; throw new Controller_Jobs_Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); } $iface = 'Controller_Jobs_Interface'; $classname = 'Controller_Jobs_Service_Delivery_Process_' . $name; $controller = self::_createController($context, $arcavias, $classname, $iface); /** controller/jobs/service/decorators/excludes * Excludes decorators added by the "common" option from the service job controllers * * @param array List of decorator names * @since 2014.03 * @category Developer * @see controller/jobs/common/decorators/default * @see controller/jobs/service/decorators/global * @see controller/jobs/service/decorators/local * @deprecated Use controller/jobs/order/decorators/excludes instead */ /** controller/jobs/service/decorators/global * Adds a list of globally available decorators only to the service job controllers * * @param array List of decorator names * @since 2014.03 * @category Developer * @see controller/jobs/common/decorators/default * @see controller/jobs/service/decorators/excludes * @see controller/jobs/service/decorators/local * @deprecated Use controller/jobs/order/decorators/global instead */ /** controller/jobs/service/decorators/local * Adds a list of local decorators only to the service jos controllers * * @param array List of decorator names * @since 2014.03 * @category Developer * @see controller/jobs/common/decorators/default * @see controller/jobs/service/decorators/excludes * @see controller/jobs/service/decorators/global * @deprecated Use controller/jobs/order/decorators/local instead */ return self::_addControllerDecorators($context, $arcavias, $controller, 'service/delivery/process'); }
/** * @param string $name */ public static function createController(MShop_Context_Item_Interface $context, $name = null, $domainToTest = 'plugin') { if ($name === null) { $name = $context->getConfig()->get('classes/controller/extjs/plugin/name', 'Default'); } if (ctype_alnum($name) === false) { throw new Controller_ExtJS_Exception(sprintf('Invalid class name "%1$s"', $name)); } $iface = 'Controller_ExtJS_Common_Interface'; $classname = 'Controller_ExtJS_Plugin_' . $name; $manager = self::_createController($context, $classname, $iface); return self::_addControllerDecorators($context, $manager, $domainToTest); }
/** * @param string $name */ public static function createController(MShop_Context_Item_Interface $context, $name = null, $domainToTest = 'service') { if ($name === null) { $name = $context->getConfig()->get('classes/controller/frontend/service/name', 'Default'); } if (ctype_alnum($name) === false) { throw new Controller_Frontend_Exception(sprintf('Invalid characters in class name "%1$s"', $name)); } $iface = 'Controller_Frontend_Service_Interface'; $classname = 'Controller_Frontend_Service_' . $name; $manager = self::_createController($context, $classname, $iface); return self::_addControllerDecorators($context, $manager, $domainToTest); }
/** * Creates a price manager DAO object. * * @param MShop_Context_Item_Interface $context Shop context instance with necessary objects * @param string $name Manager name * @return MShop_Common_Manager_Interface Manager object implementing the manager interface * @throws MShop_Price_Exception|MShop_Exception If requested manager * implementation couldn't be found or initialisation fails */ public static function createManager(MShop_Context_Item_Interface $context, $name = null) { if ($name === null) { $name = $context->getConfig()->get('classes/price/manager/name', 'Default'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? 'MShop_Price_Manager_' . $name : '<not a string>'; throw new MShop_Price_Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); } $iface = 'MShop_Price_Manager_Interface'; $classname = 'MShop_Price_Manager_' . $name; $manager = self::_createManager($context, $classname, $iface); return self::_addManagerDecorators($context, $manager, 'price'); }
/** * Adds the decorators to the controller object. * * @param MShop_Context_Item_Interface $context Context instance with necessary objects * @param Controller_ExtJS_Common_Interface $controller Controller object * @param string $domain Domain name in lower case, e.g. "product" * @return Controller_ExtJS_Common_Interface Controller object */ protected static function _addControllerDecorators(MShop_Context_Item_Interface $context, Controller_ExtJS_Interface $controller, $domain) { if (!is_string($domain) || $domain === '') { throw new Controller_ExtJS_Exception(sprintf('Invalid domain "%1$s"', $domain)); } $subdomains = explode('/', $domain); $domain = $localClass = $subdomains[0]; if (count($subdomains) > 1) { $localClass = str_replace(' ', '_', ucwords(implode(' ', $subdomains))); } $config = $context->getConfig(); /** controller/extjs/common/decorators/default * Configures the list of decorators applied to all ExtJS controllers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to configure a list of decorator names that should * be wrapped around the original instance of all created clients: * * controller/extjs/common/decorators/default = array( 'decorator1', 'decorator2' ) * * This would wrap the decorators named "decorator1" and "decorator2" around * all client instances in that order. The decorator classes would be * "Controller_ExtJS_Common_Decorator_Decorator1" and * "Controller_ExtJS_Common_Decorator_Decorator2". * * @param array List of decorator names * @since 2014.03 * @category Developer */ $decorators = $config->get('controller/extjs/common/decorators/default', array()); $excludes = $config->get('controller/extjs/' . $domain . '/decorators/excludes', array()); foreach ($decorators as $key => $name) { if (in_array($name, $excludes)) { unset($decorators[$key]); } } $classprefix = 'Controller_ExtJS_Common_Decorator_'; $controller = self::_addDecorators($context, $controller, $decorators, $classprefix); $classprefix = 'Controller_ExtJS_Common_Decorator_'; $decorators = $config->get('controller/extjs/' . $domain . '/decorators/global', array()); $controller = self::_addDecorators($context, $controller, $decorators, $classprefix); $classprefix = 'Controller_ExtJS_' . ucfirst($localClass) . '_Decorator_'; $decorators = $config->get('controller/extjs/' . $domain . '/decorators/local', array()); $controller = self::_addDecorators($context, $controller, $decorators, $classprefix); return $controller; }
public static function createController(MShop_Context_Item_Interface $context, $name = null) { /** classes/controller/extjs/customer/list/type/name * Class name of the used ExtJS customer list type controller implementation * * Each default ExtJS controller can be replace by an alternative imlementation. * To use this implementation, you have to set the last part of the class * name as configuration value so the client factory knows which class it * has to instantiate. * * For example, if the name of the default class is * * Controller_ExtJS_Customer_List_Type_Default * * and you want to replace it with your own version named * * Controller_ExtJS_Customer_List_Type_Mytype * * then you have to set the this configuration option: * * classes/controller/extjs/customer/list/type/name = Mytype * * The value is the last part of your own class name and it's case sensitive, * so take care that the configuration value is exactly named like the last * part of the class name. * * The allowed characters of the class name are A-Z, a-z and 0-9. No other * characters are possible! You should always start the last part of the class * name with an upper case character and continue only with lower case characters * or numbers. Avoid chamel case names like "MyType"! * * @param string Last part of the class name * @since 2014.03 * @category Developer */ if ($name === null) { $name = $context->getConfig()->get('classes/controller/extjs/customer/list/type/name', 'Default'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? 'Controller_ExtJS_Customer_List_Type_' . $name : '<not a string>'; throw new Controller_ExtJS_Exception(sprintf('Invalid class name "%1$s"', $classname)); } $iface = 'Controller_ExtJS_Common_Interface'; $classname = 'Controller_ExtJS_Customer_List_Type_' . $name; $manager = self::_createController($context, $classname, $iface); return self::_addControllerDecorators($context, $manager, 'customer/list/type'); }
/** * Creates a list client object. * * @param MShop_Context_Item_Interface $context Shop context instance with necessary objects * @param array $templatePaths List of file system paths where the templates are stored * @param string|null $name Client name (default: "Default") * @return Client_Html_Interface Filter part implementing Client_Html_Interface * @throws Client_Html_Exception If requested client implementation couldn't be found or initialisation fails */ public static function createClient(MShop_Context_Item_Interface $context, array $templatePaths, $name = null) { /** classes/client/html/catalog/detail/name * Class name of the used catalog detail client implementation * * Each default HTML client can be replace by an alternative imlementation. * To use this implementation, you have to set the last part of the class * name as configuration value so the client factory knows which class it * has to instantiate. * * For example, if the name of the default class is * * Client_Html_Catalog_Detail_Default * * and you want to replace it with your own version named * * Client_Html_Catalog_Detail_Mydetail * * then you have to set the this configuration option: * * classes/client/html/catalog/detail/name = Mydetail * * The value is the last part of your own class name and it's case sensitive, * so take care that the configuration value is exactly named like the last * part of the class name. * * The allowed characters of the class name are A-Z, a-z and 0-9. No other * characters are possible! You should always start the last part of the class * name with an upper case character and continue only with lower case characters * or numbers. Avoid chamel case names like "MyDetail"! * * @param string Last part of the class name * @since 2014.03 * @category Developer */ if ($name === null) { $name = $context->getConfig()->get('classes/client/html/catalog/detail/name', 'Default'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? 'Client_Html_Catalog_Detail_' . $name : '<not a string>'; throw new Client_Html_Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); } $iface = 'Client_Html_Interface'; $classname = 'Client_Html_Catalog_Detail_' . $name; $client = self::_createClient($context, $classname, $iface, $templatePaths); return self::_addClientDecorators($context, $client, $templatePaths, 'catalog/detail'); }
/** * Returns the cache object for the context * * @param \MShop_Context_Item_Interface $context Context object including config * @param string $siteid Unique site ID * @return \MW_Cache_Interface Cache object */ protected static function getCache(\MShop_Context_Item_Interface $context) { $config = $context->getConfig(); switch (Base::getExtConfig('cacheName', 'Typo3')) { case 'None': $config->set('client/html/basket/cache/enable', false); return \MW_Cache_Factory::createManager('None', array(), null); case 'Typo3': if (class_exists('\\TYPO3\\CMS\\Core\\Cache\\Cache')) { \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework(); } $manager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager'); return new \MAdmin_Cache_Proxy_Typo3($context, $manager->getCache('aimeos')); default: return new \MAdmin_Cache_Proxy_Default($context); } }
/** * Adds the user ID and name if available * * @param \MShop_Context_Item_Interface $context Context object */ protected function addUser(\MShop_Context_Item_Interface $context) { if (($userid = \Auth::id()) !== null) { $context->setUserId($userid); } if (($user = \Auth::user()) !== null) { $context->setEditor($user->name); } }
/** * Adds the decorators to the manager object. * * @param MShop_Context_Item_Interface $context Context instance with necessary objects * @param MShop_Common_Manager_Interface $manager Manager object * @param string $domain Domain name in lower case, e.g. "product" * @return MShop_Common_Manager_Interface Manager object */ protected static function _addManagerDecorators(MShop_Context_Item_Interface $context, MShop_Common_Manager_Interface $manager, $domain) { $config = $context->getConfig(); /** madmin/common/manager/decorators/default * Configures the list of decorators applied to all admin managers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to configure a list of decorator names that should * be wrapped around the original instances of all created managers: * * madmin/common/manager/decorators/default = array( 'decorator1', 'decorator2' ) * * This would wrap the decorators named "decorator1" and "decorator2" around * all controller instances in that order. The decorator classes would be * "MShop_Common_Manager_Decorator_Decorator1" and * "MShop_Common_Manager_Decorator_Decorator2". * * @param array List of decorator names * @since 2014.03 * @category Developer */ $decorators = $config->get('madmin/common/manager/decorators/default', array()); $excludes = $config->get('madmin/' . $domain . '/manager/decorators/excludes', array()); foreach ($decorators as $key => $name) { if (in_array($name, $excludes)) { unset($decorators[$key]); } } $classprefix = 'MShop_Common_Manager_Decorator_'; $manager = self::_addDecorators($context, $manager, $decorators, $classprefix); $classprefix = 'MShop_Common_Manager_Decorator_'; $decorators = $config->get('madmin/' . $domain . '/manager/decorators/global', array()); $manager = self::_addDecorators($context, $manager, $decorators, $classprefix); $classprefix = 'MShop_' . ucfirst($domain) . '_Manager_Decorator_'; $decorators = $config->get('madmin/' . $domain . '/manager/decorators/local', array()); $manager = self::_addDecorators($context, $manager, $decorators, $classprefix); return $manager; }
/** * Creates a new controller specified by the given name. * * @param MShop_Context_Item_Interface $context Context object required by controllers * @param Arcavias $arcavias Arcavias object * @param string|null $name Name of the controller or "Default" if null * @return Controller_Jobs_Interface New controller object */ public static function createController(MShop_Context_Item_Interface $context, Arcavias $arcavias, $name = null) { /** classes/controller/jobs/order/product/stock/name * Class name of the used order product stock scheduler controller implementation * * @param string Last part of the class name * @since 2014.03 * @category Developer * @deprecated Use classes/controller/jobs/order/cleanup/resource/name instead */ if ($name === null) { $name = $context->getConfig()->get('classes/controller/jobs/order/product/stock/name', 'Default'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? 'Controller_Jobs_Order_Product_Stock_' . $name : '<not a string>'; throw new Controller_Jobs_Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); } $iface = 'Controller_Jobs_Interface'; $classname = 'Controller_Jobs_Order_Product_Stock_' . $name; $controller = self::_createController($context, $arcavias, $classname, $iface); return self::_addControllerDecorators($context, $arcavias, $controller, 'order/product/stock'); }
/** * Adds the user ID and name if available * * @param \MShop_Context_Item_Interface $context Context object */ protected function addUser(\MShop_Context_Item_Interface $context) { $username = ''; if ($this->container->has('security.context')) { $token = $this->container->get('security.context')->getToken(); if (is_object($token)) { if (method_exists($token->getUser(), 'getId')) { $userid = $token->getUser()->getId(); $context->setUserId($userid); $context->setGroupIds(function () use($context, $userid) { $manager = \MShop_Factory::createManager($context, 'customer'); return $manager->getItem($userid, array('customer/group'))->getGroups(); }); } if (is_object($token->getUser())) { $username = $token->getUser()->getUsername(); } else { $username = $token->getUser(); } } } $context->setEditor($username); }
/** * Sends the notification e-mail for the given customer address and products * * @param MShop_Context_Item_Interface $context Context item object * @param MShop_Common_Item_Address_Interface $address Payment address of the customer * @param array $products List of products a notification should be sent for */ protected function _sendMail(MShop_Context_Item_Interface $context, MShop_Common_Item_Address_Interface $address, array $products) { $view = $context->getView(); $view->extProducts = $products; $view->extAddressItem = $address; $helper = new MW_View_Helper_Translate_Default($view, $context->getI18n($address->getLanguageId())); $view->addHelper('translate', $helper); $mailer = $context->getMail(); $message = $mailer->createMessage(); $helper = new MW_View_Helper_Mail_Default($view, $message); $view->addHelper('mail', $helper); $client = $this->_getClient($context); $client->setView($view); $client->getHeader(); $client->getBody(); $mailer->send($message); }
/** * Creates a new controller specified by the given name. * * @param MShop_Context_Item_Interface $context Context object required by controllers * @param Arcavias $arcavias Arcavias object * @param string|null $name Name of the controller or "Default" if null * @return Controller_Jobs_Interface New controller object */ public static function createController(MShop_Context_Item_Interface $context, Arcavias $arcavias, $name = null) { /** classes/controller/jobs/admin/job/name * Class name of the used admin jobs scheduler controller implementation * * Each default job controller can be replace by an alternative imlementation. * To use this implementation, you have to set the last part of the class * name as configuration value so the controller factory knows which class it * has to instantiate. * * For example, if the name of the default class is * * Controller_Jobs_Admin_Job_Default * * and you want to replace it with your own version named * * Controller_Jobs_Admin_Job_Myjob * * then you have to set the this configuration option: * * classes/controller/jobs/admin/job/name = Myjob * * The value is the last part of your own class name and it's case sensitive, * so take care that the configuration value is exactly named like the last * part of the class name. * * The allowed characters of the class name are A-Z, a-z and 0-9. No other * characters are possible! You should always start the last part of the class * name with an upper case character and continue only with lower case characters * or numbers. Avoid chamel case names like "MyJob"! * * @param string Last part of the class name * @since 2014.03 * @category Developer */ if ($name === null) { $name = $context->getConfig()->get('classes/controller/jobs/admin/job/name', 'Default'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? 'Controller_Jobs_Admin_Job_' . $name : '<not a string>'; throw new Controller_Jobs_Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); } $iface = 'Controller_Jobs_Interface'; $classname = 'Controller_Jobs_Admin_Job_' . $name; $controller = self::_createController($context, $arcavias, $classname, $iface); /** controller/jobs/admin/decorators/excludes * Excludes decorators added by the "common" option from the admin job controllers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to remove a decorator added via * "controller/jobs/common/decorators/default" before they are wrapped * around the job controller. * * controller/jobs/admin/decorators/excludes = array( 'decorator1' ) * * This would remove the decorator named "decorator1" from the list of * common decorators ("Controller_Jobs_Common_Decorator_*") added via * "controller/jobs/common/decorators/default" for the admin job controller. * * @param array List of decorator names * @since 2014.03 * @category Developer * @see controller/jobs/common/decorators/default * @see controller/jobs/admin/decorators/global * @see controller/jobs/admin/decorators/local */ /** controller/jobs/admin/decorators/global * Adds a list of globally available decorators only to the admin job controllers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to wrap global decorators * ("Controller_Jobs_Common_Decorator_*") around the job controller. * * controller/jobs/admin/decorators/global = array( 'decorator1' ) * * This would add the decorator named "decorator1" defined by * "Controller_Jobs_Common_Decorator_Decorator1" only to the job controller. * * @param array List of decorator names * @since 2014.03 * @category Developer * @see controller/jobs/common/decorators/default * @see controller/jobs/admin/decorators/excludes * @see controller/jobs/admin/decorators/local */ /** controller/jobs/admin/decorators/local * Adds a list of local decorators only to the admin job controllers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to wrap local decorators * ("Controller_Jobs_Admin_Decorator_*") around the job controller. * * controller/jobs/admin/decorators/local = array( 'decorator2' ) * * This would add the decorator named "decorator2" defined by * "Controller_Jobs_Admin_Decorator_Decorator2" only to the job * controller. * * @param array List of decorator names * @since 2014.03 * @category Developer * @see controller/jobs/common/decorators/default * @see controller/jobs/admin/decorators/excludes * @see controller/jobs/admin/decorators/global */ return self::_addControllerDecorators($context, $arcavias, $controller, 'admin/job'); }
/** * Adds the user ID and name if available * * @param \MShop_Context_Item_Interface $context Context object */ protected function addUser(\MShop_Context_Item_Interface $context) { if (($userid = \Auth::id()) !== null) { $context->setUserId($userid); $context->setGroupIds(function () use($context, $userid) { $manager = \MShop_Factory::createManager($context, 'customer'); return $manager->getItem($userid, array('customer/group'))->getGroups(); }); } if (($user = \Auth::user()) !== null) { $context->setEditor($user->name); } }
/** * Returns the cache object for the context * * @param \MShop_Context_Item_Interface $context Context object * @return \MW_Cache_Interface Cache object */ protected function getCache(\MShop_Context_Item_Interface $context) { switch ($context->getConfig()->get('flow/cache/name', 'Flow')) { case 'None': $config->set('client/html/basket/cache/enable', false); return \MW_Cache_Factory::createManager('None', array(), null); case 'Flow': return new \MAdmin_Cache_Proxy_Flow($context, $this->cache); default: return new \MAdmin_Cache_Proxy_Default($context); } }
/** * Returns the JSON encoded configuration for the ExtJS client. * * @param \MShop_Context_Item_Interface $context Context item object * @return string JSON encoded configuration object */ protected function getJsonClientConfig(\MShop_Context_Item_Interface $context) { $config = $context->getConfig()->get('client/extjs', array()); return json_encode(array('client' => array('extjs' => $config)), JSON_FORCE_OBJECT); }