/**
  * Trait constructor
  */
 protected function __TStandardComponents()
 {
     /** @var mfe $class */
     $class = get_called_class();
     $stackObject = mfe::option('stackObject');
     /** @var CObjectsStack $components */
     $this->components = new $stackObject(['coreComponents' => new $stackObject([], 0), 'components' => new $stackObject([], 1)]);
     $this->closingComponents = new $stackObject();
     $this->registerStandardComponents();
     $this->_registerClosingComponent('di', $class);
     $this->_registerClosingComponent('componentManager', $class);
 }
Пример #2
0
<?php

namespace mfe\core\core;

use mfe\core\mfe;
/**
 * Map file
 */
#mfe::map('core', 'loader', '@engine.@core.loader.core');
mfe::loadCore('loader');
mfe::loadCore('page');
Пример #3
0
 /**
  * @return string
  */
 public function render()
 {
     if (!$this->layout) {
         CLog::getInstance()->_error('[' . __CLASS__ . '] Layout file not selected!');
         mfe::stop(0xe3);
     }
     ob_start(function ($layout) {
         return preg_replace_callback('#\\{([a-z0-9\\-_\\#]*?)\\}#Ssi', function ($match) {
             return isset($this->{substr($match[0], 1, -1)}) ? $this->{substr($match[0], 1, -1)} : $match[0];
         }, $layout);
     });
     if (!$this->loadLayout()) {
         CLog::getInstance()->_error('[' . __CLASS__ . '] Not found layout file: ' . $this->layout . $this->layout_extension . ' in directories: ' . PHP_EOL . implode('; ' . PHP_EOL, mfe::app()->loader->getRealPaths('@engine.@layout.', true)));
         mfe::stop(0xe3);
     }
     $this->result = ob_get_contents();
     ob_clean();
     return $this->result;
 }
Пример #4
0
 public static function registerComponent()
 {
     mfe::registerComponent('request', [get_called_class(), 'initRequest']);
     return true;
 }
Пример #5
0
 public function testMfeInterfaceInstance()
 {
     $this->assertInstanceOf('mfe\\core\\libs\\interfaces\\IEventsManager', mfe::app());
 }
Пример #6
0
 public static function registerComponent()
 {
     mfe::registerComponent('page', [get_called_class(), 'getInstance']);
     return true;
 }
Пример #7
0
<?php

namespace mfe\core\libs;

use mfe\core\mfe;
/**
 * Map file
 */
mfe::trigger('loadLibs.begin');
// There are must be load instruction...
mfe::trigger('loadLibs.end');
Пример #8
0
 public static function registerComponent()
 {
     mfe::registerCoreComponent('router', [get_called_class(), 'routerInit']);
     return true;
 }
Пример #9
0
 /**
  * @param $code
  * @return bool|null
  */
 protected static function logAndSplashScreen($code)
 {
     CDebug::display('errorLayout', self::$_CODE[$code]);
     return mfe::stopEngine();
 }
 /**
  * TODO:: Application stack
  *
  * @param mixed|null $id
  * @return mfe
  */
 public static function app($id = null)
 {
     return mfe::getInstance();
 }
Пример #11
0
<?php

@(include_once __DIR__ . '/../vendor/autoload.php') or die('Please execute: php composer.phar update' . PHP_EOL);
use mfe\core\mfe as engine;
engine::app();
Пример #12
0
 /**
  * @param $option
  * @return bool|null
  */
 protected static function option($option)
 {
     return mfe::option($option);
 }
Пример #13
0
<?php

@(include_once '../vendor/autoload.php') or die('Please execute: php composer.phar update' . PHP_EOL);
/**
 * This file only for micro test, delete it when build
 */
use mfe\core\core\Page;
use mfe\core\mfe as engine;
/** @var Page $page */
$page = engine::app()->page;
$page->setLayout('test');
$page->_content = "<p>Hello World!</p>";
$page->render();
engine::display($page);
if (class_exists('Lua')) {
    $lua = new \Lua();
    $lua->eval("print('Hello World!');");
}
Пример #14
0
 /**
  * Start engine
  *
  * Here the engine is registered and prepares for work all components
  *
  * @return bool
  * @throws CException
  */
 public final function startEngine()
 {
     //mfe::dependence('CDisplay');
     //TODO:: Where from phar archive register specific paths
     if (self::option('MFE_PHAR_INIT')) {
     }
     $RUN = array_reverse(explode('/', $_SERVER['SCRIPT_NAME']))[0];
     $REAL_PATH = dirname(realpath($RUN));
     self::registerAlias('@engine', __DIR__);
     if (__DIR__ !== $REAL_PATH && file_exists($REAL_PATH . '/') && is_dir($REAL_PATH . '/')) {
         self::registerAlias('@engine', $REAL_PATH . '/');
     }
     self::registerAlias('@libs', 'libs');
     self::registerAlias('@core', 'core');
     //Load main libs & core files by map file!
     //if (self::loadMapFile('@libs.libs')) self::loadMap('libs'); //TODO:: Это устарело, удалить
     if (self::loadMapFile('@core.core')) {
         self::loadMap('core');
     }
     try {
         return self::trigger('engine.start');
     } catch (CException $e) {
         mfe::stop(0xe1);
     }
     return false;
 }
Пример #15
0
 /**
  * Behavior trait constructor
  */
 public static function TStandardEngine()
 {
     mfe::$options = ['MFE_PHAR_INIT' => false, 'MFE_AUTOLOAD' => false, 'stackObject' => 'mfe\\core\\libs\\components\\CObjectsStack', 'FileHelper' => 'mfe\\core\\libs\\components\\CSimpleFileHelper'];
 }
Пример #16
0
 /**
  * @param $event_node
  * @param array $params
  * @return bool
  * @throws CException
  */
 public function fireEvent($event_node, $params = [])
 {
     if (!is_string($event_node)) {
         return false;
     }
     if ($event_node !== 'event.fire') {
         $this->trigger('event.fire', [$event_node, $params]);
     }
     if (!isset($this->eventsMap[$event_node])) {
         return null;
     }
     foreach ($this->eventsMap[$event_node] as $event) {
         if (is_object($event) && is_callable($event)) {
             // TODO:: Fix second param, to link with stats object
             if ($event($params, mfe::app()) === false) {
                 throw new CException("Event \r\n" . print_r($event, true) . "\r\n return false", 0xe2);
             }
         } elseif (is_string($event) && isset($this->eventsMap[$event]) && $event_node !== $event) {
             if ($this->trigger($event) === false) {
                 throw new CException("Event \r\n{$event}\r\n return false", 0xe2);
             }
         }
     }
     return true;
 }
Пример #17
0
 /**
  * @param $file
  * @param bool $EXT
  * @return bool|mixed|string
  */
 public function load($file, $EXT = false)
 {
     $class = get_called_class();
     /** @var mfe $class */
     $FileHelper = $class::option('FileHelper');
     $EXT = !$EXT ? $FileHelper::$PHP : $EXT;
     $paths = $this->getRealPaths($file);
     foreach ($paths as $file) {
         $file = str_replace('//', '/', $file);
         #print $file . $EXT . PHP_EOL;
         if (file_exists($file . $EXT)) {
             mfe::trigger('file.load', [$file . $EXT]);
             /** @noinspection PhpIncludeInspection */
             return $EXT == $FileHelper::$PHP || $EXT == $FileHelper::$Phar ? require_once $file . $EXT : file_get_contents($file . $EXT);
         }
     }
     return false;
 }