/** * {@inheritDoc} */ public function createService(ServiceLocatorInterface $serviceLocator) { $listener = new ContentTypeFilterListener(); $config = array(); if ($serviceLocator->has('Config')) { $moduleConfig = false; $appConfig = $serviceLocator->get('Config'); if (isset($appConfig['zf-content-negotiation']) && is_array($appConfig['zf-content-negotiation']) ) { $moduleConfig = $appConfig['zf-content-negotiation']; } if ($moduleConfig && isset($moduleConfig['content_type_whitelist']) && is_array($moduleConfig['content_type_whitelist']) ) { $config = $moduleConfig['content_type_whitelist']; } } if (!empty($config)) { $listener->setConfig($config); } return $listener; }
/** * @param ContainerInterface $container * @return ContentTypeFilterListener */ public function __invoke(ContainerInterface $container) { $listener = new ContentTypeFilterListener(); $options = $container->get(ContentNegotiationOptions::class); $listener->setConfig($options->getContentTypeWhitelist()); return $listener; }
/** * {@inheritDoc} */ public function createService(ServiceLocatorInterface $serviceLocator) { $listener = new ContentTypeFilterListener(); /* @var $options \ZF\ContentNegotiation\ContentNegotiationOptions */ $options = $serviceLocator->get('ZF\\ContentNegotiation\\ContentNegotiationOptions'); $listener->setConfig($options->getContentTypeWhitelist()); return $listener; }