예제 #1
0
파일: Page.php 프로젝트: rafasashi/Phile
 /**
  * the constructor
  *
  * @param        $filePath
  * @param string $folder
  */
 public function __construct($filePath, $folder = CONTENT_DIR)
 {
     $this->contentFolder = $folder;
     $this->setFilePath($filePath);
     /**
      * @triggerEvent before_load_content this event is triggered before the content is loaded
      *
      * @param            string filePath the path to the file
      * @param \Phile\Model\Page page     the page model
      */
     Event::triggerEvent('before_load_content', array('filePath' => &$this->filePath, 'page' => &$this));
     if (file_exists($this->filePath)) {
         $this->rawData = file_get_contents($this->filePath);
         $this->parseRawData();
     }
     /**
      * @triggerEvent after_load_content this event is triggered after the content is loaded
      *
      * @param            string filePath the path to the file
      * @param            string rawData  the raw data
      * @param \Phile\Model\Page page     the page model
      */
     Event::triggerEvent('after_load_content', array('filePath' => &$this->filePath, 'rawData' => $this->rawData, 'page' => &$this));
     $this->parser = ServiceLocator::getService('Phile_Parser');
 }
 protected function clearCache()
 {
     if (!ServiceLocator::hasService('Phile_Cache')) {
         return;
     }
     $cache = ServiceLocator::getService('Phile_Cache');
     $cache->clean();
 }
예제 #3
0
파일: Meta.php 프로젝트: patrova/Phile
 /**
  * parse the raw data
  *
  * @param $rawData
  */
 protected function parseRawData($rawData)
 {
     /** @var \Phile\ServiceLocator\MetaInterface $metaParser */
     $metaParser = ServiceLocator::getService('Phile_Parser_Meta');
     $data = $metaParser->parse($rawData);
     foreach ($data as $key => $value) {
         $this->set($key, $value);
     }
 }
예제 #4
0
파일: Page.php 프로젝트: rafasashi/Phile
 /**
  * the constructor
  */
 public function __construct($settings = null)
 {
     if ($settings === null) {
         $settings = Registry::get('Phile_Settings');
     }
     $this->settings = $settings;
     if (ServiceLocator::hasService('Phile_Cache')) {
         $this->cache = ServiceLocator::getService('Phile_Cache');
     }
 }
예제 #5
0
파일: Plugin.php 프로젝트: rafasashi/Phile
 /**
  * called on 'plugins_loaded' event
  *
  * @param null $data
  * @throws \Phile\Exception\ServiceLocatorException
  */
 public function onPluginsLoaded($data = null)
 {
     switch ($this->settings['handler']) {
         case Plugin::HANDLER_ERROR_LOG:
             ServiceLocator::registerService('Phile_ErrorHandler', new ErrorLog($this->settings));
             break;
         case Plugin::HANDLER_DEVELOPMENT:
             ServiceLocator::registerService('Phile_ErrorHandler', new Development($this->settings));
             break;
     }
 }
예제 #6
0
파일: Plugin.php 프로젝트: patrova/Phile
 /**
  * onPluginsLoaded method
  */
 public function onPluginsLoaded()
 {
     // phpFastCache not working in CLI mode...
     if (PHILE_CLI_MODE) {
         return;
     }
     unset($this->settings['active']);
     $config = $this->settings + \phpFastCache::$config;
     $storage = $this->settings['storage'];
     $cache = phpFastCache($storage, $config);
     ServiceLocator::registerService('Phile_Cache', new PhpFastCache($cache));
 }
예제 #7
0
파일: Plugin.php 프로젝트: patrova/Phile
 /**
  * onPluginsLoaded method
  *
  * @param null   $data
  *
  * @return mixed|void
  */
 public function onPluginsLoaded($data = null)
 {
     ServiceLocator::registerService('Phile_Data_Persistence', new SimpleFileDataPersistence());
 }
예제 #8
0
파일: index.php 프로젝트: patrova/Phile
<?php

/**
 * @author PhileCMS
 * @link https://philecms.com
 * @license http://opensource.org/licenses/MIT
 * @package Phile
 */
require_once __DIR__ . '/lib/Phile/Bootstrap.php';
ob_start();
try {
    \Phile\Bootstrap::getInstance()->initializeBasics();
    $router = new \Phile\Core\Router();
    $response = new \Phile\Core\Response();
    $phileCore = new \Phile\Core($router, $response);
    $phileCore->render();
} catch (\Phile\Exception\AbstractException $e) {
    if (\Phile\Core\ServiceLocator::hasService('Phile_ErrorHandler')) {
        ob_end_clean();
        /** @var \Phile\ServiceLocator\ErrorHandlerInterface $errorHandler */
        $errorHandler = \Phile\Core\ServiceLocator::getService('Phile_ErrorHandler');
        $errorHandler->handleException($e);
    }
} catch (\Exception $e) {
    if (\Phile\Core\ServiceLocator::hasService('Phile_ErrorHandler')) {
        ob_end_clean();
        /** @var \Phile\ServiceLocator\ErrorHandlerInterface $errorHandler */
        $errorHandler = \Phile\Core\ServiceLocator::getService('Phile_ErrorHandler');
        $errorHandler->handleException($e);
    }
}
예제 #9
0
파일: Plugin.php 프로젝트: patrova/Phile
 /**
  * onPluginsLoaded method
  *
  * @param null   $data
  *
  * @return mixed|void
  */
 public function onPluginsLoaded($data = null)
 {
     ServiceLocator::registerService('Phile_Template', new Twig($this->settings));
 }
예제 #10
0
파일: Plugin.php 프로젝트: patrova/Phile
 /**
  * onPluginsLoaded method
  *
  * @param null   $data
  *
  * @return mixed|void
  */
 public function onPluginsLoaded($data = null)
 {
     ServiceLocator::registerService('Phile_Parser_Meta', new Meta($this->settings));
 }