Exemple #1
0
 public function testSettersViaConstruct()
 {
     $route = new Route(array('service' => 'app.test'));
     $this->assertSame('', $route->getPath());
     $this->assertSame('app.test', $route->getService());
     $route = new Route(array('service' => 'app.test', 'path' => '/test/'));
     $this->assertSame('/test/', $route->getPath());
     $this->assertSame('app.test', $route->getService());
 }
 /**
  * @param RouteCollection $collection
  * @param $annot
  * @param $globals
  * @param \ReflectionClass $class
  * @param \ReflectionMethod $method
  */
 protected function addRoute(RouteCollection $collection, $annot, $globals, \ReflectionClass $class, \ReflectionMethod $method)
 {
     $i18n = isset($annot->data['i18n']) ? $annot->data['i18n'] : true;
     unset($annot->data['i18n']);
     foreach ($this->registry->getRegisteredLocales() as $locale) {
         $i18nAnnot = new Route($annot->data);
         $i18nGlobals = $globals;
         if ($i18n) {
             $i18nAnnot->setName($this->helper->alterName($i18nAnnot->getName(), $locale));
             $i18nAnnot->setPath($this->helper->alterPath($i18nAnnot->getPath(), $locale));
             $i18nAnnot->setDefaults($this->helper->alterDefaults($i18nAnnot->getDefaults(), $locale));
             if (isset($i18nGlobals['path']) && !empty($i18nGlobals['path'])) {
                 $i18nGlobals['path'] = '/' . $locale . '/' . ltrim($this->helper->alterPath($i18nGlobals['path'], $locale), '/');
             } else {
                 $i18nGlobals['path'] = '/' . $locale;
             }
         }
         parent::addRoute($collection, $i18nAnnot, $i18nGlobals, $class, $method);
     }
 }