コード例 #1
0
 /**
  * @param \Ced\DevTool\Block\Context $context
  * @param \Magento\Framework\UrlFactory $urlFactory
  */
 public function __construct(\Ced\DevTool\Block\Context $context, UrlFactory $urlFactory)
 {
     $this->_devToolHelper = $context->getDevToolHelper();
     $this->_config = $context->getConfig();
     $this->_urlApp = $urlFactory->create();
     parent::__construct($context);
 }
コード例 #2
0
 public function testAuthenticate()
 {
     $urlMock = $this->getMock('Magento\\Framework\\Url', [], [], '', false);
     $urlMock->expects($this->exactly(2))->method('getUrl')->will($this->returnValue(''));
     $urlMock->expects($this->once())->method('getRebuiltUrl')->will($this->returnValue(''));
     $this->urlFactoryMock->expects($this->exactly(3))->method('create')->will($this->returnValue($urlMock));
     $this->responseMock->expects($this->once())->method('setRedirect')->with('')->will($this->returnValue(''));
     $this->assertFalse($this->_model->authenticate());
 }
コード例 #3
0
ファイル: Confirm.php プロジェクト: opexsw/magento2
 /**
  * @param Context $context
  * @param Session $customerSession
  * @param PageFactory $resultPageFactory
  * @param ScopeConfigInterface $scopeConfig
  * @param StoreManagerInterface $storeManager
  * @param AccountManagementInterface $customerAccountManagement
  * @param CustomerRepositoryInterface $customerRepository
  * @param Address $addressHelper
  * @param UrlFactory $urlFactory
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(Context $context, Session $customerSession, PageFactory $resultPageFactory, ScopeConfigInterface $scopeConfig, StoreManagerInterface $storeManager, AccountManagementInterface $customerAccountManagement, CustomerRepositoryInterface $customerRepository, Address $addressHelper, UrlFactory $urlFactory)
 {
     $this->scopeConfig = $scopeConfig;
     $this->storeManager = $storeManager;
     $this->customerAccountManagement = $customerAccountManagement;
     $this->customerRepository = $customerRepository;
     $this->addressHelper = $addressHelper;
     $this->urlModel = $urlFactory->create();
     parent::__construct($context, $customerSession, $resultPageFactory);
 }
コード例 #4
0
ファイル: Result.php プロジェクト: nblair/magescotch
 /**
  * @return void
  */
 public function executeInternal()
 {
     try {
         $this->_catalogSearchAdvanced->addFilters($this->getRequest()->getQueryValue());
         $this->_view->loadLayout();
         $this->_view->renderLayout();
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->messageManager->addError($e->getMessage());
         $defaultUrl = $this->_urlFactory->create()->addQueryParams($this->getRequest()->getQueryValue())->getUrl('*/*/');
         $this->getResponse()->setRedirect($this->_redirect->error($defaultUrl));
     }
 }
コード例 #5
0
ファイル: Query.php プロジェクト: Doability/magento2dev
 /**
  * {@inheritdoc}
  */
 public function getItems()
 {
     $items = [];
     /** @var \Magento\Search\Model\Query $query */
     foreach ($this->collection as $query) {
         $url = $this->urlFactory->create();
         $url->setQueryParam('q', $query->getQueryText());
         $url = $url->getUrl('catalogsearch/result');
         $key = strtolower(trim($query->getQueryText()));
         $items[$key] = ['query_text' => $query->getQueryText(), 'num_results' => $query->getNumResults(), 'popularity' => $query->getPopularity(), 'url' => $url];
     }
     return array_values($items);
 }
コード例 #6
0
ファイル: Index.php プロジェクト: wclabhinav/Magento2
 public function __construct(Context $context, PageFactory $resultPageFactory, Registration $registration, Session $customerSession, StoreManagerInterface $storeManager, AccountManagementInterface $accountManagement, CustomerUrl $customerUrl, CustomerExtractor $customerExtractor, AccountRedirect $accountRedirect, UrlFactory $urlFactory, Logger $logger)
 {
     $this->resultPageFactory = $resultPageFactory;
     parent::__construct($context);
     $this->registration = $registration;
     $this->session = $customerSession;
     $this->storeManager = $storeManager;
     $this->accountManagement = $accountManagement;
     $this->customerUrl = $customerUrl;
     $this->customerExtractor = $customerExtractor;
     $this->accountRedirect = $accountRedirect;
     $this->urlModel = $urlFactory->create();
     $this->logger = $logger;
 }
コード例 #7
0
ファイル: Term.php プロジェクト: tingyeeh/magento2
 /**
  * @param \Magento\Framework\DataObject $obj
  * @return string
  */
 public function getSearchUrl($obj)
 {
     /** @var $url UrlInterface */
     $url = $this->_urlFactory->create();
     /*
      * url encoding will be done in Url.php http_build_query
      * so no need to explicitly called urlencode for the text
      */
     $url->setQueryParam('q', $obj->getName());
     return $url->getUrl('catalogsearch/result');
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  * @param Observer $observer
  * @return bool
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNorouteToSearchEnabled()) {
         /** @var \Magento\Framework\App\Request\Http $request */
         $request = $observer->getEvent()->getData('request');
         /** @var \Magento\Framework\App\Response\Http\Interceptor $response */
         $response = $observer->getEvent()->getData('response');
         $extension = pathinfo($request->getRequestString(), PATHINFO_EXTENSION);
         if ($response->getStatusCode() != 404 || !$request->isGet() || in_array($extension, $this->mediaTypes)) {
             return false;
         } else {
             $searchQuery = $this->getSearchQuery($request);
             if (!$searchQuery) {
                 return false;
             }
             $message = __('The page you requested was not found, but we have searched for relevant content.');
             $this->messageManager->addNotice($message);
             $url = $this->urlFactory->create()->addQueryParams(['q' => $searchQuery])->getUrl('catalogsearch/result');
             $response->setRedirect($url)->setStatusCode(301)->sendResponse();
         }
     }
     return true;
 }
コード例 #9
0
 /**
  * @param Context $context
  * @param Session $customerSession
  * @param ScopeConfigInterface $scopeConfig
  * @param StoreManagerInterface $storeManager
  * @param AccountManagementInterface $accountManagement
  * @param Address $addressHelper
  * @param UrlFactory $urlFactory
  * @param FormFactory $formFactory
  * @param SubscriberFactory $subscriberFactory
  * @param RegionInterfaceFactory $regionDataFactory
  * @param AddressInterfaceFactory $addressDataFactory
  * @param CustomerInterfaceFactory $customerDataFactory
  * @param CustomerUrl $customerUrl
  * @param Registration $registration
  * @param Escaper $escaper
  * @param CustomerExtractor $customerExtractor
  * @param DataObjectHelper $dataObjectHelper
  * @param AccountRedirect $accountRedirect
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(Context $context, Session $customerSession, ScopeConfigInterface $scopeConfig, StoreManagerInterface $storeManager, AccountManagementInterface $accountManagement, Address $addressHelper, UrlFactory $urlFactory, FormFactory $formFactory, SubscriberFactory $subscriberFactory, RegionInterfaceFactory $regionDataFactory, AddressInterfaceFactory $addressDataFactory, CustomerInterfaceFactory $customerDataFactory, CustomerUrl $customerUrl, Registration $registration, Escaper $escaper, CustomerExtractor $customerExtractor, DataObjectHelper $dataObjectHelper, AccountRedirect $accountRedirect)
 {
     $this->session = $customerSession;
     $this->scopeConfig = $scopeConfig;
     $this->storeManager = $storeManager;
     $this->accountManagement = $accountManagement;
     $this->addressHelper = $addressHelper;
     $this->formFactory = $formFactory;
     $this->subscriberFactory = $subscriberFactory;
     $this->regionDataFactory = $regionDataFactory;
     $this->addressDataFactory = $addressDataFactory;
     $this->customerDataFactory = $customerDataFactory;
     $this->customerUrl = $customerUrl;
     $this->registration = $registration;
     $this->escaper = $escaper;
     $this->customerExtractor = $customerExtractor;
     $this->urlModel = $urlFactory->create();
     $this->dataObjectHelper = $dataObjectHelper;
     $this->accountRedirect = $accountRedirect;
     parent::__construct($context);
 }
コード例 #10
0
ファイル: Session.php プロジェクト: pavelnovitsky/magento2
 /**
  * @return \Magento\Framework\UrlInterface
  */
 protected function _createUrl()
 {
     return $this->_urlFactory->create();
 }
コード例 #11
0
ファイル: Misspell.php プロジェクト: Doability/magento2dev
 /**
  * Return search url for query
  *
  * @param string $query
  * @return string
  */
 public function getQueryUrl($query)
 {
     return $this->urlFactory->create()->addQueryParams(['q' => $query])->getUrl('catalogsearch/result');
 }
コード例 #12
0
ファイル: Url.php プロジェクト: pradeep-wagento/magento2
 /**
  * Retrieve URL Instance
  *
  * @return \Magento\Framework\UrlInterface
  */
 private function getUrlInstance()
 {
     return $this->urlFactory->create();
 }
コード例 #13
0
ファイル: Query.php プロジェクト: Doability/magento2dev
 /**
  * Fallback Url
  *
  * @param string $from
  * @param string $to
  * @return string
  */
 public function getFallbackUrl($from, $to)
 {
     return $this->urlFactory->create()->addQueryParams(['q' => $to, 'f' => $from])->getUrl('catalogsearch/result');
 }
コード例 #14
0
ファイル: Result.php プロジェクト: shabbirvividads/magento2
 /**
  * @return string
  */
 public function getFormUrl()
 {
     return $this->_urlFactory->create()->addQueryParams($this->getRequest()->getQueryValue())->getUrl('*/*/', ['_escape' => true]);
 }