Exemple #1
0
 /**
  * Initialize the provided component by setting up routes for it in Silex.
  *
  * @param ComponentInterface $component
  */
 public function initComponent(ComponentInterface $component)
 {
     $this->application->match('/admin/' . $component->getName() . '/{page}', function ($page) use($component) {
         /* @var $component ComponentInterface */
         foreach ($this->components as $preDispatchComponent) {
             $preDispatchComponent->preDispatch();
         }
         return $component->dispatchPage($page);
     });
     $this->application->get('/admin/' . $component->getName(), function () use($component) {
         $url = '/admin/' . $component->getName() . '/index';
         if (Pimple::hasResource('url-filter')) {
             /* @var $filter callable */
             $filter = Pimple::getResource('url-filter');
             $url = $filter($url);
         }
         return $this->application->redirect($url);
     });
 }