/** * @param bool $undo * @return array */ protected function registerLoader($undo = false) { $components = ['registerAlias' => [__CLASS__, '_registerAlias'], 'loadFile' => [__CLASS__, '_loadFile'], 'loadPhar' => [__CLASS__, '_loadPhar'], 'loadCore' => [__CLASS__, '_loadCore'], 'loadMapFile' => [__CLASS__, '_loadMapFile'], 'map' => [__CLASS__, '_map'], 'loadMap' => [__CLASS__, '_loadMap']]; foreach ($components as $key => $callback) { !$undo ? mfe::app()->registerCoreComponent($key, $callback) : mfe::app()->unRegisterCoreComponent($key); } return $components; }
/** * @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; }
try { return self::trigger('engine.start'); } catch (CException $e) { mfe::stop(0xe1); } return false; } /** * Stop engine * * @return bool|null */ public static final function stopEngine() { if (!is_null(error_get_last()) && self::$_STATUS !== 0xe0) { CRunHandler::FatalErrorHandler(); } if (isset(self::$instance) || is_null(self::$instance)) { return CRunHandler::DebugHandler(); } self::trigger('engine.stop'); self::$instance = null; return true; } } /** * Auto register self in system * @standards MFS-5.5 */ !mfe::option('MFE_AUTOLOAD') or mfe::app();
/** * @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; }
public function setLayout($layout) { if (!($this->layout = mfe::loadFile('@engine.@layout.' . $layout, $this->layout_extension))) { throw new CException('Not found layout file: ' . $layout . $this->layout_extension . ' in directories: ' . PHP_EOL . implode('; ' . PHP_EOL, mfe::app()->loader->getRealPaths('@engine.@layout.', true))); } return $this; }
public function testMfeInterfaceInstance() { $this->assertInstanceOf('mfe\\core\\libs\\interfaces\\IEventsManager', mfe::app()); }
<?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();
<?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!');"); }