本文整理汇总了PHP中MShop_Context_Item_Interface类的典型用法代码示例。如果您正苦于以下问题:PHP MShop_Context_Item_Interface类的具体用法?PHP MShop_Context_Item_Interface怎么用?PHP MShop_Context_Item_Interface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MShop_Context_Item_Interface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLocale
/**
* 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;
}
示例2: _addControllerDecorators
/**
* 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;
}
示例3: __construct
/**
* 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']));
}
}
示例4: createController
/**
* 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;
}
示例5: createController
/**
* 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');
}
示例6: createController
/**
* @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);
}
示例7: createController
/**
* @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);
}
示例8: createManager
/**
* 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');
}
示例9: _addControllerDecorators
/**
* 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;
}
示例10: createController
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');
}
示例11: createClient
/**
* 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');
}
示例12: getCache
/**
* 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);
}
}
示例13: addUser
/**
* 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);
}
}
示例14: _addManagerDecorators
/**
* 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;
}
示例15: createController
/**
* 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');
}