Exemplo n.º 1
0
 /**
  * Register the Blade service.
  *
  * @param Silex\Application $app
  **/
 public function register(Application $app)
 {
     $app['blade.filesystem'] = $app->share(function () {
         return new Filesystem();
     });
     $app['blade.compiler'] = $app->share(function () use($app) {
         return new BladeCompiler($app['blade.filesystem'], $app['blade.settings']['cache']);
     });
     $app['blade.compiler_engine'] = $app->share(function () use($app) {
         return new CompilerEngine($app['blade.compiler'], $app['blade.filesystem']);
     });
     $app['blade.resolver'] = $app->share(function () {
         return new EngineResolver();
     });
     $app['blade.resolver']->register('blade', function () use($app) {
         return $app['blade.compiler_engine'];
     });
     $app['blade.finder'] = $app->share(function () use($app) {
         return new FileViewFinder($app['blade.filesystem'], $app['blade.settings']['views']);
     });
     $app['blade.dispatcher'] = $app->share(function () {
         return new Dispatcher();
     });
     $app['blade'] = $app->share(function ($app) {
         $blade = new Environment($app['blade.resolver'], $app['blade.finder'], $app['blade.dispatcher']);
         $blade->share('app', $app);
         return $blade;
     });
 }
Exemplo n.º 2
0
 /**
  * Returns all social sharing buttons.
  *
  * @return string
  */
 public function all()
 {
     $defaultButtons = Config::get('shareable::default_buttons', array());
     $buttons = array();
     $output = '';
     foreach ($defaultButtons as $button) {
         $buttons[] = call_user_func(array($this, $button));
     }
     return $this->view->make('shareable::all', array('buttons' => $buttons));
 }
 /**
  * Add a piece of shared data to the environment.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return void
  */
 public function share($key, $value = null)
 {
     if (!is_array($key)) {
         return parent::share($key, $this->makePresentable($value));
     }
     return parent::share($this->makePresentable($key));
 }
 /**
  * Register Environment
  *
  * @return void
  */
 public function registerEnvironment()
 {
     $this->app['view'] = $this->app->share(function ($app) {
         $resolver = $app['view.engine.resolver'];
         $resource = 'view.';
         $engine = $app['config']->get($resource . 'engine');
         if (empty($engine)) {
             $resource = 'PhpTalView::';
         }
         $finder = new FileViewFinder($app['files'], array());
         $finder->addLocation($app['config']->get($resource . 'templateRepository'));
         $finder->addExtension($app['config']->get($resource . 'extension'));
         $env = new Environment($resolver, $finder, $app['events']);
         $env->addExtension($app['config']->get($resource . 'extension'), 'phptal');
         $env->setContainer($app);
         $env->share('app', $app);
         return $env;
     });
 }
Exemplo n.º 5
0
 /**
  * Return code for a Google AdSence ad
  *
  * @access public
  * @param string $name
  * @param array [$arguments] Arguments for enabled closure.
  * @return string
  */
 public function get($name, array $arguments = [])
 {
     if (!$this->showAds($arguments)) {
         return '';
     }
     $this->ad->load($name, $this->config->get("ardyn/adsense::ads.{$name}"));
     // Do not display more ads than Google allows
     if ($this->adCount[$this->ad->type]++ >= $this->adLimits[$this->ad->type]) {
         return "<!-- Adsense limit reached. Ad '{$this->ad->name}' not displayed. -->";
     }
     $data = ['ad_client' => $this->adClient, 'slot' => $this->ad->id, 'width' => $this->ad->width, 'height' => $this->ad->height, 'name' => $this->ad->name, 'description' => $this->ad->description];
     return $this->view->make("ardyn/adsense::{$this->renderer}", $data)->render();
 }
Exemplo n.º 6
0
 /**
  * @param $element
  * @return string|View
  */
 public function buildElement($element)
 {
     if (!$element instanceof ElementInterface) {
         return;
     }
     $this->events->fire('form.formBuilder.buildElement.before', array($element, $this));
     $view = $element->getView();
     $state = '';
     $state .= $element->getValidationState() ? ' has-' . $element->getValidationState() : '';
     $state .= $element->isRequired() ? ' is-required' : '';
     $response = '';
     if ($view instanceof Closure) {
         $response = call_user_func_array($view, array($element));
     } elseif ($this->renderer->exists($view)) {
         $response = $this->renderer->make($view, compact('element', 'state'));
     }
     $this->events->fire('form.formBuilder.buildElement.after', array($response, $element, $this));
     return $response;
 }
Exemplo n.º 7
0
 /**
  * Register the view environment.
  *
  * @return void
  */
 public function registerEnvironment()
 {
     // Next we need to grab the engine resolver instance that will be used by the
     // environment. The resolver will be used by an environment to get each of
     // the various engine implementations such as plain PHP or Blade engine.
     $resolver = $this->container['view.engine.resolver'];
     $finder = $this->container['view.finder'];
     $env = new Environment($resolver, $finder, $this->container['events']);
     // We will also set the container instance on this view environment since the
     // view composers may be classes registered in the container, which allows
     // for great testable, flexible composers for the application developer.
     $env->setContainer($this->container);
     return $env;
 }
Exemplo n.º 8
0
 /**
  * Get a evaluated view contents for the given view.
  *
  * @param  string  $view
  * @param  array   $data
  * @return Illuminate\View\View
  */
 public function make($view, $data = array())
 {
     $data = $this->makePresentable($data);
     return parent::make($view, $data);
 }
Exemplo n.º 9
0
 /**
  * Get the pagination view.
  *
  * @param  Illuminate\Pagination\Paginator  $paginator
  * @return Illuminate\View\View
  */
 public function getPaginationView(Paginator $paginator)
 {
     $data = array('environment' => $this, 'paginator' => $paginator);
     return $this->view->make($this->getViewName(), $data);
 }
Exemplo n.º 10
0
 /**
  * Prepare the feed view.
  *
  * @param array $data
  *
  * @return \Illuminate\View\View
  */
 protected function prepareView(array $data)
 {
     $view = $this->getViewName();
     return $this->view->make($view, $data);
 }
Exemplo n.º 11
0
 /**
  * Add a view instance to the view data.
  *
  * @param  string  $key
  * @param  string  $view
  * @param  array   $data
  * @return \Illuminate\View\View
  */
 public function nest($key, $view, array $data = array())
 {
     return $this->with($key, $this->environment->make($view, $data));
 }
Exemplo n.º 12
0
 /**
  * Render the given view.
  *
  * @param  string  $view
  * @param  array   $data
  * @return Illuminate\View\View
  */
 protected function getView($view, $data)
 {
     return $this->views->make($view, $data)->render();
 }
Exemplo n.º 13
0
 /**
  * Get all of the registered named views in environment.
  *
  * @return array 
  * @static 
  */
 public static function getNames()
 {
     return \Illuminate\View\Environment::getNames();
 }
Exemplo n.º 14
0
 /**
  * @param $view
  * @param array $data
  * @return \Illuminate\View\View
  */
 public function make($view, $data = array())
 {
     return $this->view->make($view, $data);
 }
Exemplo n.º 15
0
 /**
  * Generate the view namespace and return the true path to a theme view
  *
  * @param string $path
  * @return string
  */
 private function generateNamespace($path = null, $theme = false)
 {
     $namespace = empty($theme) ? static::$namespace : static::$namespace . '-' . $theme;
     $this->view->addNamespace($namespace, $this->getCurrentPath($theme));
     return $namespace . '::' . $path;
 }