1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace WorkflowBundle\Repository;
- use \Doctrine\ORM\EntityRepository;
- class ActionRepository extends EntityRepository
- {
- /**
- * @param string $eventName
- * @param string $objectClass
- *
- * @return array
- */
- public function findAllByEventAndObjectClass($eventName, $objectClass)
- {
- $qb = $this->createQueryBuilder('Action')
- ->andWhere('Action.event LIKE :eventName')
- ->setParameter('eventName', "%{$eventName}%")
- ->andWhere('Action.objectClass LIKE :objectClass')
- ->setParameter('objectClass', str_replace('\\', '\\\\', $objectClass))
- ;
-
- return $qb->getQuery()->getResult();
- }
- /**
- * @param string $eventName
- * @param string $workflowName
- * @param string $eventReference
- * @param string $objectClass
- *
- * @return array
- */
- public function findAllByEventAndWorkflowName($eventName, $workflowName, $eventReference, $objectClass = null)
- {
- $qb = $this->createQueryBuilder('Action')
- ->andWhere('Action.event LIKE :eventName')
- ->setParameter('eventName', "%{$eventName}%")
- ->andWhere('Action.workflowName = :workflowName')
- ->setParameter('workflowName', $workflowName)
- ->andWhere('Action.eventReference = :eventReference')
- ->setParameter('eventReference', $eventReference)
- ;
- if ($objectClass) {
- $qb->andWhere('Action.objectClass = :objectClass')
- ->setParameter('objectClass', $objectClass);
- }
-
- return $qb->getQuery()->getResult();
- }
-
- /**
- * @param string $workflowName Nombre del workflow
- * @param string $event Nombre del event
- *
- * @return array
- */
- public function findByWorkflowAndEventRef($workflowName, $event)
- {
- $actions = $this->createQueryBuilder('Action')
- ->andWhere('Action.eventReference = :eventReference')
- ->setParameter('eventReference', $eventReference)
- ->getQuery()->getResult();
- $return = [];
- foreach ($actions as $action) {
- $workflows = array_map('trim', explode(',', $action->getWorkflowName()));
- if (in_array($workflowName, $workflows)) {
- $return[] = $action;
- }
- }
-
- return $return;
- }
- }
|