/** * 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); }
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'); }
/** * 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; }
/** * 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())); } }
/** * 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; }
/** * 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; }
/** * 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'); } }
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)); }
/** * 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(); }
/** * 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; }
/** * 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; }
/** * 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; }