Example #1
0
 /**
  * Initialize the provided component by setting up routes for it in Silex.
  *
  * @param ComponentAbstract $component
  */
 public function initComponent(ComponentAbstract $component)
 {
     $this->application->match('/admin/' . $component->getName() . '/{page}', function ($page) use($component) {
         /* @var $component ComponentAbstract */
         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);
     });
 }