/**
  * @Route("/", name="easyadmin")
  */
 public function indexAction(Request $request)
 {
     if (null === $request->query->get('entity')) {
         return $this->render('demo/welcome.html.twig');
     }
     return parent::indexAction($request);
 }
 /**
  * @Route("/", name="easyadmin")
  * @Route("/", name="admin")
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Request $request)
 {
     $action = $request->query->get('action', 'list');
     if (!$this->get('security.authorization_checker')->isGranted('ROLE_' . strtoupper($action))) {
         $request->query->replace(array('action' => 'list'));
     }
     return parent::indexAction($request);
 }
Example #3
1
 /**
  * @Route("/", name="admin")
  * @Route("/", name="easyadmin")
  *
  * @param Request $request
  *
  * @return RedirectResponse|Response
  */
 public function indexAction(Request $request)
 {
     $this->request = $request;
     $r = $this->request->query;
     if (count($r) == 0) {
         $this->request->query->set('entity', $this->container->getParameter('startingPage'));
         $this->request->query->set('action', 'list');
     }
     if (!$this->hasNeededRole()) {
         throw $this->createAccessDeniedException();
     }
     $twig = $this->container->get('twig');
     foreach (['site_icon'] as $twigGlobal) {
         if ($this->container->hasParameter($twigGlobal)) {
             $twig->addGlobal("_{$twigGlobal}", $this->container->getParameter($twigGlobal));
         }
     }
     return parent::indexAction($request);
 }
 /**
  * @Route("/", name="admin")
  */
 public function indexAction(Request $request)
 {
     // if the URL doesn't include the entity name, this is the index page
     if (null === $request->query->get('entity')) {
         // define this route in any of your own controllers
         return $this->redirectToRoute('admin_dashboard');
     }
     // don't forget to add this line to serve the regular backend pages
     return parent::indexAction($request);
 }
Example #5
0
 protected function createTeachersNewForm($entity, array $entityProperties)
 {
     $editForm = parent::createEditForm($entity, $entityProperties);
     if ($entity instanceof CoursesTeachers) {
         $repository = $this->getDoctrine()->getRepository('AppBundle:CoursesUniversities');
         $products = $repository->findAll();
         $editForm->remove('university_id');
         $editForm->add('universityId', 'entity', array('class' => 'AppBundle:CoursesUniversities', 'choices' => $products));
     }
     return $editForm;
 }
 /**
  * For the Users entity, customize the FormBuilder with dynamic elements.
  *
  * {@inheritdoc}
  *
  * @see JavierEguiluz\Bundle\EasyAdminBundle\Controller\AdminController::createEntityFormBuilder
  */
 public function createUsersEntityFormBuilder($entity, $view)
 {
     $builder = parent::createEntityFormBuilder($entity, $view);
     // Add the dynamic choices for the roles
     $redirectionCodeField = $builder->get('roles');
     $type = $redirectionCodeField->getType();
     $options = $redirectionCodeField->getOptions();
     $options['choices'] = ['roles.administrator' => 'ROLE_ADMIN', 'roles.manager' => 'ROLE_MANAGER'];
     unset($options['choice_list']);
     $builder->add($redirectionCodeField->getName(), $type->getName(), $options);
     return $builder;
 }
 /**
  * The method that is executed when the user performs a 'new' action on an entity.
  *
  * @return RedirectResponse|Response
  */
 protected function newAction()
 {
     $adminResponse = parent::newAction();
     if ($adminResponse instanceof RedirectResponse) {
         $url = $this->generateUrl($this->getAdminRouteName(), $this->getUrlParameters('list'));
         $adminResponse->setTargetUrl($url);
     }
     return $adminResponse;
 }
 /**
  * Don't forget to add this route annotation!
  *
  * @Route("/easyadmin/", name="admin")
  */
 public function indexAction(Request $request)
 {
     // don't forget to add this line to serve the regular backend pages
     return parent::indexAction($request);
 }
 /**
  * Busca entra los préstamos activos.
  *
  * @param $entityClass
  * @param $searchQuery
  * @param array $searchableFields
  *
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function createRentalSearchQueryBuilder($entityClass, $searchQuery, array $searchableFields)
 {
     $queryBuilder = parent::createSearchQueryBuilder($entityClass, $searchQuery, $searchableFields);
     $queryBuilder->leftJoin('entity.user', 'user')->leftJoin('entity.locker', 'locker')->orWhere($queryBuilder->expr()->like('user.username', ':fuzzy_query'))->orWhere($queryBuilder->expr()->like('user.nic', ':fuzzy_query'))->orWhere($queryBuilder->expr()->like('locker.code', ':fuzzy_query'))->andWhere($queryBuilder->expr()->isNull('entity.returnAt'));
     return $queryBuilder;
 }