Beispiel #1
0
 /**
  * Load design
  *
  * @return void
  */
 public function load()
 {
     $area = $this->_areaList->getArea($this->appState->getAreaCode());
     $area->load(\Magento\Framework\App\Area::PART_DESIGN);
     $area->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     $area->detectDesign($this->_request);
 }
Beispiel #2
0
    /**
     * {@inheritdoc}
     */
    public function doOperation()
    {
        if (empty($this->data)) {
            return;
        }
        $this->interceptionConfigurationBuilder->addAreaCode(App\Area::AREA_GLOBAL);

        foreach ($this->areaList->getCodes() as $areaCode) {
            $this->interceptionConfigurationBuilder->addAreaCode($areaCode);
        }

        $classesList = [];
        foreach ($this->data['intercepted_paths'] as $path) {
            $classesList = array_merge($classesList, $this->classesScanner->getList($path));
        }

        $generatorIo = new \Magento\Framework\Code\Generator\Io(
            new \Magento\Framework\Filesystem\Driver\File(),
            $this->data['path_to_store']
        );
        $generator = $this->generatorFactory->create(
            [
                'ioObject' => $generatorIo,
                'generatedEntities' => [
                    Interceptor::ENTITY_TYPE => 'Magento\Setup\Module\Di\Code\Generator\Interceptor',
                ]
            ]
        );
        $configuration = $this->interceptionConfigurationBuilder->getInterceptionConfiguration($classesList);
        $generator->generateList($configuration);
    }
Beispiel #3
0
 public function testGetArea()
 {
     /** @var \Magento\Framework\ObjectManagerInterface $objectManagerMock */
     $objectManagerMock = $this->getObjectManagerMockGetArea();
     $areas = ['area1' => ['router' => 'value1'], 'area2' => 'value2'];
     $this->_model = new AreaList($objectManagerMock, $this->_resolverFactory, $areas, '');
     $this->assertEquals($this->_model->getArea('testArea'), 'ok');
 }
Beispiel #4
0
 /**
  * Get options in "key-value" format
  *
  * @return array
  */
 public function toArray()
 {
     $areListCodes = $this->areaList->getCodes();
     $areList = [];
     foreach ($areListCodes as $areListCode) {
         $areList[$areListCode] = sprintf('%s [%s]', $this->areaList->getFrontName($areListCode), $areListCode);
     }
     return $areList;
 }
Beispiel #5
0
 /**
  * Modify pathInfo: strip down the front name and query parameters.
  *
  * @param \Magento\Framework\App\AreaList $areaList
  * @param \Magento\Framework\Config\ScopeInterface $configScope
  * @param null|string|\Zend_Uri $uri
  */
 public function __construct(\Magento\Framework\App\AreaList $areaList, \Magento\Framework\Config\ScopeInterface $configScope, $uri = null)
 {
     parent::__construct($uri);
     $areaFrontName = $areaList->getFrontName($configScope->getCurrentScope());
     $this->_pathInfo = $this->_requestUri;
     /** Remove base url and area from path */
     $this->_pathInfo = preg_replace("#.*?/{$areaFrontName}/?#", '/', $this->_pathInfo);
     /** Remove GET parameters from path */
     $this->_pathInfo = preg_replace('#\\?.*#', '', $this->_pathInfo);
 }
Beispiel #6
0
 /**
  * Modify pathInfo: strip down the front name and query parameters.
  *
  * @param AreaList $areaList
  * @param ScopeInterface $configScope
  * @param CookieReaderInterface $cookieReader
  * @param null|string|\Zend_Uri $uri
  */
 public function __construct(CookieReaderInterface $cookieReader, AreaList $areaList, ScopeInterface $configScope, $uri = null)
 {
     parent::__construct($cookieReader, $uri);
     $pathInfo = $this->getRequestUri();
     /** Remove base url and area from path */
     $areaFrontName = $areaList->getFrontName($configScope->getCurrentScope());
     $pathInfo = preg_replace("#.*?/{$areaFrontName}/?#", '/', $pathInfo);
     /** Remove GET parameters from path */
     $pathInfo = preg_replace('#\\?.*#', '', $pathInfo);
     $this->setPathInfo($pathInfo);
 }
 /**
  * Prepare message
  *
  * @return $this
  * @throws \Zend_Mail_Exception
  */
 protected function prepareMessage()
 {
     $template = $this->getTemplate();
     $types = [TemplateTypesInterface::TYPE_TEXT => MessageInterface::TYPE_TEXT, TemplateTypesInterface::TYPE_HTML => MessageInterface::TYPE_HTML];
     // Bugfix for not translated cron scheduled mails
     $areaObject = $this->areaList->getArea($template->getDesignConfig()->getArea());
     $areaObject->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     $body = $template->processTemplate();
     $this->message->setMessageType($types[$template->getType()])->setBody($body)->setSubject($template->getSubject());
     return $this;
 }
Beispiel #8
0
 /**
  * {@inheritdoc}
  */
 public function doOperation()
 {
     if (empty($this->data)) {
         return;
     }
     $definitionsCollection = new DefinitionsCollection();
     foreach ($this->data as $path) {
         $definitionsCollection->addCollection($this->getDefinitionsCollection($path));
     }
     $areaCodes = array_merge([App\Area::AREA_GLOBAL], $this->areaList->getCodes());
     foreach ($areaCodes as $areaCode) {
         $this->configWriter->write($areaCode, $this->configReader->generateCachePerScope($definitionsCollection, $areaCode));
     }
 }
 /**
  * Transform content and/or content type for the specified preprocessing chain object
  *
  * @param Chain $chain
  * @return void
  */
 public function process(Chain $chain)
 {
     if ($this->config->isEmbeddedStrategy()) {
         $context = $chain->getAsset()->getContext();
         $areaCode = \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE;
         if ($context instanceof FallbackContext) {
             $areaCode = $context->getAreaCode();
             $this->translate->setLocale($context->getLocale());
         }
         $area = $this->areaList->getArea($areaCode);
         $area->load(\Magento\Framework\App\Area::PART_TRANSLATE);
         $chain->setContent($this->translate($chain->getContent()));
     }
 }
Beispiel #10
0
 /**
  * {@inheritdoc}
  */
 public function doOperation()
 {
     if (empty($this->data)) {
         return;
     }
     $this->interceptionConfigurationBuilder->addAreaCode(App\Area::AREA_GLOBAL);
     foreach ($this->areaList->getCodes() as $areaCode) {
         $this->interceptionConfigurationBuilder->addAreaCode($areaCode);
     }
     $generatorIo = new \Magento\Framework\Code\Generator\Io(new \Magento\Framework\Filesystem\Driver\File(), $this->data);
     $generator = new \Magento\Tools\Di\Code\Generator($generatorIo, [Interceptor::ENTITY_TYPE => 'Magento\\Tools\\Di\\Code\\Generator\\Interceptor']);
     $configuration = $this->interceptionConfigurationBuilder->getInterceptionConfiguration(get_declared_classes());
     $generator->generateList($configuration);
 }
Beispiel #11
0
 /**
  * Handle REST request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         $this->checkPermissions();
         $route = $this->getCurrentRoute();
         if ($route->isSecure() && !$this->_request->isSecure()) {
             throw new \Magento\Webapi\Exception(__('Operation allowed only in HTTPS'));
         }
         /** @var array $inputData */
         $inputData = $this->_request->getRequestData();
         $serviceMethodName = $route->getServiceMethod();
         $serviceClassName = $route->getServiceClass();
         $inputData = $this->overrideParams($inputData, $route->getParameters());
         $inputParams = $this->_serializer->getInputData($serviceClassName, $serviceMethodName, $inputData);
         $service = $this->_objectManager->get($serviceClassName);
         /** @var \Magento\Framework\Service\Data\AbstractExtensibleObject $outputData */
         $outputData = call_user_func_array([$service, $serviceMethodName], $inputParams);
         $outputData = $this->dataObjectConverter->processServiceOutput($outputData);
         if ($this->_request->getParam(PartialResponseProcessor::FILTER_PARAMETER) && is_array($outputData)) {
             $outputData = $this->partialResponseProcessor->filter($outputData);
         }
         $this->_response->prepareResponse($outputData);
     } catch (\Exception $e) {
         $maskedException = $this->_errorProcessor->maskException($e);
         $this->_response->setException($maskedException);
     }
     return $this->_response;
 }
Beispiel #12
0
 /**
  * Dispatch SOAP request.
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         if ($this->_isWsdlRequest()) {
             $this->validateWsdlRequest();
             $responseBody = $this->_wsdlGenerator->generate($this->_request->getRequestedServices(), $this->_request->getScheme(), $this->_request->getHttpHost(), $this->_soapServer->generateUri());
             $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST);
             $this->_setResponseBody($responseBody);
         } else {
             if ($this->_isWsdlListRequest()) {
                 $servicesList = [];
                 foreach (array_keys($this->_wsdlGenerator->getListOfServices()) as $serviceName) {
                     $servicesList[$serviceName]['wsdl_endpoint'] = $this->_soapServer->getEndpointUri() . '?' . \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL . '&services=' . $serviceName;
                 }
                 $renderer = $this->rendererFactory->get();
                 $this->_setResponseContentType($renderer->getMimeType());
                 $this->_setResponseBody($renderer->render($servicesList));
             } else {
                 $this->_soapServer->handle();
             }
         }
     } catch (\Exception $e) {
         $this->_prepareErrorResponse($e);
     }
     return $this->_response;
 }
Beispiel #13
0
 /**
  * Transform content and/or content type for the specified preprocessing chain object
  *
  * @param Chain $chain
  * @return void
  */
 public function process(Chain $chain)
 {
     if ($this->isDictionaryPath($chain->getTargetAssetPath())) {
         $context = $chain->getAsset()->getContext();
         $themePath = '*/*';
         $areaCode = \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE;
         if ($context instanceof FallbackContext) {
             $themePath = $context->getThemePath();
             $areaCode = $context->getAreaCode();
             $this->translate->setLocale($context->getLocale());
         }
         $area = $this->areaList->getArea($areaCode);
         $area->load(\Magento\Framework\App\Area::PART_TRANSLATE);
         $chain->setContent(json_encode($this->dataProvider->getData($themePath)));
         $chain->setContentType('json');
     }
 }
Beispiel #14
0
 /**
  * Fetch routes from configs by area code and router id
  *
  * @param string $scope
  * @return array
  */
 protected function _getRoutes($scope = null)
 {
     $scope = $scope ?: $this->_configScope->getCurrentScope();
     if (isset($this->_routes[$scope])) {
         return $this->_routes[$scope];
     }
     $cacheId = $scope . '::' . $this->_cacheId;
     $cachedRoutes = unserialize($this->_cache->load($cacheId));
     if (is_array($cachedRoutes)) {
         $this->_routes[$scope] = $cachedRoutes;
         return $cachedRoutes;
     }
     $routers = $this->_reader->read($scope);
     $routes = $routers[$this->_areaList->getDefaultRouter($scope)]['routes'];
     $this->_cache->save(serialize($routes), $cacheId);
     $this->_routes[$scope] = $routes;
     return $routes;
 }
Beispiel #15
0
 /**
  * Create an admin user
  *
  * @param array $data
  * @return void
  */
 public function createAdministrator($data)
 {
     // \Magento\User\Model\User belongs to adminhtml area
     $this->_areaList->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)->load(\Magento\Framework\App\AreaInterface::PART_CONFIG);
     /** @var $user \Magento\User\Model\User */
     $user = $this->_userModelFactory->create();
     $user->loadByUsername($data['username']);
     // setForceNewPassword(true) - run-time flag to force saving of the entered password
     $user->addData($data)->setForceNewPassword(true)->setRoleId(1)->save();
     $this->_refreshConfig();
 }
Beispiel #16
0
 /**
  * Run application
  *
  * @return ResponseInterface
  */
 public function launch()
 {
     $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName());
     $this->_state->setAreaCode($areaCode);
     $this->_objectManager->configure($this->_configLoader->load($areaCode));
     $this->_response = $this->_objectManager->get('Magento\\Framework\\App\\FrontControllerInterface')->dispatch($this->_request);
     // This event gives possibility to launch something before sending output (allow cookie setting)
     $eventParams = array('request' => $this->_request, 'response' => $this->_response);
     $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams);
     return $this->_response;
 }
 public function testGetData()
 {
     $asset = $this->getMock('Magento\\Framework\\View\\Asset\\File', [], [], '', false);
     $chain = $this->getMock('Magento\\Framework\\View\\Asset\\PreProcessor\\Chain', [], [], '', false);
     $context = $this->getMock('Magento\\Framework\\View\\Asset\\File\\FallbackContext', [], [], '', false);
     $originalContent = 'content$.mage.__("hello1")content';
     $translatedContent = 'content"hello1"content';
     $patterns = ['~\\$\\.mage\\.__\\([\'|\\"](.+?)[\'|\\"]\\)~'];
     $areaCode = 'adminhtml';
     $area = $this->getMock('Magento\\Framework\\App\\Area', [], [], '', false);
     $chain->expects($this->once())->method('getAsset')->willReturn($asset);
     $asset->expects($this->once())->method('getContext')->willReturn($context);
     $context->expects($this->once())->method('getAreaCode')->willReturn($areaCode);
     $this->configMock->expects($this->once())->method('isEmbeddedStrategy')->willReturn(true);
     $chain->expects($this->once())->method('getContent')->willReturn($originalContent);
     $this->configMock->expects($this->once())->method('getPatterns')->willReturn($patterns);
     $this->areaListMock->expects($this->once())->method('getArea')->with($areaCode)->willReturn($area);
     $chain->expects($this->once())->method('setContent')->with($translatedContent);
     $this->model->process($chain);
 }
Beispiel #18
0
 /**
  * Observer for controller_front_send_response_before event fired in lib/internal/Magento/Framework/App/Http.php.
  *
  * $eventParams = ['request' => $this->_request, 'response' => $this->_response];
  *
  * request => Magento\Framework\App\Request\Http
  * response => Magento\Framework\Webapi\Rest\Response\Proxy
  *
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /* @var $request \Magento\Framework\App\Request\Http */
     $request = $observer->getEvent()->getRequest();
     $areaCode = $this->areaList->getCodeByFrontName($request->getFrontName());
     /**
      * Stop execution if module is not active
      * or if the current request falls within excluded areas
      * or if the current request falls within excluded actions
      */
     if (!$this->helper->isFoggylineSentinelActive() or in_array($areaCode, $this->helper->getExcludeAreas()) or in_array($request->getFullActionName(), $this->helper->getExcludeActions())) {
         //return $this;
     }
     /* @var $log \Foggyline\Sentinel\Model\AccessLog */
     $log = $this->log->create();
     $log->setRequestId($this->helper->getHttpRequestUniqueId());
     if ($this->authSession && $this->authSession->getUser()) {
         $user = $this->authSession->getUser();
         $log->setUserId($user->getId());
         $log->setUserUsername($user->getUserName());
         $log->setUserEmail($user->getEmail());
         $log->setUserName($user->getName());
     }
     $log->setActionName($request->getActionName());
     $log->setFullActionName($request->getFullActionName());
     $log->setClientIp($request->getClientIp());
     $log->setRequestString($request->getRequestString());
     $log->setRequestMethod($request->getMethod());
     $log->setHttpGetParams($_GET);
     $log->setHttpPostParams($_POST);
     $log->setHttpFilesParams($_FILES);
     $log->setModuleName($request->getModuleName());
     $log->setControllerModule($request->getControllerModule());
     $log->setArea($areaCode);
     try {
         $log->save();
     } catch (\Exception $e) {
         $this->logger->critical($e);
     }
     return $this;
 }
 public function testGetData()
 {
     $chain = $this->getMock('Magento\\Framework\\View\\Asset\\PreProcessor\\Chain', [], [], '', false);
     $asset = $this->getMock('Magento\\Framework\\View\\Asset\\File', [], [], '', false);
     $context = $this->getMock('Magento\\Framework\\View\\Asset\\File\\FallbackContext', [], [], '', false);
     $fileName = 'js-translation.json';
     $targetPath = 'path/js-translation.json';
     $themePath = '*/*';
     $dictionary = ['hello' => 'bonjour'];
     $areaCode = 'adminhtml';
     $area = $this->getMock('Magento\\Framework\\App\\Area', [], [], '', false);
     $chain->expects($this->once())->method('getTargetAssetPath')->willReturn($targetPath);
     $this->configMock->expects($this->once())->method('getDictionaryFileName')->willReturn($fileName);
     $chain->expects($this->once())->method('getAsset')->willReturn($asset);
     $asset->expects($this->once())->method('getContext')->willReturn($context);
     $context->expects($this->once())->method('getThemePath')->willReturn($themePath);
     $context->expects($this->once())->method('getAreaCode')->willReturn($areaCode);
     $this->areaListMock->expects($this->once())->method('getArea')->with($areaCode)->willReturn($area);
     $this->dataProviderMock->expects($this->once())->method('getData')->with($themePath)->willReturn($dictionary);
     $chain->expects($this->once())->method('setContent')->with(json_encode($dictionary));
     $chain->expects($this->once())->method('setContentType')->with('json');
     $this->model->process($chain);
 }
Beispiel #20
0
 public function testGetFrontNameWhenAreaCodeAndFrontNameArentSet()
 {
     $model = new \Magento\Framework\App\AreaList($this->objectManagerMock, $this->_resolverFactory);
     $code = 'testAreaCode';
     $this->assertNull($model->getCodeByFrontName($code));
     $this->assertNull($model->getFrontName($code));
     $this->assertSame([], $model->getCodes());
     $this->assertNull($model->getDefaultRouter($code));
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\App\\AreaInterface', ['areaCode' => $code])->willReturn('test');
     $this->assertSame('test', $model->getArea($code));
 }
Beispiel #21
0
 /**
  * Handle REST request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         if ($this->isSchemaRequest()) {
             $this->processSchemaRequest();
         } else {
             $this->processApiRequest();
         }
     } catch (\Exception $e) {
         $maskedException = $this->_errorProcessor->maskException($e);
         $this->_response->setException($maskedException);
     }
     return $this->_response;
 }
Beispiel #22
0
 /**
  * Dispatch SOAP request.
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         if ($this->_isWsdlRequest()) {
             $responseBody = $this->_wsdlGenerator->generate($this->_request->getRequestedServices(), $this->_soapServer->generateUri());
             $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST);
             $this->_setResponseBody($responseBody);
         } else {
             $this->_soapServer->handle();
         }
     } catch (\Exception $e) {
         $this->_prepareErrorResponse($e);
     }
     return $this->_response;
 }
Beispiel #23
0
 /**
  * Run application
  *
  * @return ResponseInterface
  */
 public function launch()
 {
     try {
         $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName());
         $this->_state->setAreaCode($areaCode);
         $this->_objectManager->configure($this->_configLoader->load($areaCode));
         $this->_response = $this->_objectManager->get('Magento\\Framework\\App\\FrontControllerInterface')->dispatch($this->_request);
         // This event gives possibility to launch something before sending output (allow cookie setting)
         $eventParams = array('request' => $this->_request, 'response' => $this->_response);
         $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams);
     } catch (\Exception $exception) {
         $message = $exception->getMessage() . "\n";
         try {
             if ($this->_state->getMode() == State::MODE_DEVELOPER) {
                 $message .= '<pre>';
                 $message .= $exception->getMessage() . "\n\n";
                 $message .= $exception->getTraceAsString();
                 $message .= '</pre>';
             } else {
                 $reportData = array($exception->getMessage(), $exception->getTraceAsString());
                 // retrieve server data
                 if (isset($_SERVER)) {
                     if (isset($_SERVER['REQUEST_URI'])) {
                         $reportData['url'] = $_SERVER['REQUEST_URI'];
                     }
                     if (isset($_SERVER['SCRIPT_NAME'])) {
                         $reportData['script_name'] = $_SERVER['SCRIPT_NAME'];
                     }
                 }
                 require_once $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/report.php';
                 $processor = new \Magento\Framework\Error\Processor($this->_response);
                 $processor->saveReport($reportData);
                 $this->_response = $processor->processReport();
             }
         } catch (\Exception $exception) {
             $message .= "Unknown error happened.";
         }
         $this->_response->setHttpResponseCode(500);
         $this->_response->setBody($message);
     }
     return $this->_response;
 }
Beispiel #24
0
 /**
  * Run application
  *
  * @throws \InvalidArgumentException
  * @return ResponseInterface
  */
 public function launch()
 {
     $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName());
     $this->_state->setAreaCode($areaCode);
     $this->_objectManager->configure($this->_configLoader->load($areaCode));
     /** @var \Magento\Framework\App\FrontControllerInterface $frontController */
     $frontController = $this->_objectManager->get('Magento\\Framework\\App\\FrontControllerInterface');
     $result = $frontController->dispatch($this->_request);
     // TODO: Temporary solution until all controllers return ResultInterface (MAGETWO-28359)
     if ($result instanceof ResultInterface) {
         $this->registry->register('use_page_cache_plugin', true, true);
         $result->renderResult($this->_response);
     } elseif ($result instanceof HttpInterface) {
         $this->_response = $result;
     } else {
         throw new \InvalidArgumentException('Invalid return type');
     }
     // This event gives possibility to launch something before sending output (allow cookie setting)
     $eventParams = ['request' => $this->_request, 'response' => $this->_response];
     $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams);
     return $this->_response;
 }
Beispiel #25
0
 /**
  * Dispatch SOAP request.
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         if (!$this->_appState->isInstalled()) {
             throw new WebapiException(__('Magento is not yet installed'));
         }
         if ($this->_isWsdlRequest()) {
             $responseBody = $this->_wsdlGenerator->generate($this->_request->getRequestedServices(), $this->_soapServer->generateUri());
             $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST);
             $this->_setResponseBody($responseBody);
         } else {
             $consumerId = $this->_oauthService->validateAccessToken($this->_getAccessToken());
             $this->_request->setConsumerId($consumerId);
             $this->_soapServer->handle();
         }
     } catch (\Exception $e) {
         $this->_prepareErrorResponse($e);
     }
     return $this->_response;
 }
Beispiel #26
0
 /**
  * Retrieve list of available config scopes
  *
  * @return string[]
  */
 public function getAllScopes()
 {
     $codes = $this->_areaList->getCodes();
     array_unshift($codes, $this->_defaultScope);
     return $codes;
 }
Beispiel #27
0
 public function testGetAllScopes()
 {
     $expectedBalances = array('primary', 'test_scope');
     $this->areaListMock->expects($this->once())->method('getCodes')->will($this->returnValue(array('test_scope')));
     $this->assertEquals($expectedBalances, $this->model->getAllScopes());
 }