/** * 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(); }
/** * @param $namespace * @return \Leapt\AdminBundle\Admin\ContentAdmin */ public function getAdminForEntityName($namespace) { $entity = new $namespace(); $admin = $this->adminManager->getAdminForEntity($entity); return $admin; }