Exemplo n.º 1
0
 /**
  * @param Context $context
  * @param Backend\DataStore|DataStore $dataStore
  * @param DefaultIntegration $integrationContext
  * @param JsonFactory $resultJsonFactory
  * @param LoggerInterface $logger
  * @param Backend\MagentoAPI|MagentoAPI $magentoAPI
  * @param RequestRouter $requestRouter
  */
 public function __construct(Context $context, DataStore $dataStore, DefaultIntegration $integrationContext, JsonFactory $resultJsonFactory, LoggerInterface $logger, MagentoAPI $magentoAPI, RequestRouter $requestRouter)
 {
     $this->dataStore = $dataStore;
     $this->integrationContext = $integrationContext;
     $this->logger = $logger;
     $this->magentoAPI = $magentoAPI;
     $this->resultJsonFactory = $resultJsonFactory;
     $this->requestRouter = $requestRouter;
     $this->requestRouter->addRouter('\\CloudFlare\\Plugin\\Backend\\ClientAPI', ClientRoutes::$routes);
     $this->requestRouter->addRouter('\\CF\\API\\Plugin', PluginRoutes::getRoutes(\CF\API\PluginRoutes::$routes));
     // php://input can only be read once
     $decodedJson = json_decode(file_get_contents('php://input'), true);
     if (json_last_error() !== 0) {
         $this->logger->error("Error decoding JSON: " . json_last_error_msg());
     }
     $this->jsonBody = $decodedJson;
     parent::__construct($context);
 }
 public function testGetPluginRoutesUpdatesRouteClass()
 {
     $routes = array('account' => array('class' => 'Any/Other/Class'));
     $newRoutes = PluginRoutes::getRoutes($routes);
     $this->assertEquals('\\CloudFlare\\Plugin\\Backend\\PluginActions', $newRoutes['account']['class']);
 }