コード例 #1
0
 /**
  * Simple trivial test to check admin registration
  *
  */
 public function testRegisterAdmin()
 {
     $adminManager = new AdminManager();
     $admin = $this->getMock('Leapt\\AdminBundle\\Admin\\AdminInterface');
     $adminManager->registerAdmin('foo', $admin);
     $this->assertInstanceOf('Leapt\\AdminBundle\\Admin\\AdminInterface', $adminManager->getAdmin('foo'));
 }
コード例 #2
0
ファイル: EntityType.php プロジェクト: leapt/admin-bundle
 /**
  * @param \Symfony\Component\Form\FormView $view
  * @param \Symfony\Component\Form\FormInterface $form
  * @param array $options
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $view->vars['allow_add'] = $options['allow_add'];
     if ($options['allow_add']) {
         $view->vars['add_url'] = $this->routingHelper->generateUrl($this->adminManager->getAdmin($options['admin']), 'modalCreate');
         $view->vars['add_label'] = $options['add_label'];
     }
 }
コード例 #3
0
ファイル: AdminLoader.php プロジェクト: leapt/admin-bundle
 /**
  * Loads a resource.
  *
  * @param mixed  $resource The resource
  * @param string $type     The resource type
  */
 public function load($resource, $type = null)
 {
     $routes = new RouteCollection();
     foreach ($this->adminManager->getAdmins() as $alias => $admin) {
         $admin->addRoutes($routes);
     }
     return $routes;
 }
コード例 #4
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param \Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter $configuration
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  * @return bool|void
  */
 public function apply(Request $request, ParamConverter $configuration)
 {
     $param = $configuration->getName();
     $alias = $request->attributes->get('alias');
     if (!$request->attributes->has('alias')) {
         throw new NotFoundHttpException('Cannot find admin without alias');
     }
     try {
         $admin = $this->adminManager->getAdmin($alias);
         $request->attributes->set($param, $admin);
         $this->registry->addActivePath($admin->getDefaultPath());
     } catch (\InvalidArgumentException $e) {
         throw new NotFoundHttpException(sprintf('Cannot find admin with alias "%s"', $alias));
     }
 }
コード例 #5
0
ファイル: Logger.php プロジェクト: leapt/admin-bundle
 /**
  * Get logs corresponding to the provided criteria
  *
  * @param $entity
  * @param string|array $action
  * @return array
  */
 public function getLogsForEntity($entity, $action = null)
 {
     if (null !== $action && !is_array($action)) {
         $action = array($action);
     }
     $admin = $this->admin->getAdminForEntity($entity);
     $qb = $this->em->createQueryBuilder()->select('l')->from($this->entityClassName, 'l')->where('l.admin = :admin')->andWhere('l.entityId = :entity_id')->setParameter('admin', $admin->getAlias())->setParameter('entity_id', $entity->getId());
     if (null !== $action) {
         $qb->andWhere($qb->expr()->in('l.action', ':action'))->setParameter('action', $action);
     }
     return $qb->getQuery()->getResult();
 }
コード例 #6
0
ファイル: AdminExtension.php プロジェクト: leapt/admin-bundle
 /**
  * @return string
  */
 public function getDefaultTranslationDomain()
 {
     return $this->adminManager->getDefaultTranslationDomain();
 }