本文整理匯總了PHP中Illuminate\View\Factory::share方法的典型用法代碼示例。如果您正苦於以下問題:PHP Factory::share方法的具體用法?PHP Factory::share怎麽用?PHP Factory::share使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\View\Factory
的用法示例。
在下文中一共展示了Factory::share方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: plant
/**
* Plant a new bonsai collection!
*
* @param string $namespace
* @param string $path
* @return null
*/
public function plant($callback = null)
{
$assets = new Assets();
if (is_callable($callback)) {
call_user_func($callback, $assets);
}
$this->collection->put('bonsai', $assets);
$this->view->share('bonsai', $assets);
return $assets;
}
示例2: make
/**
* Create a new menu instance.
*
* @param string $name
* @param callable $callback
* @return \Caffeinated\Menus\Builder
*/
public function make($name, $callback)
{
if (is_callable($callback)) {
$menu = new Builder($name, $this->loadConfig($name), $this->html, $this->url);
call_user_func($callback, $menu);
$this->collection->put($name, $menu);
$this->view->share('menu_' . $name, $menu);
return $menu;
}
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
$this->app->setLocale($this->settings->get('user.language', 'en'));
$langDir = ['left' => 'left', 'right' => 'right'];
if (trans('general.direction') == 'rtl') {
$langDir['left'] = 'right';
$langDir['right'] = 'left';
}
$this->viewFactory->share('langDir', $langDir);
return $next($request);
}
示例4: make
/**
* Create a new menu instance.
*
* @param string $name
* @param callable $callback
*
* @return \Kiwina\Menu\Menu
*/
public function make($name, $callback)
{
if (is_callable($callback)) {
$menu = new Builder($name, $this->loadConf($name), $this->html, $this->url);
// Registering the items
call_user_func($callback, $menu);
// Storing each menu instance in the collection
$this->collection->put($name, $menu);
// Make the instance available in all views
$this->view->share($name, $menu);
return $menu;
}
}
示例5: boot
/**
* Bootstrap the application services
*
* @param ViewFactory $viewFactory
*/
public function boot(ViewFactory $viewFactory)
{
if (is_dir(base_path() . '/resources/views/viktorv/lpanel')) {
$this->loadViewsFrom(base_path() . '/resources/views/viktorv/lpanel', 'lpanel');
} else {
$path = realpath(__DIR__ . '/../resources/views');
/** @var \League\Plates\Engine $platesEngine */
$platesEngine = $this->app->make('League\\Plates\\Engine');
$platesEngine->setDirectory($path);
$platesEngine->addFolder('layout', $path . '/admin/layout');
$platesEngine->addFolder('noscript', $path . '/noscript');
$this->loadViewsFrom($path, 'lpanel');
}
/** @var \Illuminate\Validation\Factory $validator */
$validator = $this->app->validator;
$validator->resolver(function ($translator, $data, $rules, $messages) {
return new Validator($translator, $data, $rules, $messages);
});
$viewFactory->share('block', new BaseBlock($this->app));
if (is_dir(base_path() . '/resources/lang/viktorv/lpanel')) {
$this->loadTranslationsFrom(base_path() . '/resources/lang/viktorv/lpanel', 'lpanel');
} else {
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'lpanel');
}
}
示例6: shareTitle
private function shareTitle()
{
$langKey = "titles.{$this->router->currentRouteName()}";
if ($this->lang->has($langKey)) {
$this->view->share('title', $this->lang->get($langKey));
}
}
示例7: share
/**
* Add a piece of shared data to the factory.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function share($key, $value = null)
{
if (!is_array($key)) {
return parent::share($key, $this->decorate($value));
}
return parent::share($this->decorate($key));
}
示例8: register
public function register(Container $pimple)
{
$pimple['files'] = function () {
return new Filesystem();
};
$pimple['view.engine.resolver'] = function () use($pimple) {
$resolver = new EngineResolver();
foreach (['php', 'blade'] as $engine) {
$this->{'register' . ucfirst($engine) . 'Engine'}($resolver, $pimple);
}
return $resolver;
};
$pimple['view.finder'] = function () use($pimple) {
$paths = $pimple['config']['view.paths'];
return new FileViewFinder($pimple['files'], $paths);
};
$pimple['view'] = function () use($pimple) {
// 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 = $pimple['view.engine.resolver'];
$finder = $pimple['view.finder'];
$env = new Factory($resolver, $finder, $pimple['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($pimple['container']);
$env->share('app', $pimple);
return $env;
};
}
示例9: __construct
public function __construct(Store $session, Factory $view)
{
$this->session = $session;
$view->share('flash', $this);
if ($this->session->has($this->namespace)) {
$flashed = $this->session->get($this->namespace);
$this->message = $flashed['message'];
$this->title = $flashed['title'];
$this->type = $flashed['type'];
$this->exists = true;
}
}
示例10: loadMocks
private function loadMocks(View $view)
{
$events = [1 => ['/img/event-sample1.jpg', 'iMasters Developer Week RJ', 'Rio de Janeiro, Brazil'], 2 => ['/img/event-sample2.jpg', 'PHP\'n Rio 2011', 'Rio de Janeiro, Brazil'], 3 => ['/img/event-sample3.jpg', 'PHPConf 2015', 'Osasco, Brazil'], 4 => ['/img/event-sample4.jpg', 'TDCOnline 2015 POA', 'Porto Alegre, Brazil'], 5 => ['/img/event-sample5.jpg', 'O\'Reilly\'s Fluent', 'San Francisco, USA'], 6 => ['/img/event-sample6.gif', 'UERJ Sem Muros', 'Rio de Janeiro, Brazil'], 7 => ['/img/event-sample7.jpg', '53º Congresso HUPE', 'Rio de Janeiro, Brazil'], 8 => ['/img/event-sample8.png', 'XXVI Congresso Brasileiro de Virologia', 'Florianópolis, Brazil']];
foreach ($events as $i => &$event) {
$event[] = time();
$event[] = $i % 2 ? time() + 60 * 60 * 24 * 3 : null;
$event[] = 'Fusce pellentesque velvitae tincidunt egestas. Pellentesque habitant morbi. Proin gravida nibh vel velit auctor aliquet. Aenean sollicitudin, lorem quis.
Bibendum auctor, nisi elit consequat ipsum, nec sagittis sem nibh id elit. Duis sed odio sit amet nibh vulputate cursus a sit amet mauris.';
$event[] = (bool) rand(0, 1);
$event[] = 'http://www.google.com.br';
$event[] = 'konato';
$event[] = 'konato2015';
}
$types = [_('Congresses'), _('Meetings'), _('Talks & discussions'), _('University meetings'), _('Cultural')];
$selected_types = array_rand($types, 2);
$themes = explode(' ', 'PHP Databases MySQL Webdesign APIs');
$selected_themes = array_rand($themes, 2);
$speakers = [['/img/speaker-sample1.jpg', 'Fabio Akita', 'São Paulo, Brazil', ['Ruby', 'Agile', 'Speaking']], ['/img/speaker-sample2.jpg', 'Raphael de Almeida', 'Rio de Janeiro, Brazil', ['PHP', 'Microsserviços', 'Ruby']], ['/img/speaker-sample3.jpg', 'Valéria Parajara', 'Rio de Janeiro, Brazil', ['Ruby', 'Gastronomia']], ['/img/speaker-sample4.jpg', 'Pedro Couteiro', 'Tsukuba, Japan', ['CG', 'Java', 'Japanese']], ['/img/speaker-sample5.jpg', 'Luan Rodrigues', 'Rio de Janeiro, Brazil', ['Computação médica', 'Cirurgia plástica']], ['/img/speaker-sample6.jpg', 'Igor Santos', 'Halifax, Canada', ['Web Services', 'PHP']]];
foreach ($speakers as $i => &$speaker) {
$speaker[] = rand(5, 15);
$speaker[] = rand(15, 50);
$speaker[] = 'Fusce pellentesque velvitae tincidunt egestas. Pellentesque habitant morbi.';
$speaker[] = ['M', 'M', 'F', 'M', 'M', 'M'][$i];
}
$materials = [['http://www.google.com', 'How to be Agile in Project Management', 'doc', $speakers[1]], ['http://pt.slideshare.net/igorsantos07/rest-fuuuu-54458320', 'The RESTful Police', 'slide', $speakers[5]], ['http://www.google.com', 'Immobilized lipase reutilization on biodiesel syntesis from soy oil', 'doc', $speakers[3]], ['http://www.google.com', 'How to launch a culinary business having an IT background', 'video', $speakers[2]]];
shuffle($events);
shuffle($speakers);
$view->share('events', $events);
// $view->share('types', $types);
$view->share('selected_types', $selected_types);
$view->share('themes', $themes);
$view->share('selected_themes', $selected_themes);
$view->share('speakers', $speakers);
$view->share('materials', $materials);
}
示例11: makeView
protected function makeView()
{
$app = new Container();
$resolver = new EngineResolver();
$resolver->register('php', function () {
return new PhpEngine();
});
$finder = new FileViewFinder(new Filesystem(), [realpath(__DIR__)]);
$dispatcher = (new Dispatcher($app))->setQueueResolver(function () use($app) {
return $app->make('Illuminate\\Contracts\\Queue\\Factory');
});
$env = new Factory($resolver, $finder, $dispatcher);
$env->setContainer($app);
$env->share('app', $app);
return new Illuminate($env);
}
示例12: registerFactory
/**
* Register the view environment.
*
* @return void
*/
public function registerFactory()
{
$this->app->singleton('view', function ($app) {
// 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 = $app['view.engine.resolver'];
$finder = $app['view.finder'];
$env = new Factory($resolver, $finder, $app['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($app);
$env->share('app', $app);
return $env;
});
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
// Share the authenticated user to make sure we have a decorated version of it
$this->viewFactory->share('auth_user', $this->guard->user());
return $next($request);
}
示例14: render
/**
* Get the string contents of the view.
*
* @param Request $request
* @return string
*/
public function render(Request $request)
{
$forum = $this->getForumDocument($request);
$this->view->share('translator', $this->locales->getTranslator());
$this->view->share('allowJs', !array_get($request->getQueryParams(), 'nojs'));
$this->view->share('forum', array_get($forum, 'data'));
$this->view->share('debug', array_get($forum, 'data.attributes.debug'));
$view = $this->view->file(__DIR__ . '/../../../views/app.blade.php');
$view->title = $this->buildTitle(array_get($forum, 'data.attributes.title'));
$view->description = $this->description;
$view->modules = $this->modules;
$view->payload = $this->buildPayload($request, $forum);
$view->layout = $this->buildLayout();
$baseUrl = array_get($forum, 'data.attributes.baseUrl');
$view->cssUrls = $this->buildCssUrls($baseUrl);
$view->jsUrls = $this->buildJsUrls($baseUrl);
$view->head = implode("\n", $this->head);
$view->foot = implode("\n", $this->foot);
return $view->render();
}
示例15: shareDataToViews
/**
* Shares the required data for the reCAPTCHA
*
* @return void
*/
public function shareDataToViews()
{
$this->view->share('captcha_validation_url', $this->mockably->route('larapress.api.captcha.validate.post'));
}