/**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $_this =& $this;
     $this->app->bind('theme.assets', function ($app) {
         return new \Onefasteuro\Theme\Assets(new \Assetic\AssetManager(), $app);
     });
     $this->app->bind('theme.page', function ($app) {
         return new Page\StaticPage($app['config'], $app['theme.assets']);
     });
     $this->app->bind('theme.parser', function ($app) use(&$_this) {
         $parser = Helper::parser($app);
         $class = new \ReflectionClass("\\Onefasteuro\\Theme\\{$parser}");
         $class = $class->newInstance($app['config'], $app['theme.page']);
         return $class;
     });
     $this->app->booting(function () {
         $loader = \Illuminate\Foundation\AliasLoader::getInstance();
         $loader->alias('Helper', '\\Onefasteuro\\Theme\\Helper');
     });
     /** blade partials **/
     \Blade::extend(function ($view, $compiler) {
         $pattern = $compiler->createMatcher('partials');
         return preg_replace($pattern, '$1<?php echo \\$__env->make("theme.views::".Helper::skin().".partials.".$2, array_except(get_defined_vars(), array("__data", "__path")))->render(); ?>', $view);
     });
 }
Exemple #2
0
 protected function view($view, $data = [])
 {
     $this->layout->meta = $this->parser->getPage()->meta();
     $this->layout->assets = $this->parser->getPage()->assets();
     $data = array_merge($data, ['page' => $this->parser->getPage()->page()]);
     $fallback = Helper::viewFallback($view);
     $this->layout->body = View::make("theme.views::{$this->skin}.{$fallback}", $data);
 }
Exemple #3
0
 public function __construct(\Assetic\AssetManager $am, \Illuminate\Foundation\Application $app)
 {
     $this->am =& $am;
     $this->app = $app;
     $this->skin = Helper::skin();
     $this->config = $this->app['config']->get('theme::theme.' . $this->skin);
     $this->path = $this->config['assets_path'];
     $this->init();
 }
Exemple #4
0
 /**
  * Loads the source file and evaluates the contents
  *
  **/
 public function load($source = NULL)
 {
     $source == NULL ? $source = Helper::getDocument() : ($source = Helper::getDocument($source));
     //render the content in case it contains blade or laravel commands (routes...)
     $source = View::make("{$this->namespace}::{$source}")->render();
     //split the body into meta variables and body content
     $sections = $this->splitSection($source);
     $this->meta = $this->parseMeta($sections[0]);
     $this->content = $this->parseBody($sections[1]);
     //Initialize our page object
     $this->page->init($this->meta, $this->content);
     return $this;
 }