/** * * @param Entity $entity * @throws \DomainException */ public function __construct($entity) { if (!is_object($entity)) { throw new \DomainException('Second argument passed to ' . __CLASS__ . '::aliasNotExistsInDB() must be an Entity instance'); } else { $this->em = DBDoctrine::em(); $this->entity = $entity; $this->entityName = get_class($entity); } }
/** * * @param string $entity */ public function __construct(string $entity = 'Entity\\Options') { $options = DBDoctrine::em()->find($entity, 1); $optonsMethods = get_class_methods($entity); foreach ($optonsMethods as $method) { if (!preg_match('/^(id|set)/', $method)) { $this->optionsArray[$method] = $options->{$method}(); } } }
/** * * @param \Entity $entity * @param Validator\Schema\Validation $schema */ public function __construct($entity, Validator\Schema\Validation $schema = null) { $this->entity = $entity; $this->entityName = get_class($this->entity); $this->em = DBDoctrine::em(); $this->entityController = RegistryFactory::start()->register('Entity\\Controller\\EntityController'); if (is_null($schema)) { $schema = new Validator\Schema\Validation(); } $this->validatorFactory = new Validator\ValidatorFactory($this, $schema); }
/** * Selects entity sets createQueryBuilder() */ private function createQuery() { $query = DBDoctrine::em()->createQueryBuilder()->select('c')->from($this->entityName, 'c'); $this->query = $query; }
/** * * {@inheritDoc} * * @see \DataBase\Query\IQueryBuilder::date($value) */ public function date(string $value) : IQueryController { $date = explode('/', $value); $emConfig = DBDoctrine::em()->getConfiguration(); $emConfig->addCustomDatetimeFunction('DATE_FORMAT', 'DoctrineExtensions\\Query\\Mysql\\DateFormat'); $format = ""; if (array_key_exists(0, $date)) { $format = "%Y"; } if (array_key_exists(1, $date)) { $format .= "/%m"; } if (array_key_exists(2, $date)) { $format .= "/%d"; } $this->set("DATE_FORMAT(c.date, '{$format}')", $value); return $this->queryController; }
/** * * @return boolean */ public function isUserLoggedIn() : bool { return isset($this->userSession) && DBDoctrine::em()->getRepository('Entity\\Users')->findBy(['login' => $this->userSession->getLogin(), 'password' => $this->userSession->getPassword()]); }