protected function createWorkflowBindEntity($entityId, $entityClass) { $result = new WorkflowBindEntity(); $result->setEntityId($entityId); $result->setEntityClass($entityClass); return $result; }
/** * @param array $entitiesToBind * @return WorkflowBindEntity[] */ protected function createBindEntities(array $entitiesToBind) { $result = array(); foreach ($entitiesToBind as $entity) { if ($entity) { $bindEntity = new WorkflowBindEntity(); $bindEntity->setEntityClass($this->doctrineHelper->getEntityClass($entity)); $bindEntity->setEntityId($this->doctrineHelper->getEntityIdentifier($entity)); $result[] = $bindEntity; } } return $result; }
/** * Get workflow items associated with entity. * * @param string $entityClass * @param string|array $entityIdentifier * @param string|null $workflowName * @param string|null $workflowType * @return array */ public function findByEntityMetadata($entityClass, $entityIdentifier, $workflowName = null, $workflowType = null) { $entityIdentifierString = WorkflowBindEntity::convertIdentifiersToString($entityIdentifier); $qb = $this->getEntityManager()->createQueryBuilder()->select('wi')->from('OroWorkflowBundle:WorkflowItem', 'wi')->innerJoin('wi.bindEntities', 'wbe')->where('wbe.entityClass = :entityClass')->andWhere('wbe.entityId = :entityId')->setParameter('entityClass', $entityClass)->setParameter('entityId', $entityIdentifierString); if ($workflowName) { $qb->andWhere('wi.workflowName = :workflowName')->setParameter('workflowName', $workflowName); } if ($workflowType) { $qb->innerJoin('wi.definition', 'wd')->andWhere('wd.type = :workflowType')->setParameter('workflowType', $workflowType); } return $qb->getQuery()->getResult(); }
/** * @param string $entityClass * @param mixed $entityId * @return WorkflowBindEntity */ protected function createBindEntity($entityClass = null, $entityId = null) { $result = new WorkflowBindEntity(); if ($entityClass) { $result->setEntityClass($entityClass); } if ($entityId) { $result->setEntityId($entityId); } return $result; }
/** * Is entity already bind to WorkflowItem * * @param WorkflowBindEntity $originalEntity * @return bool */ public function hasBindEntity(WorkflowBindEntity $originalEntity) { $bindEntities = $this->getBindEntities()->filter(function (WorkflowBindEntity $existedEntity) use($originalEntity) { return $originalEntity->hasSameEntity($existedEntity); }); return $bindEntities->count() > 0; }