コード例 #1
0
 /**
  * Set the passed in address object to ignore validation only when
  * we are currently saving an order and ROM Address validation is not
  * needed.
  *
  * @param  Mage_Customer_Model_Address_Abstract
  * @return self
  */
 public function allowAddressValidation(Mage_Customer_Model_Address_Abstract $address)
 {
     /** @var Mage_Core_Controller_Request_Http */
     $request = $this->app->getRequest();
     /** @var bool */
     $needValidation = $this->validator->shouldValidateAddress($address);
     // We only want to ignore address validation when we are actually creating an order.
     // The assumption is if we get to this point, then, validating the address is
     // unnecessary if it is already valid in ROM.
     if (!$needValidation && $request->getActionName() === 'saveOrder') {
         $address->setShouldIgnoreValidation(true);
     }
     return $this;
 }
コード例 #2
0
 /**
  * Determine current API type using application request (not web API request).
  *
  * @return string
  * @throws Mage_Core_Exception
  * @throws Mage_Webapi_Exception If requested API type is invalid.
  */
 public function determineApiType()
 {
     if (is_null($this->_apiType)) {
         $request = $this->_application->getRequest();
         $apiRoute = $this->_routeFactory->createRoute('Mage_Webapi_Controller_Router_Route_Webapi', Mage_Webapi_Controller_Router_Route_Webapi::getApiRoute());
         if (!($apiTypeMatch = $apiRoute->match($request, true))) {
             throw new Mage_Webapi_Exception($this->_helper->__('Request does not match any API type route.'), Mage_Webapi_Exception::HTTP_BAD_REQUEST);
         }
         $apiType = $apiTypeMatch[Mage_Webapi_Controller_Router_Route_Webapi::PARAM_API_TYPE];
         if (!in_array($apiType, $this->getListOfAvailableApiTypes())) {
             throw new Mage_Webapi_Exception($this->_helper->__('The "%s" API type is not defined.', $apiType), Mage_Webapi_Exception::HTTP_BAD_REQUEST);
         }
         $this->_apiType = $apiType;
     }
     return $this->_apiType;
 }
コード例 #3
0
ファイル: AppTest.php プロジェクト: nemphys/magento2
 public function testSetGetRequest()
 {
     $this->assertInstanceOf('Mage_Core_Controller_Request_Http', $this->_model->getRequest());
     $this->_model->setRequest(new Magento_Test_Request());
     $this->assertInstanceOf('Magento_Test_Request', $this->_model->getRequest());
 }