当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestInterface::getParam方法代码示例

本文整理汇总了PHP中Magento\Framework\App\RequestInterface::getParam方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getParam方法的具体用法?PHP RequestInterface::getParam怎么用?PHP RequestInterface::getParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\App\RequestInterface的用法示例。


在下文中一共展示了RequestInterface::getParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getWishlist

 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getWishlist($wishlistId = null)
 {
     if ($this->wishlist) {
         return $this->wishlist;
     }
     try {
         if (!$wishlistId) {
             $wishlistId = $this->request->getParam('wishlist_id');
         }
         $customerId = $this->customerSession->getCustomerId();
         $wishlist = $this->wishlistFactory->create();
         if (!$wishlistId && !$customerId) {
             return $wishlist;
         }
         if ($wishlistId) {
             $wishlist->load($wishlistId);
         } elseif ($customerId) {
             $wishlist->loadByCustomerId($customerId, true);
         }
         if (!$wishlist->getId() || $wishlist->getCustomerId() != $customerId) {
             throw new \Magento\Framework\Exception\NoSuchEntityException(__('The requested Wish List doesn\'t exist.'));
         }
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         $this->messageManager->addError($e->getMessage());
         return false;
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('We can\'t create the Wish List right now.'));
         return false;
     }
     $this->wishlist = $wishlist;
     return $wishlist;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:36,代码来源:WishlistProvider.php

示例2: build

 /**
  * Build product based on user request
  *
  * @param RequestInterface $request
  * @return \Magento\Catalog\Model\Product
  */
 public function build(RequestInterface $request)
 {
     $productId = (int) $request->getParam('id');
     /** @var $product \Magento\Catalog\Model\Product */
     $product = $this->productFactory->create();
     $product->setStoreId($request->getParam('store', 0));
     $typeId = $request->getParam('type');
     if (!$productId && $typeId) {
         $product->setTypeId($typeId);
     }
     $product->setData('_edit_mode', true);
     if ($productId) {
         try {
             $product->load($productId);
         } catch (\Exception $e) {
             $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE);
             $this->logger->critical($e);
         }
     }
     $setId = (int) $request->getParam('set');
     if ($setId) {
         $product->setAttributeSetId($setId);
     }
     $this->registry->register('product', $product);
     $this->registry->register('current_product', $product);
     $this->wysiwygConfig->setStoreId($request->getParam('store'));
     return $product;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:34,代码来源:Builder.php

示例3: getLinks

 /**
  * Get stored value.
  * Fallback to request if none.
  *
  * @return array|null
  */
 public function getLinks()
 {
     if (null === $this->links) {
         $this->links = (array) $this->request->getParam('links', []);
     }
     return $this->links;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:Resolver.php

示例4: __construct

 /**
  * @param string $name
  * @param string $primaryFieldName
  * @param string $requestFieldName
  * @param CollectionFactory $collectionFactory
  * @param RequestInterface $request
  * @param array $meta
  * @param array $data
  */
 public function __construct($name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, RequestInterface $request, array $meta = [], array $data = [])
 {
     parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
     $this->request = $request;
     $this->collection = $collectionFactory->create();
     $this->collection->setExcludeSetFilter((int) $this->request->getParam('template_id', 0));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:Listing.php

示例5: getCategoriesTree

 /**
  * Retrieve categories tree
  *
  * @return array
  */
 protected function getCategoriesTree()
 {
     if ($this->categoriesTree === null) {
         $storeId = $this->request->getParam('store');
         /* @var $matchingNamesCollection \Magento\Catalog\Model\ResourceModel\Category\Collection */
         $matchingNamesCollection = $this->categoryCollectionFactory->create();
         $matchingNamesCollection->addAttributeToSelect('path')->addAttributeToFilter('entity_id', ['neq' => CategoryModel::TREE_ROOT_ID])->setStoreId($storeId);
         $shownCategoriesIds = [];
         /** @var \Magento\Catalog\Model\Category $category */
         foreach ($matchingNamesCollection as $category) {
             foreach (explode('/', $category->getPath()) as $parentId) {
                 $shownCategoriesIds[$parentId] = 1;
             }
         }
         /* @var $collection \Magento\Catalog\Model\ResourceModel\Category\Collection */
         $collection = $this->categoryCollectionFactory->create();
         $collection->addAttributeToFilter('entity_id', ['in' => array_keys($shownCategoriesIds)])->addAttributeToSelect(['name', 'is_active', 'parent_id'])->setStoreId($storeId);
         $categoryById = [CategoryModel::TREE_ROOT_ID => ['value' => CategoryModel::TREE_ROOT_ID]];
         foreach ($collection as $category) {
             foreach ([$category->getId(), $category->getParentId()] as $categoryId) {
                 if (!isset($categoryById[$categoryId])) {
                     $categoryById[$categoryId] = ['value' => $categoryId];
                 }
             }
             $categoryById[$category->getId()]['is_active'] = $category->getIsActive();
             $categoryById[$category->getId()]['label'] = $category->getName();
             $categoryById[$category->getParentId()]['optgroup'][] =& $categoryById[$category->getId()];
         }
         $this->categoriesTree = $categoryById[CategoryModel::TREE_ROOT_ID]['optgroup'];
     }
     return $this->categoriesTree;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:37,代码来源:Options.php

示例6: getData

 /**
  * Retrieve configuration metadata
  *
  * @return array
  */
 public function getData()
 {
     $scope = $this->request->getParam('scope');
     $scopeId = $this->request->getParam('scope_id');
     $data = [];
     if ($scope) {
         $showFallbackReset = false;
         list($fallbackScope, $fallbackScopeId) = $this->scopeFallbackResolver->getFallbackScope($scope, $scopeId);
         if ($fallbackScope && !$this->storeManager->isSingleStoreMode()) {
             $scope = $fallbackScope;
             $scopeId = $fallbackScopeId;
             $showFallbackReset = true;
         }
         $designConfig = $this->designConfigRepository->getByScope($scope, $scopeId);
         $fieldsData = $designConfig->getExtensionAttributes()->getDesignConfigData();
         foreach ($fieldsData as $fieldData) {
             $element =& $data;
             foreach (explode('/', $fieldData->getFieldConfig()['fieldset']) as $fieldset) {
                 if (!isset($element[$fieldset]['children'])) {
                     $element[$fieldset]['children'] = [];
                 }
                 $element =& $element[$fieldset]['children'];
             }
             $fieldName = $fieldData->getFieldConfig()['field'];
             $element[$fieldName]['arguments']['data']['config']['default'] = $fieldData->getValue();
             $element[$fieldName]['arguments']['data']['config']['showFallbackReset'] = $showFallbackReset;
         }
     }
     return $data;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:35,代码来源:MetadataLoader.php

示例7: toOptionArray

 /**
  * Get options.
  *
  * @return array
  */
 public function toOptionArray()
 {
     $fields = [];
     $fields[] = ['value' => '0', 'label' => '-- Disabled --'];
     $websiteName = $this->request->getParam('website', false);
     $website = $websiteName ? $this->storeManager->getWebsite($websiteName) : 0;
     if ($this->helper->isEnabled($website)) {
         $savedPrograms = $this->registry->registry('programs');
         //get saved datafileds from registry
         if (is_array($savedPrograms)) {
             $programs = $savedPrograms;
         } else {
             //grab the datafields request and save to register
             $client = $this->helper->getWebsiteApiClient($website);
             $programs = $client->getPrograms();
             $this->registry->unregister('programs');
             $this->registry->register('programs', $programs);
         }
         //set the api error message for the first option
         if (isset($programs->message)) {
             //message
             $fields[] = ['value' => 0, 'label' => $programs->message];
         } elseif (!empty($programs)) {
             //loop for all programs option
             foreach ($programs as $program) {
                 if (isset($program->id) && $program->status == 'Active') {
                     //@codingStandardsIgnoreStart
                     $fields[] = ['value' => $program->id, 'label' => addslashes($program->name)];
                     //@codingStandardsIgnoreEnd
                 }
             }
         }
     }
     return $fields;
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:40,代码来源:Program.php

示例8: execute

 /**
  * Generate urls for UrlRewrite and save it in storage
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     foreach ($observer->getEvent()->getProducts() as $productId) {
         $product = $this->productRepository->getById($productId, false, $this->request->getParam('store_id', Store::DEFAULT_STORE_ID));
         $this->urlPersist->deleteByData([UrlRewrite::ENTITY_ID => $product->getId(), UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE]);
         $this->urlPersist->replace($this->productUrlRewriteGenerator->generate($product));
     }
 }
开发者ID:CompassPointMedia,项目名称:magento2,代码行数:14,代码来源:ProductToWebsiteChangeObserver.php

示例9: aroundGetConfigPath

 /**
  * Get original configPath (not changed by PayPal configuration inheritance)
  *
  * @param \Magento\Config\Model\Config\Structure\Element\Field $subject
  * @param \Closure $proceed
  * @return string|null
  */
 public function aroundGetConfigPath(\Magento\Config\Model\Config\Structure\Element\Field $subject, \Closure $proceed)
 {
     $configPath = $proceed();
     if (!isset($configPath) && $this->_request->getParam('section') == 'payment') {
         $configPath = preg_replace('@^(' . implode('|', \Magento\Paypal\Model\Config\StructurePlugin::getPaypalConfigCountries(true)) . ')/@', 'payment/', $subject->getPath());
     }
     return $configPath;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:FieldPlugin.php

示例10: getData

 /**
  * Retrieve configuration data
  *
  * @return array
  */
 public function getData()
 {
     $scope = $this->request->getParam('scope');
     $scopeId = $this->request->getParam('scope_id');
     $data = $this->loadData($scope, $scopeId);
     $data[$scope]['scope'] = $scope;
     $data[$scope]['scope_id'] = $scopeId;
     return $data;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:14,代码来源:DataLoader.php

示例11: afterSaveShippingMethod

 /**
  * @param \Magento\Checkout\Model\Type\Onepage $subject
  * @param array $result
  * @return $this
  */
 public function afterSaveShippingMethod(\Magento\Checkout\Model\Type\Onepage $subject, array $result)
 {
     if (!$result) {
         $giftMessages = $this->request->getParam('giftmessage');
         $quote = $subject->getQuote();
         $this->message->add($giftMessages, $quote);
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:Onepage.php

示例12: aroundProcessProduct

 /**
  * Change product type to configurable if needed
  *
  * @param \Magento\Catalog\Model\Product\TypeTransitionManager $subject
  * @param Closure $proceed
  * @param \Magento\Catalog\Model\Product $product
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundProcessProduct(\Magento\Catalog\Model\Product\TypeTransitionManager $subject, Closure $proceed, \Magento\Catalog\Model\Product $product)
 {
     $attributes = $this->request->getParam('attributes');
     if (!empty($attributes)) {
         $product->setTypeId(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE);
         return;
     }
     $proceed($product);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Configurable.php

示例13: getData

 /**
  * {@inheritdoc}
  */
 public function getData()
 {
     $this->getCollection()->addEntityFilter($this->request->getParam('current_product_id', 0))->addStoreData();
     $arrItems = ['totalRecords' => $this->getCollection()->getSize(), 'items' => []];
     foreach ($this->getCollection() as $item) {
         $arrItems['items'][] = $item->toArray([]);
     }
     return $arrItems;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:12,代码来源:ReviewDataProvider.php

示例14: execute

 /**
  * Reset session data when customer re-authenticates
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute($observer)
 {
     $this->_customerSession->setCustomerId(null)->setCustomerGroupId(null);
     if ($this->_requestHttp->getParam('context') != 'checkout') {
         $this->quoteManager->expire();
         return;
     }
     $this->quoteManager->setGuest();
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:15,代码来源:CustomerAuthenticatedEvent.php

示例15: getPost

 /**
  * Retrieve post
  *
  * @return PostInterface|null
  */
 protected function getPost()
 {
     if (null !== $this->post) {
         return $this->post;
     }
     if (!($id = $this->request->getParam('current_post_id'))) {
         return null;
     }
     return $this->post = $this->postRepository->getById($id);
 }
开发者ID:magefan,项目名称:module-blog,代码行数:15,代码来源:PostDataProvider.php


注:本文中的Magento\Framework\App\RequestInterface::getParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。