public function validarMetadatos() { try { if (is_null($this->nombre) || empty($this->nombre)) { throw new Exception("El Contenido debe tener un nombre\n"); } if (is_null($this->sinopsis) || empty($this->sinopsis)) { throw new Exception("El Contenido debe tener una sinopsis\n"); } if (is_null($this->actores) || empty($this->actores)) { throw new Exception("El Contenido debe tener los actores\n"); } $existeContenido = Contenido::GetOneByName($this->nombre); if (isset($existeContenido)) { throw new Exception("El Contenido ya existe\n"); } } catch (\Exception $e) { throw $e; } }
protected function validarNuevo() { try { if ($this->getTipo() == TipoContenido::PELICULA) { $contenido = Contenido::GetOneByName($this->nombre); if (isset($contenido)) { throw new \Exception("El Contenido ya existe\n"); } } else { // Contenido cont = Contenido.GetOne($this->nombre); $contenido = Contenido::GetOneByName($this->nombre); if (isset($contenido)) { // Collection<Contenido> capitulos = Contenido.getAll($contenido.getID()); $capitulos = Contenido::getAllByIdContenido($contenido->getID()); //for (Contenido cap : capitulos) { foreach ($capitulos as $cap) { // if ($cap->getNombreCapitulo().equalsIgnoreCase($this->getNombreCapitulo()) && $this->getID() != $contenido->getID()) { if (strcasecmp($cap->getNombreCapitulo(), $this->getNombreCapitulo()) == 0 && $this->getID() != $contenido->getID()) { throw new \Exception("El Contenido ya existe\n"); } } } } } catch (\Exception $e) { throw $e; } }