true, ]; public const MARKING_STORE = [ 'type' => 'single_state', 'arguments' => ['currentPlace'], ]; public function __construct( EntityManagerInterface $entityManager ) { $this->entityManager = $entityManager; } /** * @param Configuration $Config */ public function create(Configuration $Config): Configuration { $this->entityManager->persist($Config); $this->entityManager->flush(); return $Config; } /** * @param string $module * * @throws NonUniqueResultException * * @return mixed */ public function list() { return $this->entityManager ->createQueryBuilder() ->select('c.id', 'c.name', 'c.module') ->from(Configuration::class, 'c') ->where('c.deletedAt is null') ->getQuery() ->getResult() ; } /** * @return mixed */ public function getConfigs() { return $this->entityManager ->createQueryBuilder() ->select('c') ->from(Configuration::class, 'c') ->innerJoin('c.transitions', 't') ->innerJoin('c.places', 'p') ->where('c.deletedAt is null') ->getQuery() ->getResult() ; } /** * @throws NonUniqueResultException * * @return mixed */ public function findByModule(string $module) { return $this->entityManager ->createQueryBuilder() ->select('c') ->from(Configuration::class, 'c') ->where('c.module = :query') ->andWhere('c.deletedAt is null') ->setParameter('query', $module) ->getQuery() ->getOneOrNullResult() ; } /** * @param string $module * * @throws NonUniqueResultException * * @return mixed */ public function findById(int $id) { return $this->entityManager ->createQueryBuilder() ->select('c') ->from(Configuration::class, 'c') ->where('c.id = :id') ->setParameter('id', $id) ->getQuery() ->getOneOrNullResult() ; } public function findByPlace(string $place) { return $this->entityManager ->createQueryBuilder() ->select('c') ->from(Configuration::class, 'c') ->innerJoin('c.places', 'p') ->where('p.keyInternal = :place') ->andWhere('c.deletedAt is null') ->setParameter('place', $place) ->getQuery() ->getOneOrNullResult() ; } /** * @throws NonUniqueResultException * * @return mixed */ public function findAllByModule(string $module) { return $this->entityManager ->createQueryBuilder() ->select('c.id', 'c.name') ->from(Configuration::class, 'c') ->where('c.module = :query') ->andWhere('c.deletedAt is null') ->setParameter('query', $module) ->getQuery() ->getResult() ; } public function findIdByPlace(string $place) { return $this->entityManager ->createQueryBuilder() ->select('c.id') ->from(Configuration::class, 'c') ->innerJoin('c.places', 'p') ->where('p.key = :place') ->andWhere('c.deletedAt is null') ->setParameter('place', $place) ->getQuery() ->getOneOrNullResult() ; } public function removeWorkflow(Configuration $config): bool { try{ $this->entityManager->remove($config); $this->entityManager->flush(); return true; } catch(Exception $e){ return false; } } }