本文整理汇总了PHP中Aimeos\Controller\Frontend\Factory::createController方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::createController方法的具体用法?PHP Factory::createController怎么用?PHP Factory::createController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aimeos\Controller\Frontend\Factory
的用法示例。
在下文中一共展示了Factory::createController方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCatalogController
/**
* Returns the catalog controller object
*
* @return \Aimeos\Controller\Frontend\Catalog\Interface Catalog controller
*/
protected function getCatalogController()
{
if (!isset($this->controller)) {
$context = $this->getContext();
$this->controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
}
return $this->controller;
}
示例2: testClearSpecific
public function testClearSpecific()
{
$cache = \Aimeos\Controller\Frontend\Factory::setCache(true);
$context = \TestHelperFrontend::getContext();
$basket1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
$catalog1 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
\Aimeos\Controller\Frontend\Factory::clear((string) $context, 'basket');
$basket2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
$catalog2 = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
\Aimeos\Controller\Frontend\Factory::setCache($cache);
$this->assertNotSame($basket1, $basket2);
$this->assertSame($catalog1, $catalog2);
}
示例3: setViewParams
/**
* Sets the necessary parameter values in the view.
*
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
* @return \Aimeos\MW\View\Iface Modified view object
*/
protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null)
{
if (!isset($this->cache)) {
$catItems = array();
$context = $this->getContext();
$controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
$currentid = (string) $view->param('f_catid', '');
$currentid = $currentid != '' ? $currentid : null;
/** client/html/catalog/filter/tree/startid
* The ID of the category node that should be the root of the displayed category tree
*
* If you want to display only a part of your category tree, you can
* configure the ID of the category node from which rendering the
* remaining sub-tree should start.
*
* In most cases you can set this value via the administration interface
* of the shop application. In that case you often can configure the
* start ID individually for each catalog filter.
*
* @param string Category ID
* @since 2014.03
* @category User
* @category Developer
* @see client/html/catalog/filter/tree/levels-always
* @see client/html/catalog/filter/tree/levels-only
* @see client/html/catalog/filter/tree/domains
*/
$startid = $view->config('client/html/catalog/filter/tree/startid', '');
$startid = $startid != '' ? $startid : null;
/** client/html/catalog/filter/tree/domains
* List of domain names whose items should be fetched with the filter categories
*
* The templates rendering the categories in the catalog filter usually
* add the images and texts associated to each item. If you want to
* display additional content, you can configure your own list of
* domains (attribute, media, price, product, text, etc. are domains)
* whose items are fetched from the storage. Please keep in mind that
* the more domains you add to the configuration, the more time is
* required for fetching the content!
*
* @param array List of domain item names
* @since 2014.03
* @category Developer
* @see client/html/catalog/filter/tree/startid
* @see client/html/catalog/filter/tree/levels-always
* @see client/html/catalog/filter/tree/levels-only
*/
$ref = $view->config('client/html/catalog/filter/tree/domains', array('text', 'media'));
if ($currentid) {
$catItems = $controller->getCatalogPath($currentid);
if ($startid) {
foreach ($catItems as $key => $item) {
if ($key == $startid) {
break;
}
unset($catItems[$key]);
}
}
}
if (($node = reset($catItems)) === false) {
$node = $controller->getCatalogTree($startid, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE);
$catItems = array($node->getId() => $node);
}
$search = $controller->createCatalogFilter();
$expr = $search->compare('==', 'catalog.parentid', array_keys($catItems));
$expr = $search->combine('||', array($expr, $search->compare('==', 'catalog.id', $node->getId())));
/** client/html/catalog/filter/tree/levels-always
* The number of levels in the category tree that should be always displayed
*
* Usually, only the root node and the first level of the category
* tree is shown in the frontend. Only if the user clicks on a
* node in the first level, the page reloads and the sub-nodes of
* the chosen category are rendered as well.
*
* Using this configuration option you can enforce the given number
* of levels to be always displayed. The root node uses level 0, the
* categories below level 1 and so on.
*
* In most cases you can set this value via the administration interface
* of the shop application. In that case you often can configure the
* levels individually for each catalog filter.
*
* @param integer Number of tree levels
* @since 2014.03
* @category User
* @category Developer
* @see client/html/catalog/filter/tree/startid
* @see client/html/catalog/filter/tree/levels-only
* @see client/html/catalog/filter/tree/domains
*/
if (($levels = $view->config('client/html/catalog/filter/tree/levels-always')) != null) {
$expr = $search->combine('||', array($expr, $search->compare('<=', 'catalog.level', $levels)));
}
/** client/html/catalog/filter/tree/levels-only
//.........这里部分代码省略.........
示例4: setViewParams
/**
* Sets the necessary parameter values in the view.
*
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
* @param array &$tags Result array for the list of tags that are associated to the output
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
* @return \Aimeos\MW\View\Iface Modified view object
*/
protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null)
{
if (!isset($this->cache)) {
$context = $this->getContext();
$config = $context->getConfig();
$attrIds = $attributeMap = $subAttrDeps = array();
if (isset($view->detailProductItem)) {
$attrIds = array_keys($view->detailProductItem->getRefItems('attribute', null, 'default'));
$attrIds += array_keys($view->detailProductItem->getRefItems('attribute', null, 'variant'));
}
$products = $view->detailProductItem->getRefItems('product', 'default', 'default');
/** client/html/catalog/detail/additional/attribute/domains
* A list of domain names whose items should be available in the additional attribute part of the catalog detail view templates
*
* The templates rendering additional attribute related data usually add
* the images and texts associated to each item. If you want to
* display additional content like the attributes, you can configure
* your own list of domains (attribute, media, price, product, text,
* etc. are domains) whose items are fetched from the storage.
* Please keep in mind that the more domains you add to the
* configuration, the more time is required for fetching the content!
*
* @param array List of domain names
* @since 2015.09
* @category Developer
* @see client/html/catalog/detail/basket/selection/domains-attributes
*/
$domains = $config->get('client/html/catalog/detail/basket/selection/domains', array('attribute'));
// find regular attributes from sub-products
$controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
$products = $controller->getProductItems(array_keys($products), $domains);
foreach ($products as $subProdId => $subProduct) {
$subItems = $subProduct->getRefItems('attribute', null, 'default');
$subItems += $subProduct->getRefItems('attribute', null, 'variant');
foreach ($subItems as $attrId => $attrItem) {
$subAttrDeps[$attrId][] = $subProdId;
$attrIds[] = $attrId;
}
}
$this->addMetaItem($products, 'product', $this->expire, $this->tags);
$this->addMetaList(array_keys($products), 'product', $this->expire);
$attrManager = $controller->createManager('attribute');
$search = $attrManager->createSearch(true);
$expr = array($search->compare('==', 'attribute.id', $attrIds), $search->getConditions());
$search->setConditions($search->combine('&&', $expr));
/** client/html/catalog/detail/basket/selection/domains-attributes
* A list of domain names whose items should be available for the attributes in the
* additional attribute part of the catalog detail view templates
*
* The templates rendering additional attribute related data usually add
* the images and texts associated to each item. If you want to
* display additional content like the attributes, you can configure
* your own list of domains (attribute, media, price, product, text,
* etc. are domains) whose items are fetched from the storage.
* Please keep in mind that the more domains you add to the
* configuration, the more time is required for fetching the content!
*
* @param array List of domain names
* @since 2015.09
* @category Developer
* @see client/html/catalog/detail/basket/selection/domains
*/
$domains = $config->get('client/html/catalog/detail/basket/selection/domains-attributes', array('text', 'media'));
$attributes = $attrManager->searchItems($search, $domains);
foreach ($attributes as $id => $item) {
$attributeMap[$item->getType()][$id] = $item;
}
$this->addMetaItem($attributes, 'attribute', $this->expire, $this->tags);
$this->addMetaList(array_keys($attributes), 'attribute', $this->expire);
$view->attributeMap = $attributeMap;
$view->subAttributeDependencies = $subAttrDeps;
$this->cache = $view;
}
$expire = $this->expires($this->expire, $expire);
$tags = array_merge($tags, $this->tags);
return $this->cache;
}
示例5: process
/**
* Processes the input, e.g. store given values.
* A view must be available and this method doesn't generate any output
* besides setting view variables.
*/
public function process()
{
$view = $this->getView();
$context = $this->getContext();
switch ($view->param('b_action')) {
case 'coupon-delete':
if (($coupon = $view->param('b_coupon')) != '') {
$this->clearCached();
$cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
$cntl->deleteCoupon($coupon);
}
break;
default:
if (($coupon = $view->param('b_coupon')) != '') {
$this->clearCached();
$cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
/** client/html/basket/standard/coupon/allowed
* Number of coupon codes a customer is allowed to enter
*
* This configuration option enables shop owners to limit the number of coupon
* codes that can be added by a customer to his current basket. By default, only
* one coupon code is allowed per order.
*
* Coupon codes are valid until a payed order is placed by the customer. The
* "count" of the codes is decreased afterwards. If codes are not personalized
* the codes can be reused in the next order until their "count" reaches zero.
*
* @param integer Positive number of coupon codes including zero
* @since 2014.05
* @category User
* @category Developer
*/
$allowed = $context->getConfig()->get('client/html/basket/standard/coupon/allowed', 1);
if ($allowed <= count($cntl->get()->getCoupons())) {
throw new \Aimeos\Client\Html\Exception(sprintf('Number of coupon codes exceeds the limit'));
}
$cntl->addCoupon($coupon);
}
break;
}
parent::process();
}
示例6: setViewParams
/**
* Sets the necessary parameter values in the view.
*
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
* @param array &$tags Result array for the list of tags that are associated to the output
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
* @return \Aimeos\MW\View\Iface Modified view object
*/
protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null)
{
if (!isset($this->cache)) {
$context = $this->getContext();
$basketCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
$view->standardBasket = $basketCntl->get();
$bTarget = $view->config('client/html/basket/standard/url/target');
$bCntl = $view->config('client/html/basket/standard/url/controller', 'basket');
$bAction = $view->config('client/html/basket/standard/url/action', 'index');
$bConfig = $view->config('client/html/basket/standard/url/config', array());
/** client/html/checkout/standard/url/target
* Destination of the URL where the controller specified in the URL is known
*
* The destination can be a page ID like in a content management system or the
* module of a software development framework. This "target" must contain or know
* the controller that should be called by the generated URL.
*
* @param string Destination of the URL
* @since 2014.03
* @category Developer
* @see client/html/checkout/standard/url/controller
* @see client/html/checkout/standard/url/action
* @see client/html/checkout/standard/url/config
*/
$cTarget = $view->config('client/html/checkout/standard/url/target');
/** client/html/checkout/standard/url/controller
* Name of the controller whose action should be called
*
* In Model-View-Controller (MVC) applications, the controller contains the methods
* that create parts of the output displayed in the generated HTML page. Controller
* names are usually alpha-numeric.
*
* @param string Name of the controller
* @since 2014.03
* @category Developer
* @see client/html/checkout/standard/url/target
* @see client/html/checkout/standard/url/action
* @see client/html/checkout/standard/url/config
*/
$cCntl = $view->config('client/html/checkout/standard/url/controller', 'checkout');
/** client/html/checkout/standard/url/action
* Name of the action that should create the output
*
* In Model-View-Controller (MVC) applications, actions are the methods of a
* controller that create parts of the output displayed in the generated HTML page.
* Action names are usually alpha-numeric.
*
* @param string Name of the action
* @since 2014.03
* @category Developer
* @see client/html/checkout/standard/url/target
* @see client/html/checkout/standard/url/controller
* @see client/html/checkout/standard/url/config
*/
$cAction = $view->config('client/html/checkout/standard/url/action', 'index');
/** client/html/checkout/standard/url/config
* Associative list of configuration options used for generating the URL
*
* You can specify additional options as key/value pairs used when generating
* the URLs, like
*
* client/html/<clientname>/url/config = array( 'absoluteUri' => true )
*
* The available key/value pairs depend on the application that embeds the e-commerce
* framework. This is because the infrastructure of the application is used for
* generating the URLs. The full list of available config options is referenced
* in the "see also" section of this page.
*
* @param string Associative list of configuration options
* @since 2014.03
* @category Developer
* @see client/html/checkout/standard/url/target
* @see client/html/checkout/standard/url/controller
* @see client/html/checkout/standard/url/action
* @see client/html/url/config
*/
$cConfig = $view->config('client/html/checkout/standard/url/config', array());
/** client/html/checkout/standard/url/step-active
* Name of the checkout process step to jump to if no previous step requires attention
*
* The checkout process consists of several steps which are usually
* displayed one by another to the customer. If the data of a step
* is already available, then that step is skipped. The active step
* is the one that is displayed if all other steps are skipped.
*
* If one of the previous steps misses some data the customer has
* to enter, then this step is displayed first. After providing
* the missing data, the whole series of steps are tested again
* and if no other step requests attention, the configured active
* step will be displayed.
*
* The order of the steps is determined by the order of sub-parts
//.........这里部分代码省略.........
示例7: process
/**
* Processes the input, e.g. store given order.
* A view must be available and this method doesn't generate any output
* besides setting view variables.
*/
public function process()
{
$view = $this->getView();
$errors = $view->get('standardErrorList', array());
if (!in_array($view->param('c_step'), array('order', 'process')) || !empty($errors)) {
return;
}
$context = $this->getContext();
$session = $context->getSession();
$orderid = $session->get('aimeos/orderid');
$config = array('absoluteUri' => true, 'namespace' => false);
try {
$orderItem = \Aimeos\MShop\Factory::createManager($context, 'order')->getItem($orderid);
if (($code = $this->getOrderServiceCode($orderItem->getBaseId())) !== null) {
$serviceItem = $this->getServiceItem($code);
$serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service');
$provider = $serviceManager->getProvider($serviceItem);
$args = array('code' => $serviceItem->getCode(), 'orderid' => $orderid);
$urls = array('payment.url-self' => $this->getUrlSelf($view, $args + array('c_step' => 'process'), array()), 'payment.url-success' => $this->getUrlConfirm($view, $args, $config), 'payment.url-update' => $this->getUrlUpdate($view, $args, $config), 'client.ipaddress' => $view->request()->getClientAddress());
$provider->injectGlobalConfigBE($urls);
$params = $view->param();
try {
$basket = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket')->get();
$attrs = $basket->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT)->getAttributes();
foreach ($attrs as $item) {
$params[$item->getCode()] = $item->getValue();
}
} catch (\Exception $e) {
}
// nothing available
if (($form = $provider->process($orderItem, $params)) === null) {
$msg = sprintf('Invalid process response from service provider with code "%1$s"', $serviceItem->getCode());
throw new \Aimeos\Client\Html\Exception($msg);
}
$view->standardUrlNext = $form->getUrl();
$view->standardMethod = $form->getMethod();
$view->standardProcessParams = $form->getValues();
$view->standardUrlExternal = $form->getExternal();
} else {
$view->standardUrlNext = $this->getUrlConfirm($view, array(), array());
$view->standardMethod = 'GET';
}
parent::process();
} catch (\Aimeos\Client\Html\Exception $e) {
$error = array($context->getI18n()->dt('client', $e->getMessage()));
$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
} catch (\Aimeos\Controller\Frontend\Exception $e) {
$error = array($context->getI18n()->dt('controller/frontend', $e->getMessage()));
$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
} catch (\Aimeos\MShop\Exception $e) {
$error = array($context->getI18n()->dt('mshop', $e->getMessage()));
$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
} catch (\Exception $e) {
$context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
$error = array($context->getI18n()->dt('client', 'A non-recoverable error occured'));
$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
}
}
示例8: setViewParams
/**
* Sets the necessary parameter values in the view.
*
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
* @param array &$tags Result array for the list of tags that are associated to the output
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
* @return \Aimeos\MW\View\Iface Modified view object
*/
protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null)
{
if (!isset($this->cache)) {
$context = $this->getContext();
$basketCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
$serviceCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'service');
$basket = $basketCntl->get();
$services = $serviceCntl->getServices('payment', $basket);
$serviceAttributes = $servicePrices = array();
foreach ($services as $id => $service) {
$serviceAttributes[$id] = $serviceCntl->getServiceAttributes('payment', $id, $basket);
$servicePrices[$id] = $serviceCntl->getServicePrice('payment', $id, $basket);
}
$view->paymentServices = $services;
$view->paymentServiceAttributes = $serviceAttributes;
$view->paymentServicePrices = $servicePrices;
$this->cache = $view;
}
return $this->cache;
}
示例9: setViewParams
/**
* Sets the necessary parameter values in the view.
*
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
* @param array &$tags Result array for the list of tags that are associated to the output
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
* @return \Aimeos\MW\View\Iface Modified view object
*/
protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null)
{
if (!isset($this->cache)) {
$codes = array();
$context = $this->getContext();
$input = $view->param('f_search');
$controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
$filter = $controller->createTextFilter($input, null, '+', 0, 25, 'default', 'name');
$texts = $controller->getTextList($filter);
/** client/html/catalog/suggest/usecode
* Enables product suggestions based on using the product code
*
* The suggested entries for the full text search in the catalog filter component
* are based on the product names by default. By setting this option to true or 1,
* you can add suggestions based on the product codes as well.
*
* @param boolean True to search for product codes too, false for product names only
* @since 2016.09
* @category Developer
*/
if ($context->getConfig()->get('client/html/catalog/suggest/usecode', false)) {
$filter = $controller->createTextFilter($input, null, '+', 0, 25, 'default', 'code');
$codes = $controller->getTextList($filter);
}
/** client/html/catalog/suggest/domains
* List of domain items that should be fetched along with the products
*
* The suggsted entries for the full text search in the catalog filter component
* usually consist of the names of the matched products. By default, only the
* product item including the localized name is available. You can add more domains
* like e.g. "media" to get the images of the product as well.
*
* '''Note:''' The more domains you will add, the slower the autocomplete requests
* will be! Keep it to an absolute minium for user friendly response times.
*
* @param array List of domain names
* @since 2016.08
* @category Developer
* @see client/html/catalog/suggest/standard/template-body
*/
$domains = $context->getConfig()->get('client/html/catalog/suggest/domains', array());
$manager = $controller->createManager('product');
$search = $manager->createSearch(true);
$expr = array($search->compare('==', 'product.id', array_merge(array_keys($texts), array_keys($codes))), $search->getConditions());
$search->setConditions($search->combine('&&', $expr));
$result = $manager->searchItems($search, $domains);
// shortcut to avoid having to fetch the text items to get the the localized name
foreach ($result as $id => $item) {
if (isset($texts[$id])) {
$item->setLabel($texts[$id]);
}
}
$view->suggestItems = $result;
$this->cache = $view;
}
return $this->cache;
}
示例10: getProductItems
/**
* Returns the product items for the given IDs.
*
* @param string[] $ids List of product IDs
* @return \Aimeos\MShop\Product\Item\Iface[] List of product items
*/
protected function getProductItems(array $ids)
{
$context = $this->getContext();
$config = $context->getConfig();
/** client/html/basket/related/bought/standard/domains
* The list of domain names whose items should be available in the template for the products
*
* The templates rendering product details usually add the images,
* prices and texts, etc. associated to the product
* item. If you want to display additional or less content, you can
* configure your own list of domains (attribute, media, price, product,
* text, etc. are domains) whose items are fetched from the storage.
* Please keep in mind that the more domains you add to the configuration,
* the more time is required for fetching the content!
*
* @param array List of domain names
* @since 2014.09
* @category Developer
*/
$domains = array('text', 'price', 'media');
$domains = $config->get('client/html/basket/related/bought/standard/domains', $domains);
$controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
return $controller->getProductItems($ids, $domains);
}
示例11: setViewParams
/**
* Sets the necessary parameter values in the view.
*
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
* @param array &$tags Result array for the list of tags that are associated to the output
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
* @return \Aimeos\MW\View\Iface Modified view object
*/
protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null)
{
if (!isset($this->cache)) {
$context = $this->getContext();
$config = $context->getConfig();
if ($config->get('client/html/catalog/lists/basket-add', false)) {
$products = $view->get('listProductItems', array());
$domains = array('media', 'price', 'text', 'attribute', 'product');
$controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
$productIds = $this->getProductIds($products);
$productManager = $controller->createManager('product');
$productItems = $this->getDomainItems($productManager, 'product.id', $productIds, $domains);
$this->addMetaItems($productItems, $this->expire, $this->tags);
$attrIds = $this->getAttributeIds($productItems);
$attributeManager = $controller->createManager('attribute');
$attributeItems = $this->getDomainItems($attributeManager, 'attribute.id', $attrIds, $domains);
$this->addMetaItems($attributeItems, $this->expire, $this->tags);
$mediaIds = $this->getMediaIds($productItems);
$mediaManager = $controller->createManager('media');
$mediaItems = $this->getDomainItems($mediaManager, 'media.id', $mediaIds, $domains);
$this->addMetaItems($mediaItems, $this->expire, $this->tags);
if (!empty($productIds) && $config->get('client/html/catalog/lists/stock/enable', true) === true) {
$view->itemsStockUrl = $this->getStockUrl($view, $productIds);
}
$view->itemsAttributeItems = $attributeItems;
$view->itemsProductItems = $productItems;
$view->itemsMediaItems = $mediaItems;
}
$view->itemPosition = ($this->getProductListPage($view) - 1) * $this->getProductListSize($view);
$this->cache = $view;
}
return $this->cache;
}
示例12: setViewParams
/**
* Sets the necessary parameter values in the view.
*
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
* @param array &$tags Result array for the list of tags that are associated to the output
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
* @return \Aimeos\MW\View\Iface Modified view object
*/
protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null)
{
if (!isset($this->cache)) {
$context = $this->getContext();
$basketCntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
$view->standardBasket = $basketCntl->get();
/** client/html/checkout/standard/url/step-active
* Name of the checkout process step to jump to if no previous step requires attention
*
* The checkout process consists of several steps which are usually
* displayed one by another to the customer. If the data of a step
* is already available, then that step is skipped. The active step
* is the one that is displayed if all other steps are skipped.
*
* If one of the previous steps misses some data the customer has
* to enter, then this step is displayed first. After providing
* the missing data, the whole series of steps are tested again
* and if no other step requests attention, the configured active
* step will be displayed.
*
* The order of the steps is determined by the order of sub-parts
* that are configured for the checkout client.
*
* @param string Name of the confirm standard HTML client
* @since 2014.07
* @category Developer
* @category User
* @see client/html/checkout/standard/standard/subparts
*/
$default = $view->config('client/html/checkout/standard/url/step-active', 'summary');
/** client/html/checkout/standard/onepage
* Shows all named checkout subparts at once for a one page checkout
*
* Normally, the checkout process is divided into several steps for entering
* addresses, select delivery and payment options as well as showing the
* summary page. This enables dependencies between two steps like showing
* delivery options based on the address entered by the customer. Furthermore,
* this is good way to limit the amount of information displayed which is
* preferred by mobile users.
*
* Contrary to that, a one page checkout displays all information on only
* one page and customers get an immediate overview of which information
* they have to enter and what options they can select from. This is an
* advantage if only a very limited amount of information must be entered
* or if there are almost no options to choose from and no dependencies
* between exist.
*
* Using this config options, shop developers are able to define which
* checkout subparts are combined to a one page view. Simply add the names
* of all checkout subparts to the list. Available checkout subparts for
* a one page checkout are:
* * address
* * delivery
* * payment
* * summary
*
* @param array List of checkout subparts name
* @since 2015.05
* @category Developer
*/
$onepage = $view->config('client/html/checkout/standard/onepage', array());
$onestep = !empty($onepage) ? array_shift($onepage) : $default;
// keep the first one page step
$steps = (array) $context->getConfig()->get($this->subPartPath, $this->subPartNames);
$steps = array_diff($steps, $onepage);
// remove all remaining steps in $onepage
// use first step if default step isn't available
$default = !in_array($default, $steps) ? reset($steps) : $default;
$current = $view->param('c_step', $default);
// use $onestep if the current step isn't available due to one page layout
if (!in_array($current, $steps)) {
$current = $onestep;
}
// use $onestep if the active step isn't available due to one page layout
if (isset($view->standardStepActive) && in_array($view->standardStepActive, $onepage)) {
$view->standardStepActive = $onestep;
}
$cpos = array_search($current, $steps);
if (!isset($view->standardStepActive) || ($apos = array_search($view->standardStepActive, $steps)) !== false && $cpos !== false && $cpos < $apos) {
$view->standardStepActive = $current;
}
$view->standardSteps = $steps;
$this->cache = $this->addNavigationUrls($view, $steps, $view->standardStepActive);
}
return $this->cache;
}
示例13: setViewParams
/**
* Sets the necessary parameter values in the view.
*
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
* @param array &$tags Result array for the list of tags that are associated to the output
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
* @return \Aimeos\MW\View\Iface Modified view object
*/
protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null)
{
if (!isset($this->view)) {
if (($pos = $view->param('l_pos')) !== null && ($pid = $view->param('d_prodid')) !== null) {
if ($pos < 1) {
$start = 0;
$size = 2;
} else {
$start = $pos - 1;
$size = 3;
}
$context = $this->getContext();
$site = $context->getLocale()->getSite()->getCode();
$params = $context->getSession()->get('aimeos/catalog/lists/params/last/' . $site, array());
$filter = $this->getProductListFilterByParam($params);
$filter->setSlice($start, $size);
$total = null;
$controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
$products = $controller->getIndexItems($filter, array('text'), $total);
if (($count = count($products)) > 1) {
$enc = $view->encoder();
$listPos = array_search($pid, array_keys($products));
$target = $view->config('client/html/catalog/detail/url/target');
$controller = $view->config('client/html/catalog/detail/url/controller', 'catalog');
$action = $view->config('client/html/catalog/detail/url/action', 'detail');
$config = $view->config('client/html/catalog/detail/url/config', array());
if ($listPos > 0 && ($product = reset($products)) !== false) {
$param = array('d_prodid' => $product->getId(), 'd_name' => $enc->url($product->getName('url ')), 'l_pos' => $pos - 1);
$view->navigationPrev = $view->url($target, $controller, $action, $param, array(), $config);
}
if ($listPos < $count - 1 && ($product = end($products)) !== false) {
$param = array('d_prodid' => $product->getId(), 'd_name' => $enc->url($product->getName('url')), 'l_pos' => $pos + 1);
$view->navigationNext = $view->url($target, $controller, $action, $param, array(), $config);
}
}
}
$this->view = $view;
}
return $this->view;
}
示例14: editProducts
/**
* Edits the products specified by the view parameters to the basket.
*
* @param \Aimeos\MW\View\Iface $view View object
* @param array $options List of options for editProducts() in basket controller
*/
protected function editProducts(\Aimeos\MW\View\Iface $view, array $options)
{
$this->clearCached();
$products = (array) $view->param('b_prod', array());
$controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket');
if (($position = $view->param('b_position', '')) !== '') {
$products[] = array('position' => $position, 'quantity' => $view->param('b_quantity', 1), 'attrconf-code' => array_filter((array) $view->param('b_attrconfcode', array())));
}
foreach ($products as $values) {
$controller->editProduct(isset($values['position']) ? (int) $values['position'] : 0, isset($values['quantity']) ? (int) $values['quantity'] : 1, $options, isset($values['attrconf-code']) ? array_filter((array) $values['attrconf-code']) : array());
}
}
示例15: setViewParams
/**
* Sets the necessary parameter values in the view.
*
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
* @param array &$tags Result array for the list of tags that are associated to the output
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
* @return \Aimeos\MW\View\Iface Modified view object
*/
protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null)
{
if (!isset($this->cache)) {
$total = 0;
$productIds = array();
$context = $this->getContext();
$typeItem = $this->getTypeItem('customer/lists/type', 'product', 'favorite');
$size = $this->getProductListSize($view);
$current = $this->getProductListPage($view);
$last = $total != 0 ? ceil($total / $size) : 1;
$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists');
$search = $manager->createSearch();
$expr = array($search->compare('==', 'customer.lists.parentid', $context->getUserId()), $search->compare('==', 'customer.lists.typeid', $typeItem->getId()), $search->compare('==', 'customer.lists.domain', 'product'));
$search->setConditions($search->combine('&&', $expr));
$search->setSortations(array($search->sort('-', 'customer.lists.position')));
$search->setSlice(($current - 1) * $size, $size);
$view->favoriteListItems = $manager->searchItems($search, array(), $total);
/** client/html/account/favorite/domains
* A list of domain names whose items should be available in the account favorite view template
*
* The templates rendering product details usually add the images,
* prices and texts associated to the product item. If you want to
* display additional or less content, you can configure your own
* list of domains (attribute, media, price, product, text, etc. are
* domains) whose items are fetched from the storage. Please keep
* in mind that the more domains you add to the configuration, the
* more time is required for fetching the content!
*
* @param array List of domain names
* @since 2014.09
* @category Developer
* @see client/html/catalog/domains
*/
$default = array('text', 'price', 'media');
$domains = $context->getConfig()->get('client/html/account/favorite/domains', $default);
foreach ($view->favoriteListItems as $listItem) {
$productIds[] = $listItem->getRefId();
}
$controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
$view->favoriteProductItems = $controller->getProductItems($productIds, $domains);
$view->favoritePageFirst = 1;
$view->favoritePagePrev = $current > 1 ? $current - 1 : 1;
$view->favoritePageNext = $current < $last ? $current + 1 : $last;
$view->favoritePageLast = $last;
$view->favoritePageCurr = $current;
$this->cache = $view;
}
return $this->cache;
}