Example #1
0
 /**
  * gives access to the singleton
  * @return Amfphp_Core_PluginManager
  */
 public static function getInstance()
 {
     if (self::$instance == NULL) {
         self::$instance = new Amfphp_Core_PluginManager();
     }
     return self::$instance;
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function service()
 {
     $filterManager = \Amfphp_Core_FilterManager::getInstance();
     $deserializedResponse = null;
     $defaultHandler = null;
     try {
         \Amfphp_Core_PluginManager::getInstance()->loadPlugins($this->config->pluginsFolders, $this->config->pluginsConfig, $this->config->sharedConfig, $this->config->disabledPlugins);
         $defaultHandler = new Handler($this->config->sharedConfig, $this->pixie);
         //filter service folder paths
         $this->config->serviceFolders = $filterManager->callFilters(self::FILTER_SERVICE_FOLDER_PATHS, $this->config->serviceFolders);
         //filter service names 2 class find info
         $this->config->serviceNames2ClassFindInfo = $filterManager->callFilters(self::FILTER_SERVICE_NAMES_2_CLASS_FIND_INFO, $this->config->serviceNames2ClassFindInfo);
         //filter serialized request
         $this->rawInputData = $filterManager->callFilters(self::FILTER_SERIALIZED_REQUEST, $this->rawInputData);
         //filter deserializer
         $deserializer = $filterManager->callFilters(self::FILTER_DESERIALIZER, $defaultHandler, $this->contentType);
         //deserialize
         $deserializedRequest = $deserializer->deserialize($this->getData, $this->postData, $this->rawInputData);
         //filter deserialized request
         $deserializedRequest = $filterManager->callFilters(self::FILTER_DESERIALIZED_REQUEST, $deserializedRequest);
         //create service router
         $serviceRouter = new \Amfphp_Core_Common_ServiceRouter($this->config->serviceFolders, $this->config->serviceNames2ClassFindInfo, $this->config->checkArgumentCount);
         //filter deserialized request handler
         /** @var Handler $deserializedRequestHandler */
         $deserializedRequestHandler = $filterManager->callFilters(self::FILTER_DESERIALIZED_REQUEST_HANDLER, $defaultHandler, $this->contentType);
         //handle request
         $deserializedResponse = $deserializedRequestHandler->handleDeserializedRequest($deserializedRequest, $serviceRouter);
     } catch (\Exception $exception) {
         //filter exception handler
         $exceptionHandler = $filterManager->callFilters(self::FILTER_EXCEPTION_HANDLER, $defaultHandler, $this->contentType);
         //handle exception
         $deserializedResponse = $exceptionHandler->handleException($exception);
     }
     //filter deserialized response
     $deserializedResponse = $filterManager->callFilters(self::FILTER_DESERIALIZED_RESPONSE, $deserializedResponse);
     //filter serializer
     $serializer = $filterManager->callFilters(self::FILTER_SERIALIZER, $defaultHandler, $this->contentType);
     //serialize
     $this->rawOutputData = $serializer->serialize($deserializedResponse);
     //filter serialized response
     $this->rawOutputData = $filterManager->callFilters(self::FILTER_SERIALIZED_RESPONSE, $this->rawOutputData);
     return $this->rawOutputData;
 }
Example #3
0
 /**
  * The service method runs the gateway application.  It deserializes the raw data passed into the constructor as an Amfphp_Core_Amf_Packet, handles the headers,
  * handles the messages as requests to services, and returns the responses from the services
  * It does not however handle output headers, gzip compression, etc. that is the job of the calling script
  *
  * @return <String> the serialized amf packet containg the service responses
  */
 public function service()
 {
     $filterManager = Amfphp_Core_FilterManager::getInstance();
     $defaultHandler = new Amfphp_Core_Amf_Handler();
     $deserializedResponse = null;
     try {
         Amfphp_Core_PluginManager::getInstance()->loadPlugins($this->config->pluginsFolder, $this->config->pluginsConfig, $this->config->disabledPlugins);
         //call filter for filtering serialized incoming packet
         $this->rawInputData = $filterManager->callFilters(self::FILTER_SERIALIZED_REQUEST, $this->rawInputData);
         //call filter to get the deserializer
         $deserializer = $filterManager->callFilters(self::FILTER_DESERIALIZER, $defaultHandler, $this->contentType);
         //deserialize
         $deserializedRequest = $deserializer->deserialize($this->getData, $this->postData, $this->rawInputData);
         //call filter for filtering deserialized request
         $deserializedRequest = $filterManager->callFilters(self::FILTER_DESERIALIZED_REQUEST, $deserializedRequest);
         //create service router
         $serviceRouter = new Amfphp_Core_Common_ServiceRouter($this->config->serviceFolderPaths, $this->config->serviceNames2ClassFindInfo);
         //call filter to get the deserialized request handler
         $deserializedRequestHandler = $filterManager->callFilters(self::FILTER_DESERIALIZED_REQUEST_HANDLER, $defaultHandler, $this->contentType);
         //handle request
         $deserializedResponse = $deserializedRequestHandler->handleDeserializedRequest($deserializedRequest, $serviceRouter);
         //call filter for filtering the deserialized response
         $deserializedResponse = $filterManager->callFilters(self::FILTER_DESERIALIZED_RESPONSE, $deserializedResponse);
     } catch (Exception $exception) {
         //call filter to get the exception handler
         $exceptionHandler = $filterManager->callFilters(self::FILTER_EXCEPTION_HANDLER, $defaultHandler, $this->contentType);
         //handle exception
         $deserializedResponse = $exceptionHandler->handleException($exception);
     }
     //call filter to get the serializer
     $serializer = $filterManager->callFilters(self::FILTER_SERIALIZER, $defaultHandler, $this->contentType);
     //serialize
     $this->rawOutputData = $serializer->serialize($deserializedResponse);
     //call filter for filtering the serialized response packet
     $this->rawOutputData = $filterManager->callFilters(self::FILTER_SERIALIZED_RESPONSE, $this->rawOutputData);
     return $this->rawOutputData;
 }
 /**
  * test bad folder
  * @expectedException Amfphp_Core_Exception
  */
 public function testBadFolder()
 {
     $this->pluginManager->loadPlugins(array('bla'));
 }