/** * Returns the locale object for frontend * * @param \Aimeos\MShop\Context\Item\Iface $context Context object * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface|null $request Request object * @return \Aimeos\MShop\Locale\Item\Iface Locale item object */ public static function get(\Aimeos\MShop\Context\Item\Iface $context, \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null) { if (!isset(self::$locale)) { $config = $context->getConfig(); $sitecode = $config->get('mshop/locale/site', 'default'); $name = $config->get('typo3/param/name/site', 'loc_site'); if ($request !== null && $request->hasArgument($name) === true) { $sitecode = $request->getArgument($name); } elseif (($value = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('S')) !== null) { $sitecode = $value; } $langid = $config->get('mshop/locale/language', ''); $name = $config->get('typo3/param/name/language', 'loc_language'); if ($request !== null && $request->hasArgument($name) === true) { $langid = $request->getArgument($name); } elseif (isset($GLOBALS['TSFE']->config['config']['language'])) { $langid = $GLOBALS['TSFE']->config['config']['language']; } $currency = $config->get('mshop/locale/currency', ''); $name = $config->get('typo3/param/name/currency', 'loc_currency'); if ($request !== null && $request->hasArgument($name) === true) { $currency = $request->getArgument($name); } elseif (($value = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('C')) !== null) { $currency = $value; } $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); self::$locale = $localeManager->bootstrap($sitecode, $langid, $currency); } return self::$locale; }
/** * Returns the locale object for the context * * @param \Aimeos\MShop\Context\Item\Iface $context Context object * @return \Aimeos\MShop\Locale\Item\Iface Locale item object */ protected function getLocale(\Aimeos\MShop\Context\Item\Iface $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 = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); self::$locale = $localeManager->bootstrap($sitecode, $langid, $currency); } return self::$locale; }
/** * Creates a new controller specified by the given name. * * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by controllers * @param string|null $name Name of the controller or "Standard" if null * @return \Aimeos\Controller\Common\Order\Iface New order controller object * @throws \Aimeos\Controller\Common\Exception */ public static function createController(\Aimeos\MShop\Context\Item\Iface $context, $name = null) { /** 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 * * \Aimeos\Controller\Common\Order\Standard * * and you want to replace it with your own version named * * \Aimeos\Controller\Common\Order\Myorder * * then you have to set the this configuration option: * * 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('controller/common/order/name', 'Standard'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Order\\' . $name : '<not a string>'; throw new \Aimeos\Controller\Common\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); } $iface = '\\Aimeos\\Controller\\Common\\Order\\Iface'; $classname = '\\Aimeos\\Controller\\Common\\Order\\' . $name; if (isset(self::$objects[$classname])) { return self::$objects[$classname]; } if (class_exists($classname) === false) { throw new \Aimeos\Controller\Common\Exception(sprintf('Class "%1$s" not available', $classname)); } $controller = new $classname($context); if (!$controller instanceof $iface) { throw new \Aimeos\Controller\Common\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $interface)); } return $controller; }
/** * @param string $name */ public static function createController(\Aimeos\MShop\Context\Item\Iface $context, $name = null, $domainToTest = 'plugin') { if ($name === null) { $name = $context->getConfig()->get('controller/extjs/plugin/name', 'Standard'); } if (ctype_alnum($name) === false) { throw new \Aimeos\Controller\ExtJS\Exception(sprintf('Invalid class name "%1$s"', $name)); } $iface = '\\Aimeos\\Controller\\ExtJS\\Common\\Iface'; $classname = '\\Aimeos\\Controller\\ExtJS\\Plugin\\' . $name; $manager = self::createControllerBase($context, $classname, $iface); return self::addControllerDecorators($context, $manager, $domainToTest); }
/** * @param string $name */ public static function createController(\Aimeos\MShop\Context\Item\Iface $context, $name = null, $domainToTest = 'service') { if ($name === null) { $name = $context->getConfig()->get('controller/frontend/service/name', 'Standard'); } if (ctype_alnum($name) === false) { throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in class name "%1$s"', $name)); } $iface = '\\Aimeos\\Controller\\Frontend\\Service\\Iface'; $classname = '\\Aimeos\\Controller\\Frontend\\Service\\' . $name; $manager = self::createControllerBase($context, $classname, $iface); return self::addControllerDecorators($context, $manager, $domainToTest); }
/** * Adds the decorators to the JSON API client object * * @param \Aimeos\Admin\JsonAdm\Common\Iface $client Client object * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects * @param \Aimeos\MW\View\Iface $view View object * @param array $templatePaths List of file system paths where the templates are stored * @param string $path Name of the client separated by slashes, e.g "product/stock" * @return \Aimeos\Admin\JsonAdm\Common\Iface Client object */ protected static function addClientDecorators(\Aimeos\Admin\JsonAdm\Iface $client, \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) { $config = $context->getConfig(); /** admin/jsonadm/common/decorators/default * Configures the list of decorators applied to all JSON API clients * * 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: * * admin/jsonadm/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 * "\Aimeos\Admin\JsonAdm\Common\Decorator\Decorator1" and * "\Aimeos\Admin\JsonAdm\Common\Decorator\Decorator2". * * @param array List of decorator names * @since 2015.12 * @category Developer */ $decorators = $config->get('admin/jsonadm/common/decorators/default', array()); $classprefix = '\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\'; $client = self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); if ($path !== null && is_string($path)) { $dpath = trim($path, '/'); $dpath = $dpath !== '' ? $dpath . '/' : $dpath; $excludes = $config->get('admin/jsonadm/' . $dpath . 'decorators/excludes', array()); $localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $path))); foreach ($decorators as $key => $name) { if (in_array($name, $excludes)) { unset($decorators[$key]); } } $classprefix = '\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\'; $decorators = $config->get('admin/jsonadm/' . $dpath . 'decorators/global', array()); $client = self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); if (!empty($path)) { $classprefix = '\\Aimeos\\Admin\\JsonAdm\\' . ucfirst($localClass) . '\\Decorator\\'; $decorators = $config->get('admin/jsonadm/' . $dpath . 'decorators/local', array()); $client = self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); } } return $client; }
/** * Creates the view object for the HTML client. * * @param \Aimeos\MShop\Context\Item\Iface $context Context object * @param array $templatePaths List of base path names with relative template paths as key/value pairs * @param string|null $locale Code of the current language or null for no translation * @return \Aimeos\MW\View\Iface View object */ public function create(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $locale = null) { $config = $context->getConfig(); $view = new \Aimeos\MW\View\Standard($templatePaths); $this->addCsrf($view); $this->addAccess($view, $context); $this->addConfig($view, $config); $this->addNumber($view, $config); $this->addParam($view); $this->addRequest($view); $this->addResponse($view); $this->addTranslate($view, $locale); $this->addUrl($view); return $view; }
/** * Creates the view object for the HTML client. * * @param \Aimeos\MShop\Context\Item\Iface $context Context object * @param \TYPO3\Flow\Mvc\Routing\UriBuilder $uriBuilder URL builder object * @param array $templatePaths List of base path names with relative template paths as key/value pairs * @param \TYPO3\Flow\Mvc\RequestInterface|null $request Request object * @param string|null $langid Language ID * @return \Aimeos\MW\View\Iface View object */ public function create(\Aimeos\MShop\Context\Item\Iface $context, \TYPO3\Flow\Mvc\Routing\UriBuilder $uriBuilder, array $templatePaths, \TYPO3\Flow\Mvc\RequestInterface $request = null, $langid = null) { $config = $context->getConfig(); $view = new \Aimeos\MW\View\Standard($templatePaths); $this->addCsrf($view); $this->addAccess($view, $context); $this->addConfig($view, $config); $this->addNumber($view, $config); $this->addParam($view, $request); $this->addRequest($view, $request); $this->addResponse($view); $this->addTranslate($view, $langid); $this->addUrl($view, $uriBuilder, $request); return $view; }
/** * Adds the user ID and name if available * * @param \Aimeos\MShop\Context\Item\Iface $context Context object */ protected function addUser(\Aimeos\MShop\Context\Item\Iface $context) { $token = null; $username = ''; if ($this->container->has('security.token_storage')) { $token = $this->container->get('security.token_storage')->getToken(); } else { 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 = \Aimeos\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); }
/** * Creates a stock client object. * * @param \Aimeos\MShop\Context\Item\Iface $context Shop context instance with necessary objects * @param array $templatePaths Stock of file system paths where the templates are stored * @param string|null $name Client name (default: "Default") * @return \Aimeos\Client\Html\Iface Filter part implementing \Aimeos\Client\Html\Iface * @throws \Aimeos\Client\Html\Exception If requested client implementation couldn't be found or initialisation fails */ public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null) { /** client/html/catalog/stock/name * Class name of the used catalog stock 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 * * \Aimeos\Client\Html\Catalog\Stock\Standard * * and you want to replace it with your own version named * * \Aimeos\Client\Html\Catalog\Stock\Mystock * * then you have to set the this configuration option: * * client/html/catalog/stock/name = Mystock * * 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 "MyStock"! * * @param string Last part of the class name * @since 2014.03 * @category Developer */ if ($name === null) { $name = $context->getConfig()->get('client/html/catalog/stock/name', 'Standard'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? '\\Aimeos\\Client\\Html\\Catalog\\Stock\\' . $name : '<not a string>'; throw new \Aimeos\Client\Html\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); } $iface = '\\Aimeos\\Client\\Html\\Iface'; $classname = '\\Aimeos\\Client\\Html\\Catalog\\Stock\\' . $name; $client = self::createClientBase($context, $classname, $iface, $templatePaths); return self::addClientDecorators($context, $client, $templatePaths, 'catalog/stock'); }
/** * Adds the decorators to the controller object. * * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects * @param \Aimeos\Controller\Frontend\Common\Iface $controller Controller object * @param string $domain Domain name in lower case, e.g. "product" * @return \Aimeos\Controller\Frontend\Common\Iface Controller object */ protected static function addControllerDecorators(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Controller\Frontend\Iface $controller, $domain) { if (!is_string($domain) || $domain === '') { throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid domain "%1$s"', $domain)); } $localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $domain))); $config = $context->getConfig(); /** controller/frontend/common/decorators/default * Configures the list of decorators applied to all frontend 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 controllers: * * controller/frontend/common/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 * "\Aimeos\Controller\Frontend\Common\Decorator\Decorator1" and * "\Aimeos\Controller\Frontend\Common\Decorator\Decorator2". * * @param array List of decorator names * @since 2014.03 * @category Developer */ $decorators = $config->get('controller/frontend/common/decorators/default', array()); $excludes = $config->get('controller/frontend/' . $domain . '/decorators/excludes', array()); foreach ($decorators as $key => $name) { if (in_array($name, $excludes)) { unset($decorators[$key]); } } $classprefix = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\'; $controller = self::addDecorators($context, $controller, $decorators, $classprefix); $classprefix = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\'; $decorators = $config->get('controller/frontend/' . $domain . '/decorators/global', array()); $controller = self::addDecorators($context, $controller, $decorators, $classprefix); $classprefix = '\\Aimeos\\Controller\\Frontend\\' . ucfirst($localClass) . '\\Decorator\\'; $decorators = $config->get('controller/frontend/' . $domain . '/decorators/local', array()); $controller = self::addDecorators($context, $controller, $decorators, $classprefix); return $controller; }
public static function createController(\Aimeos\MShop\Context\Item\Iface $context, $name = null) { /** controller/extjs/product/export/text/name * Class name of the used ExtJS product export text 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 * * \Aimeos\Controller\ExtJS\Product\Export\Text\Standard * * and you want to replace it with your own version named * * \Aimeos\Controller\ExtJS\Product\Export\Text\Mytext * * then you have to set the this configuration option: * * controller/extjs/product/export/text/name = Mytext * * 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 "MyText"! * * @param string Last part of the class name * @since 2014.03 * @category Developer */ if ($name === null) { $name = $context->getConfig()->get('controller/extjs/product/export/text/name', 'Standard'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? '\\Aimeos\\Controller\\ExtJS\\Product\\Export\\Text\\' . $name : '<not a string>'; throw new \Aimeos\Controller\ExtJS\Exception(sprintf('Invalid class name "%1$s"', $classname)); } $iface = '\\Aimeos\\Controller\\ExtJS\\Common\\Load\\Text\\Iface'; $classname = '\\Aimeos\\Controller\\ExtJS\\Product\\Export\\Text\\' . $name; return self::createControllerBase($context, $classname, $iface); }
/** * Returns the cache object for the context * * @param \Aimeos\MShop\Context\Item\Iface $context Context object including config * @param string $siteid Unique site ID * @return \Aimeos\MW\Cache\Iface Cache object */ protected static function getCache(\Aimeos\MShop\Context\Item\Iface $context) { $config = $context->getConfig(); switch (Base::getExtConfig('cacheName', 'Typo3')) { case 'None': $config->set('client/html/basket/cache/enable', false); return \Aimeos\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 \Aimeos\MAdmin\Cache\Proxy\Typo3($context, $manager->getCache('aimeos')); default: return new \Aimeos\MAdmin\Cache\Proxy\Standard($context); } }
/** * Creates a new client object. * * @param \Aimeos\MShop\Context\Item\Iface $context Shop context instance with necessary objects * @param array List of file system paths where the templates are stored * @param string $type Type of the client, e.g 'product' for \Aimeos\Admin\JQAdm\Product\Standard * @param string|null $name Admin name (default: "Standard") * @return \Aimeos\Admin\JQAdm\Iface admin client implementing \Aimeos\Admin\JQAdm\Iface * @throws \Aimeos\Admin\JQAdm\Exception If requested client implementation couldn't be found or initialisation fails */ public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $type, $name = null) { if (empty($type)) { throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Admin JQAdm type is empty')); } if (ctype_alnum($type) === false) { throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Invalid characters in client name "%1$s"', $type)); } $factory = '\\Aimeos\\Admin\\JQAdm\\' . ucwords($type) . '\\Factory'; if (class_exists($factory) === false) { throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Class "%1$s" not available', $factory)); } $client = @call_user_func_array(array($factory, 'createClient'), array($context, $templatePaths, $name)); if ($client === false) { throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Invalid factory "%1$s"', $factory)); } $client->setView($context->getView()); return $client; }
/** * Adds the decorators to the manager object. * * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects * @param \Aimeos\MShop\Common\Manager\Iface $manager Manager object * @param string $domain Domain name in lower case, e.g. "product" * @return \Aimeos\MShop\Common\Manager\Iface Manager object */ protected static function addManagerDecorators(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Common\Manager\Iface $manager, $domain) { $config = $context->getConfig(); /** mshop/common/manager/decorators/default * Configures the list of decorators applied to all shop 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: * * mshop/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 * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" and * "\Aimeos\MShop\Common\Manager\Decorator\Decorator2". * * @param array List of decorator names * @since 2014.03 * @category Developer */ $decorators = $config->get('mshop/common/manager/decorators/default', array()); $excludes = $config->get('mshop/' . $domain . '/manager/decorators/excludes', array()); foreach ($decorators as $key => $name) { if (in_array($name, $excludes)) { unset($decorators[$key]); } } $classprefix = '\\Aimeos\\MShop\\Common\\Manager\\Decorator\\'; $manager = self::addDecorators($context, $manager, $decorators, $classprefix); $classprefix = '\\Aimeos\\MShop\\Common\\Manager\\Decorator\\'; $decorators = $config->get('mshop/' . $domain . '/manager/decorators/global', array()); $manager = self::addDecorators($context, $manager, $decorators, $classprefix); $classprefix = '\\Aimeos\\MShop\\' . ucfirst($domain) . '\\Manager\\Decorator\\'; $decorators = $config->get('mshop/' . $domain . '/manager/decorators/local', array()); $manager = self::addDecorators($context, $manager, $decorators, $classprefix); return $manager; }
/** * Creates the required manager specified by the given path of manager names. * * Domain managers are created by providing only the domain name, e.g. * "product" for the \Aimeos\MShop\Product\Manager\Standard or a path of names to * retrieve a specific sub-manager, e.g. "product/type" for the * \Aimeos\MShop\Product\Manager\Type\Standard manager. * Please note, that only the default managers can be created. If you need * a specific implementation, you need to use the factory class of the * domain or the getSubManager() method to hand over specifc implementation * names. * * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by managers * @param string $path Name of the domain (and sub-managers) separated by slashes, e.g "product/list" * @return \Aimeos\MShop\Common\Manager\Iface Manager object * @throws \Aimeos\MShop\Exception If the given path is invalid or the manager wasn't found */ public static function createManager(\Aimeos\MShop\Context\Item\Iface $context, $path) { if (empty($path)) { throw new \Aimeos\MShop\Exception(sprintf('Manager path is empty')); } $id = (string) $context; if (self::$cache === false || !isset(self::$managers[$id][$path])) { $subpath = ''; $parts = explode('/', $path); foreach ($parts as $part) { if (ctype_alnum($part) === false) { throw new \Aimeos\MShop\Exception(sprintf('Invalid characters in manager name "%1$s" in "%2$s"', $part, $path)); } } if (($domain = array_shift($parts)) === null) { throw new \Aimeos\MShop\Exception(sprintf('Manager path "%1$s" is invalid', $path)); } if (self::$cache === false || !isset(self::$managers[$id][$domain])) { $factory = '\\Aimeos\\MShop\\' . ucwords($domain) . '\\Manager\\Factory'; if (class_exists($factory) === false) { throw new \Aimeos\MShop\Exception(sprintf('Class "%1$s" not available', $factory)); } $manager = @call_user_func_array(array($factory, 'createManager'), array($context)); if ($manager === false) { throw new \Aimeos\MShop\Exception(sprintf('Invalid factory "%1$s"', $factory)); } self::$managers[$id][$domain] = $manager; } foreach ($parts as $part) { $subpath .= $part . '/'; $tmpname = $domain . '/' . $part; $classname = $context->getConfig()->get('mshop/' . $domain . '/manager/' . $subpath . 'name'); if (self::$cache === false || !isset(self::$managers[$id][$tmpname])) { self::$managers[$id][$tmpname] = self::$managers[$id][$domain]->getSubManager($part, $classname); } $domain = $tmpname; } } return self::$managers[$id][$path]; }
/** * Adds the user ID and name if available * * @param \Aimeos\MShop\Context\Item\Iface $context Context object */ protected function addUser(\Aimeos\MShop\Context\Item\Iface $context) { if (($userid = \Auth::id()) !== null) { $context->setUserId($userid); $context->setGroupIds(function () use($context, $userid) { $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); return $manager->getItem($userid, array('customer/group'))->getGroups(); }); } if (($user = \Auth::user()) !== null) { $context->setEditor($user->name); } }
/** * Adds the user ID and name if available * * @param \Aimeos\MShop\Context\Item\Iface $context Context object */ protected function addUser(\Aimeos\MShop\Context\Item\Iface $context) { $context->setEditor(''); }
/** * Creates the top level client * * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by clients * @param \Aimeos\MW\View\Iface $view View object * @param array $templatePaths List of file system paths where the templates are stored * @param string $path Name of the client separated by slashes, e.g "product/stock" * @param string|null $name Name of the JsonAdm client (default: "Standard") * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created */ protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null) { /** admin/jsonadm/name * Class name of the used JSON API client implementation * * Each default JSON API 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 * * \Aimeos\Admin\JsonAdm\Standard * * and you want to replace it with your own version named * * \Aimeos\Admin\JsonAdm\Mycntl * * then you have to set the this configuration option: * * admin/jsonadm/name = Mycntl * * 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 "MyCntl"! * * @param string Last part of the class name * @since 2015.12 * @category Developer */ if ($name === null) { $name = $context->getConfig()->get('admin/jsonadm/name', 'Standard'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname)); } $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name; $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); /** admin/jsonadm/decorators/excludes * Excludes decorators added by the "common" option from the JSON API clients * * 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 * "admin/jsonadm/common/decorators/default" before they are wrapped * around the Jsonadm client. * * admin/jsonadm/decorators/excludes = array( 'decorator1' ) * * This would remove the decorator named "decorator1" from the list of * common decorators ("\Aimeos\Admin\JsonAdm\Common\Decorator\*") added via * "admin/jsonadm/common/decorators/default" for the JSON API client. * * @param array List of decorator names * @since 2016.01 * @category Developer * @see admin/jsonadm/common/decorators/default * @see admin/jsonadm/decorators/global * @see admin/jsonadm/decorators/local */ /** admin/jsonadm/decorators/global * Adds a list of globally available decorators only to the Jsonadm client * * 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 * ("\Aimeos\Admin\Jsonadm\Common\Decorator\*") around the Jsonadm * client. * * admin/jsonadm/product/decorators/global = array( 'decorator1' ) * * This would add the decorator named "decorator1" defined by * "\Aimeos\Admin\Jsonadm\Common\Decorator\Decorator1" only to the * "product" Jsonadm client. * * @param array List of decorator names * @since 2016.01 * @category Developer * @see admin/jsonadm/common/decorators/default * @see admin/jsonadm/decorators/excludes * @see admin/jsonadm/decorators/local */ /** admin/jsonadm/decorators/local * Adds a list of local decorators only to the Jsonadm client * * 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 * ("\Aimeos\Admin\Jsonadm\Product\Decorator\*") around the Jsonadm * client. * * admin/jsonadm/product/decorators/local = array( 'decorator2' ) * * This would add the decorator named "decorator2" defined by * "\Aimeos\Admin\Jsonadm\Product\Decorator\Decorator2" only to the * "product" Jsonadm client. * * @param array List of decorator names * @since 2016.01 * @category Developer * @see admin/jsonadm/common/decorators/default * @see admin/jsonadm/decorators/excludes * @see admin/jsonadm/decorators/global */ return self::addClientDecorators($client, $context, $view, $templatePaths, $path); }
/** * Adds the session object to the context * * @param \Aimeos\MShop\Context\Item\Iface $context Context object * @return \Aimeos\MShop\Context\Item\Iface Modified context object */ protected function addSession(\Aimeos\MShop\Context\Item\Iface $context) { $session = new \Aimeos\MW\Session\PHP(); $context->setSession($session); return $context; }
/** * Sends the notification e-mail for the given customer address and products * * @param \Aimeos\MShop\Context\Item\Iface $context Context item object * @param \Aimeos\MShop\Common\Item\Address\Iface $address Payment address of the customer * @param array $products List of products a notification should be sent for */ protected function sendMail(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Common\Item\Address\Iface $address, array $products) { $view = $context->getView(); $view->extProducts = $products; $view->extAddressItem = $address; $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $context->getI18n($address->getLanguageId())); $view->addHelper('translate', $helper); $mailer = $context->getMail(); $message = $mailer->createMessage(); $helper = new \Aimeos\MW\View\Helper\Mail\Standard($view, $message); $view->addHelper('mail', $helper); $client = $this->getClient($context); $client->setView($view); $client->getHeader(); $client->getBody(); $mailer->send($message); }
/** * Returns the JSON encoded configuration for the ExtJS client. * * @param \Aimeos\MShop\Context\Item\Iface $context Context item object * @return string JSON encoded configuration object */ protected function getJsonClientConfig(\Aimeos\MShop\Context\Item\Iface $context) { $config = $context->getConfig()->get('admin/extjs', array()); return json_encode(array('admin' => array('extjs' => $config)), JSON_FORCE_OBJECT); }
public static function createController(\Aimeos\MShop\Context\Item\Iface $context, $name = null) { /** controller/extjs/customer/group/name * Class name of the used ExtJS customer group 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 * * \Aimeos\Controller\ExtJS\Customer\Group\Standard * * and you want to replace it with your own version named * * \Aimeos\Controller\ExtJS\Customer\Group\Mylist * * then you have to set the this configuration option: * * controller/extjs/customer/group/name = Mylist * * 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 "MyGroup"! * * @param string Last part of the class name * @since 2014.03 * @category Developer */ if ($name === null) { $name = $context->getConfig()->get('controller/extjs/customer/group/name', 'Standard'); } if (ctype_alnum($name) === false) { $classname = is_string($name) ? '\\Aimeos\\Controller\\ExtJS\\Customer\\Group\\' . $name : '<not a string>'; throw new \Aimeos\Controller\ExtJS\Exception(sprintf('Invalid class name "%1$s"', $classname)); } $iface = '\\Aimeos\\Controller\\ExtJS\\Common\\Iface'; $classname = '\\Aimeos\\Controller\\ExtJS\\Customer\\Group\\' . $name; $controller = self::createControllerBase($context, $classname, $iface); /** controller/extjs/customer/group/decorators/excludes * Excludes decorators added by the "common" option from the customer group 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 remove a decorator added via * "controller/extjs/common/decorators/default" before they are wrapped * around the ExtJS controller. * * controller/extjs/customer/group/decorators/excludes = array( 'decorator1' ) * * This would remove the decorator named "decorator1" from the list of * common decorators ("\Aimeos\Controller\ExtJS\Common\Decorator\*") added via * "controller/extjs/common/decorators/default" for the admin ExtJS controller. * * @param array List of decorator names * @since 2015.09 * @category Developer * @see controller/extjs/common/decorators/default * @see controller/extjs/customer/group/decorators/global * @see controller/extjs/customer/group/decorators/local */ /** controller/extjs/customer/group/decorators/global * Adds a list of globally available decorators only to the customer group 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 wrap global decorators * ("\Aimeos\Controller\ExtJS\Common\Decorator\*") around the ExtJS controller. * * controller/extjs/customer/group/decorators/global = array( 'decorator1' ) * * This would add the decorator named "decorator1" defined by * "\Aimeos\Controller\ExtJS\Common\Decorator\Decorator1" only to the ExtJS controller. * * @param array List of decorator names * @since 2015.09 * @category Developer * @see controller/extjs/common/decorators/default * @see controller/extjs/customer/group/decorators/excludes * @see controller/extjs/customer/group/decorators/local */ /** controller/extjs/customer/group/decorators/local * Adds a list of local decorators only to the customer group 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 wrap local decorators * ("\Aimeos\Controller\ExtJS\Customer\Group\Decorator\*") around the ExtJS controller. * * controller/extjs/customer/group/decorators/local = array( 'decorator2' ) * * This would add the decorator named "decorator2" defined by * "\Aimeos\Controller\ExtJS\Customer\Group\Decorator\Decorator2" only to the ExtJS * controller. * * @param array List of decorator names * @since 2015.09 * @category Developer * @see controller/extjs/common/decorators/default * @see controller/extjs/customer/group/decorators/excludes * @see controller/extjs/customer/group/decorators/global */ return self::addControllerDecorators($context, $controller, 'customer/group'); }
/** * Sends the account creation e-mail to the e-mail address of the customer * * @param \Aimeos\MShop\Context\Item\Iface $context Context item object * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object * @param string $password Customer clear text password */ protected function sendEmail(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $item, $password) { $address = $item->getPaymentAddress(); $view = $context->getView(); $view->extAddressItem = $address; $view->extAccountCode = $item->getCode(); $view->extAccountPassword = $password; $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $context->getI18n($address->getLanguageId())); $view->addHelper('translate', $helper); $mailer = $context->getMail(); $message = $mailer->createMessage(); $helper = new \Aimeos\MW\View\Helper\Mail\Standard($view, $message); $view->addHelper('mail', $helper); $client = $this->getClient($context); $client->setView($view); $client->getHeader(); $client->getBody(); $mailer->send($message); }