/**
  * @deprecated 
  */
 public function getAdminRoute($action, $object = null)
 {
     if ($object !== null) {
         $url = $this->core->getRouteByEntity($object, $action);
         return $url;
     }
 }
Exemplo n.º 2
0
 /**
  * Check if a named property is of specified type.
  * Call when we only know the name of property, and not the var itself
  *
  */
 public function propertyIsRelation($propertyName, $entityClass = null)
 {
     if ($entityClass === null) {
         $entityClass = $this->core->getCurrentEntityClass();
     }
     return $this->entityManager->getMetadataFactory()->getMetadataFor($entityClass)->hasAssociation($propertyName);
 }
Exemplo n.º 3
0
 /**
  * onKernelController
  * 
  * @param FilterControllerEvent $event
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     $controller = $event->getController();
     /*
      * $controller peut être une classe ou une closure. Ce n'est pas
      * courant dans Symfony2 mais ça peut arriver.
      * Si c'est une classe, elle est au format array
      */
     if (!is_array($controller)) {
         return;
     }
     if (is_subclass_of($controller[0], 'Sfs\\AdminBundle\\Controller\\AdminController')) {
         $this->core->setCurrentSlug($controller[0]->getSlug());
         $this->core->setCurrentAction();
     }
 }
Exemplo n.º 4
0
 /**
  * load
  * 
  * @param unknown $resource
  * @param mixed $type
  * 
  * @return array
  */
 public function load($resource, $type = null)
 {
     if (true === $this->loaded) {
         throw new \RuntimeException('Do not add the admin routes loader twice');
     }
     $routes = new RouteCollection();
     $adminRoutes = $this->core->getRoutes();
     $adminResources = $this->core->getAdmins();
     // Foreach admin resource, and each generic page it requires: loop and create a route
     foreach ($adminRoutes as $slug => $adminRoute) {
         foreach ($adminRoute as $action) {
             // prepare a new route
             $path = $action['path'];
             $defaults = array('_controller' => $adminResources[$slug]['service'] . ':' . $action['action']);
             $route = new Route($path, $defaults, $action['requirements']);
             $routeName = $action['route'];
             // add the new route to the route collection
             $routes->add($routeName, $route);
         }
     }
     $this->loaded = true;
     return $routes;
 }
Exemplo n.º 5
0
 /**
  * @param Request $request
  * @param Response $response
  * @param \Exception|null $exception
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $this->data = array('adminsTotal' => count($this->core->getAdmins()), 'admins' => $this->core->getAdmins(), 'routes' => $this->core->getRoutes(), 'currentAdminService' => $this->core->getCurrentAdmin()['service'], 'currentAdminSlug' => $this->core->getCurrentSlug(), 'currentEntityClass' => $this->core->getCurrentEntityClass(), 'currentAction' => $this->core->getCurrentAction());
 }