示例#1
0
 /**
  * @param  ServiceLocatorInterface $serviceLocator
  * @return Detector
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     $config = $config['slm_locale'];
     $detector = new Detector();
     $events = $serviceLocator->get('EventManager');
     $detector->setEventManager($events);
     $this->addStrategies($detector, $config['strategies'], $serviceLocator);
     if (array_key_exists('default', $config)) {
         $detector->setDefault($config['default']);
     }
     if (array_key_exists('supported', $config)) {
         $detector->setSupported($config['supported']);
     }
     return $detector;
 }
示例#2
0
 public function setEventManager(Detector $detector, $event = null, $callback = null)
 {
     $events = new EventManager();
     if (null !== $event && null !== $callback) {
         $events->attach($event, $callback);
     }
     $detector->setEventManager($events);
     return $detector;
 }