services = $serviceLocator; $this->workflow->setServiceLocator($serviceLocator); } /** * @see \Zend\ServiceManager\ServiceLocatorAwareInterface::getServiceLocator() */ public function getServiceLocator() { return $this->services; } /** * Retrieve Doctrine Entity Manager. * @return \Doctrine\ORM\EntityManager */ public function getEntityManager() { return $this->services->get('doctrine.entitymanager.orm_default'); } /** * Validate unique value for a specified field. * @param \Workspace\Utility\ServiceInputParams $contract * @return multitype:string unknown NULL */ public function fieldIsUnique(\Workspace\Utility\ServiceInputParams $contract) { if (!isset($this->entityMap[$contract->Group])) { return $contract->error( 'Invalid `Group` specified.', 'System Error.' ); } $entityName = $this->entityMap[$contract->Group]; $entry = $this->getEntityManager() ->getRepository($entityName) ->findOneBy(array($contract->Field => $contract->Value)); return is_null($entry) ? $contract->success() : $contract->error('Value already used.', 'Value already used.'); } /** * List available tasks. * @param string $state * @return array */ public function listTasks($state = 'Global') { return $this->workflow->listStateTasks($state); } }