/** * @param string $object * @throws TypeNotValidException */ public function setObject($object) { if (!is_string($object)) { $description = ExceptionMessage::TYPE_NOT_VALID("CronExpressionValidator was not given an string\n value at the setObject function"); throw new TypeNotValidException($description, 500); } $this->expression = $object; }
/** * @param null $directoryId * @return \Doctrine\ORM\Query * @throws TypeNotValidException */ protected function getQueryByDirectory($directoryId = null) { if (!is_null($directoryId)) { if (is_numeric($directoryId)) { //query for it $queryBuilder = $this->createQueryBuilder('q'); $queryBuilder->join("q.directory", "d")->where("d.id = :dirId")->setParameter('dirId', $directoryId); return $queryBuilder->getQuery(); } throw new TypeNotValidException(ExceptionMessage::TYPE_NOT_VALID("folder id should be numeric"), 500); } return $this->createQueryBuilder('d')->where('d.directory is null')->getQuery(); }
/** * @param $mode * @return bool * @throws TypeNotValidException */ public static function validateMode($mode) { $exists = array_key_exists($mode, StrategyFactory::getModes()); if (!$exists) { $description = ExceptionMessage::TYPE_NOT_VALID("the mode given ({$mode}) was not valid"); throw new TypeNotValidException($description, 500); } return true; }
/** * @param null $directoryId * @return \Doctrine\ORM\Query * @throws NotFoundException * @throws TypeNotValidException */ protected function getQueryForRoot($directoryId = null) { // TODO: refactor this! if ($directoryId && !is_null($directoryId)) { if (is_numeric($directoryId)) { if ($this->directoryExists($directoryId)) { $queryBuilder = $this->createQueryBuilder('d'); $queryBuilder->where('d.parent = ?1')->setParameter(1, $directoryId); return $queryBuilder->getQuery(); } } throw new TypeNotValidException(ExceptionMessage::TYPE_NOT_VALID("directory id has to be numeric"), 500); } return $this->createQueryBuilder('d')->where('d.parent is null')->getQuery(); }