/** * Provoquer une ErrorException et/ou retourne la dernière provoquée. * * @param string $message=null Le message de l'erreur * @param int $code=0 Le code de l'erreur * @return ErrorException|null */ public function error($message = null, $code = 0) { if ($message !== null) { $error = new \ErrorException($message, $code); \ALLOCINEHELPER\AlloHelper::$_lastError = $error; throw $error; } return \ALLOCINEHELPER\AlloHelper::$_lastError; }
private function loadFilmFiche() { $oAlloHelper = new \ALLOCINEHELPER\AlloHelper(); try { //$aFilms = $oAlloHelper->search('', 1); $oFilm = $oAlloHelper->movie($this->oRequest->getParam('fiche', 'string')); $oFicheFilm = new Fichefilm(); $oFicheFilm->loadFromAllocine($oFilm); $oFicheFilm->storeIfNotExists($this->oRelease->getId()); return $oFicheFilm; } catch (ErrorException $e) { throw new Error('Aucune fiche ne correspond à l\'ID', 1163); } }
/** * Essai de scrapper un film * @return boolean Vrai si c'est un film */ private function tryMovie() { if (preg_match('#(\\W|^)[0-9]{4}(\\W|$)#i', $this->sReleaseName, $aYear)) { $aElements = preg_split('#(\\W|^)[0-9]{4}(\\W|$)#i', $this->sReleaseName); $sMovie = strtr($aElements[0], ".", " "); $oAlloHelper = new \ALLOCINEHELPER\AlloHelper(); try { $sYear = substr($aYear[0], 1, 4); $aFilms = $oAlloHelper->search($sMovie, 1); $iCode = 0; foreach ($aFilms['movie'] as $aMovie) { if ($aMovie['productionYear'] == $sYear) { $iCode = $aMovie['code']; break; } } if ($iCode === 0) { return false; } $oFilm = $oAlloHelper->movie($iCode, 'medium'); $oFicheFilm = new Fichefilm(); $oFicheFilm->loadFromAllocine($oFilm); $oFicheFilm->storeIfNotExists($this->iReleaseId); $this->iCategorieId = 1; $this->sFicheId = $iCode; $aDatas = array('id_categorie' => $this->iCategorieId); parent::update('tks_releases', $aDatas, $this->iReleaseId); return true; } catch (ErrorException $e) { return false; } return false; } }