public function fetchArticles() { try { $list = HailApi::getArticlesByTag($this->HailID); } catch (HailApiException $ex) { Debug::warningHandler(E_WARNING, $ex->getMessage(), $ex->getFile(), $ex->getLine(), $ex->getTrace()); return; } $hailIdList = array(); foreach ($list as $hailData) { // Build up Hail ID list $hailIdList[] = $hailData->id; // Check if we can find an existing item. $hailObj = HailArticle::get()->filter(array('HailID' => $hailData->id))->First(); if (!$hailObj) { $hailObj = new HailArticle(); } $hailObj->importHailData($hailData); $this->Articles()->add($hailObj); } $this->Articles()->exclude('HailID', $hailIdList)->removeAll(); }
function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) { switch ($errno) { case E_ERROR: case E_CORE_ERROR: case E_USER_ERROR: Debug::fatalHandler($errno, $errstr, $errfile, $errline, $errcontext); break; case E_WARNING: case E_CORE_WARNING: case E_USER_WARNING: Debug::warningHandler($errno, $errstr, $errfile, $errline, $errcontext); break; } }
/** * Fetch the video gallery of this article from the Hail API * * @return void */ public function fetchVideos() { try { $list = HailApi::getVideosByArticles($this->HailID); } catch (HailApiException $ex) { Debug::warningHandler(E_WARNING, $ex->getMessage(), $ex->getFile(), $ex->getLine(), $ex->getTrace()); return; } $hailIdList = array(); foreach ($list as $hailData) { // Build up Hail ID list $hailIdList[] = $hailData->id; // Check if we can find an existing item. $hailObj = HailVideo::get()->filter(array('HailID' => $hailData->id))->First(); if (!$hailObj) { $hailObj = new HailVideo(); } $hailObj->importHailData($hailData); $this->VideoGallery()->add($hailObj); } // Remove images that are no longer assign to this article if ($hailIdList) { $this->VideoGallery()->exclude('HailID', $hailIdList)->removeAll(); } else { $this->VideoGallery()->removeAll(); } }
/** * Retrieves the latest version of this object whatever it's outdated or not. * * @return HailApiObject */ public function refresh() { if ($this->ID && $this->HailID) { try { $data = HailApi::getOne(static::getObjectType(), $this->HailID); } catch (HailApiException $ex) { Debug::warningHandler(E_WARNING, $ex->getMessage(), $ex->getFile(), $ex->getLine(), $ex->getTrace()); return $this; } $this->importHailData($data); $this->refreshing(); } return $this; }
/** * Generic callback to catch standard PHP runtime errors thrown by the interpreter * or manually triggered with the user_error function. * Caution: The error levels default to E_ALL is the site is in dev-mode (set in main.php). * * @ignore * @param int $errno * @param string $errstr * @param string $errfile * @param int $errline */ function errorHandler($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_ERROR: case E_CORE_ERROR: case E_USER_ERROR: return Debug::fatalHandler($errno, $errstr, $errfile, $errline, debug_backtrace()); case E_WARNING: case E_CORE_WARNING: case E_USER_WARNING: return Debug::warningHandler($errno, $errstr, $errfile, $errline, debug_backtrace()); case E_NOTICE: case E_USER_NOTICE: case E_DEPRECATED: case E_USER_DEPRECATED: case E_STRICT: return Debug::noticeHandler($errno, $errstr, $errfile, $errline, debug_backtrace()); } }
/** * Generic callback to catch standard PHP runtime errors thrown by the interpreter * or manually triggered with the user_error function. * Caution: The error levels default to E_ALL is the site is in dev-mode (set in main.php). * * @ignore * @param int $errno * @param string $errstr * @param string $errfile * @param int $errline */ function errorHandler($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_ERROR: case E_CORE_ERROR: case E_USER_ERROR: Debug::fatalHandler($errno, $errstr, $errfile, $errline, null); break; case E_WARNING: case E_CORE_WARNING: case E_USER_WARNING: Debug::warningHandler($errno, $errstr, $errfile, $errline, null); break; case E_NOTICE: case E_USER_NOTICE: case E_DEPRECATED: case E_USER_DEPRECATED: case E_STRICT: Debug::noticeHandler($errno, $errstr, $errfile, $errline, null); break; } }
/** * Generic callback to catch standard PHP runtime errors thrown by the interpreter * or manually triggered with the user_error function. * Caution: The error levels default to E_ALL is the site is in dev-mode (set in main.php). * * @ignore * @param int $errno * @param string $errstr * @param string $errfile * @param int $errline */ public static function error_handler($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_ERROR: case E_CORE_ERROR: case E_USER_ERROR: StaticPagesQueue::has_error(self::$current_url, $errstr); Debug::fatalHandler($errno, $errstr, $errfile, $errline, null); break; case E_WARNING: case E_CORE_WARNING: case E_USER_WARNING: StaticPagesQueue::has_error(self::$current_url, $errstr); Debug::warningHandler($errno, $errstr, $errfile, $errline, null); break; case E_NOTICE: case E_USER_NOTICE: Debug::noticeHandler($errno, $errstr, $errfile, $errline, null); break; } }