Inheritance: implements ArrayAccess
示例#1
0
文件: App.php 项目: sjardim/Hugopit
 public function __construct($settings = [])
 {
     $settings["helpers"] = array_merge(["acl" => "Lime\\Helper\\SimpleAcl", "assets" => "Lime\\Helper\\Assets", "fs" => "Lime\\Helper\\Filesystem", "image" => "Lime\\Helper\\Image", "i18n" => "Lime\\Helper\\I18n", "utils" => "Lime\\Helper\\Utils", "coockie" => "Lime\\Helper\\Cookie"], isset($settings["helpers"]) ? $settings["helpers"] : []);
     parent::__construct($settings);
     // renderer service
     $this->service('renderer', function () {
         $renderer = new \Lexy();
         //register app helper functions
         $renderer->extend(function ($content) {
             $content = preg_replace('/(\\s*)@extend\\((.+?)\\)/', '$1<?php $extend($2); ?>', $content);
             $content = preg_replace('/(\\s*)@base\\((.+?)\\)/', '$1<?php $app->base($2); ?>', $content);
             $content = preg_replace('/(\\s*)@route\\((.+?)\\)/', '$1<?php $app->route($2); ?>', $content);
             $content = preg_replace('/(\\s*)@scripts\\((.+?)\\)/', '$1<?php echo $app->assets($2); ?>', $content);
             $content = preg_replace('/(\\s*)@render\\((.+?)\\)/', '$1<?php echo $app->view($2); ?>', $content);
             $content = preg_replace('/(\\s*)@trigger\\((.+?)\\)/', '$1<?php $app->trigger($2); ?>', $content);
             $content = preg_replace('/(\\s*)@lang\\((.+?)\\)/', '$1<?php echo $app("i18n")->get($2); ?>', $content);
             $content = preg_replace('/(\\s*)@start\\((.+?)\\)/', '$1<?php $app->start($2); ?>', $content);
             $content = preg_replace('/(\\s*)@end\\((.+?)\\)/', '$1<?php $app->end($2); ?>', $content);
             $content = preg_replace('/(\\s*)@block\\((.+?)\\)/', '$1<?php $app->block($2); ?>', $content);
             return $content;
         });
         return $renderer;
     });
     $this("session")->init();
 }
示例#2
0
文件: App.php 项目: amdad/BirdsLab
 public function __construct($settings = array())
 {
     $settings["helpers"] = array_merge(array("acl" => "Lime\\Helper\\SimpleAcl", "assets" => "Lime\\Helper\\Assets", "cache" => "Lime\\Helper\\Cache", "fs" => "Lime\\Helper\\Filesystem", "image" => "Lime\\Helper\\Image", "i18n" => "Lime\\Helper\\I18n", "utils" => "Lime\\Helper\\Utils", "coockie" => "Lime\\Helper\\Coockie"), isset($settings["helpers"]) ? $settings["helpers"] : array());
     parent::__construct($settings);
     $this->viewvars["app"] = $this;
     $this->viewvars["base_url"] = $this["base_url"];
     $this->viewvars["base_route"] = $this["base_route"];
     $this->viewvars["docs_root"] = $this["docs_root"];
     $this["modules"] = new \ArrayObject(array());
     $this("session")->init();
 }
示例#3
0
 /**
  * @param array $settings
  */
 public function __construct($settings = [])
 {
     $settings["helpers"] = array_merge(["acl" => "Lime\\Helper\\SimpleAcl", "assets" => "Lime\\Helper\\Assets", "fs" => "Lime\\Helper\\Filesystem", "image" => "Lime\\Helper\\Image", "i18n" => "Lime\\Helper\\I18n", "utils" => "Lime\\Helper\\Utils", "coockie" => "Lime\\Helper\\Cookie", "yaml" => "Lime\\Helper\\YAML"], isset($settings["helpers"]) ? $settings["helpers"] : []);
     parent::__construct($settings);
     // renderer service
     $this->service('renderer', function () {
         $renderer = new \Lexy();
         //register app helper functions
         $renderer->extend(function ($content) {
             $replace = ['extend' => '<?php $extend(expr); ?>', 'base' => '<?php $app->base(expr); ?>', 'route' => '<?php $app->route(expr); ?>', 'trigger' => '<?php $app->trigger(expr); ?>', 'assets' => '<?php echo $app->assets(expr); ?>', 'start' => '<?php $app->start(expr); ?>', 'end' => '<?php $app->end(expr); ?>', 'block' => '<?php $app->block(expr); ?>', 'url' => '<?php echo $app->pathToUrl(expr); ?>', 'view' => '<?php echo $app->view(expr); ?>', 'render' => '<?php echo $app->view(expr); ?>', 'include' => '<?php echo include($app->path(expr)); ?>', 'lang' => '<?php echo $app("i18n")->get(expr); ?>'];
             $content = preg_replace_callback('/\\B@(\\w+)([ \\t]*)(\\( ( (?>[^()]+) | (?3) )* \\))?/x', function ($match) use($replace) {
                 if (isset($match[3]) && trim($match[1]) && isset($replace[$match[1]])) {
                     return str_replace('(expr)', $match[3], $replace[$match[1]]);
                 }
                 return $match[0];
             }, $content);
             return $content;
         });
         return $renderer;
     });
     $this("session")->init();
 }