public function setupRenderer()
 {
     if (!$this->helpers) {
         $this->setupHelpers();
     }
     $this->renderer = $renderer = new RestfulJsonRenderer();
     $renderer->setHelperPluginManager($this->helpers);
 }
Example #2
0
 /**
  * Retrieve Service Manager configuration
  *
  * Defines PhlyRestfully\RestfulJsonStrategy service factory.
  *
  * @return array
  */
 public function getServiceConfig()
 {
     return array('factories' => array('PhlyRestfully\\ApiProblemListener' => function ($services) {
         $config = array();
         if ($services->has('config')) {
             $config = $services->get('config');
         }
         $filter = null;
         if (isset($config['phlyrestfully']) && isset($config['phlyrestfully']['accept_filter'])) {
             $filter = $config['phlyrestfully']['accept_filter'];
         }
         return new Listener\ApiProblemListener($filter);
     }, 'PhlyRestfully\\MetadataMap' => function ($services) {
         $config = array();
         if ($services->has('config')) {
             $config = $services->get('config');
         }
         if ($services->has('HydratorManager')) {
             $hydrators = $services->get('HydratorManager');
         } else {
             $hydrators = new HydratorPluginManager();
         }
         $map = array();
         if (isset($config['phlyrestfully']) && isset($config['phlyrestfully']['metadata_map']) && is_array($config['phlyrestfully']['metadata_map'])) {
             $map = $config['phlyrestfully']['metadata_map'];
         }
         return new MetadataMap($map, $hydrators);
     }, 'PhlyRestfully\\JsonRenderer' => function ($services) {
         $helpers = $services->get('ViewHelperManager');
         $config = $services->get('Config');
         $displayExceptions = false;
         if (isset($config['view_manager']) && isset($config['view_manager']['display_exceptions'])) {
             $displayExceptions = (bool) $config['view_manager']['display_exceptions'];
         }
         $renderer = new View\RestfulJsonRenderer();
         $renderer->setHelperPluginManager($helpers);
         $renderer->setDisplayExceptions($displayExceptions);
         return $renderer;
     }, 'PhlyRestfully\\RestfulJsonStrategy' => function ($services) {
         $renderer = $services->get('PhlyRestfully\\JsonRenderer');
         return new View\RestfulJsonStrategy($renderer);
     }));
 }