/** * Bootstrap any application services. * * @return void */ public function boot() { Blade::extend(function ($value) { return preg_replace('/@define(.+)/', '<?php ${1}; ?>', $value); }); Blade::extend(function ($value) { $value = preg_replace('/(?<=\\s)@switch\\((.*)\\)(\\s*)@case\\((.*)\\)(?=\\s)/', '<?php switch($1):$2case $3: ?>', $value); $value = preg_replace('/(?<=\\s)@endswitch(?=\\s)/', '<?php endswitch; ?>', $value); $value = preg_replace('/(?<=\\s)@case\\((.*)\\)(?=\\s)/', '<?php case $1: ?>', $value); $value = preg_replace('/(?<=\\s)@default(?=\\s)/', '<?php default: ?>', $value); $value = preg_replace('/(?<=\\s)@endcase(?=\\s)/', '<?php break; ?>', $value); return $value; }); Blade::extend(function ($value) { $value = preg_replace('/(?<=\\s)@me\\((.*)\\)(?=\\s)/', '<?php if(is_me(${1})) { ?>', $value); $value = preg_replace('/(?<=\\s)@endme(?=\\s)/', '<?php } ?>', $value); return $value; }); Blade::extend(function ($value) { $value = preg_replace('/(?<=\\s)@auth(?=\\s)/', '<?php if(Auth::user()) { ?>', $value); $value = preg_replace('/(?<=\\s)@endauth(?=\\s)/', '<?php } ?>', $value); return $value; }); Blade::extend(function ($value) { $value = preg_replace('/(?<=\\s)@guest(?=\\s)/', '<?php if(!Auth::user()) { ?>', $value); $value = preg_replace('/(?<=\\s)@endguest(?=\\s)/', '<?php } ?>', $value); return $value; }); }
/** * Register a blade directive. * * @param $name * @param $expression */ protected function registerBladeDirective($name, $expression) { Blade::extend(function ($view) use($name, $expression) { $pattern = $this->createMatcher($name); return preg_replace($pattern, $expression, $view); }); }
function __construct() { // self::$settings = Config::get('garbarinoviajes'); // self::$static = url('statics') . '/'; // if (false == \Illuminate\Support\Facades\Request::ajax()) { self::addJsHeader('http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'); self::addCss('main.css'); // ex bootstrap self::addCss('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'); self::addCss('https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/redmond/jquery-ui.css'); self::addCss('details.css'); // self::addCss('1200.css'); self::addJsFooter('https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'); self::addJsFooter('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js'); } // \Illuminate\Support\Facades\Blade::extend(function ($value) { return preg_replace('/(\\s*)@(break|continue)(\\s*)/', '$1<?php $2; ?>$3', $value); }); // view()->composer('*', 'App\\Http\\Composers\\ViewComposer'); }
/** * Extend the blade compiler for the minification process. * * @return void */ protected function setupCompiler() { Blade::extend(function ($value, $compiler) { BladePlaceholder::setBladeTags($this->getBladeTags($compiler)); $context = new MinifyContext(new PlaceholderContainer()); $minifier = $this->laravel->make('blade.compiler.min'); $this->minifyContext = $minifier->run($context->setContents($value), $this->option()); return $this->minifyContext->getContents(); }); }
public function boot() { $this->package('skovachev/lacore'); Validator::resolver(function ($translator, $data, $rules, $messages) { return new \Skovachev\Lacore\Extensions\Validator($translator, $data, $rules, $messages); }); Blade::extend(function ($view) { $html = "<div id='message' class='alert <?php echo (Session::has('message-status') ? 'alert-' . Session::get('message-status') : ''); ?>'><?php echo Session::get('message'); ?></div>"; return str_replace("@message", $html, $view); }); }
/** * Register meta blade extensions . * */ protected function registerBladeExtension() { if ($this->versionMatch('5.0')) { Blade::extend(function ($view) { return str_replace("@meta", app('meta')->render(), $view); }); } elseif ($this->versionMatch('5.1')) { Blade::directive('meta', function ($expression) { return app('meta')->render($expression); }); } }
/** * Register the service provider. * * @return void */ public function register() { // Register the piwik tracker object $this->app['piwiktracker'] = $this->app->share(function () { return new PiwikTracker(); }); // Insert the piwik tracker code when we discover a @piwiktracker // directive in a template Blade::extend(function ($view, $compiler) { $pattern = $compiler->createPlainMatcher('piwiktracker'); return preg_replace($pattern, '<?php echo PiwikTracker::getCode() ?>', $view); }); }
public function register() { $this->app['prettyDump'] = $this->app->share(function ($app) { return new Dumper(); }); $this->app->booting(function () { AliasLoader::getInstance()->alias('PrettyDump', 'kotchuprik\\PrettyDump\\Facade'); }); Blade::extend(function ($view, $compiler) { $pattern = $compiler->createMatcher('prettyDump'); return preg_replace($pattern, '$1<?php PrettyDump::dump$2 ?>', $view); }); }
/** * Create a new instance * * @param ApiServer $apiServer * @param Sentry $sentry * @return void */ public function __construct(ApiServer $apiServer, Sentry $sentry, Excel $excel) { $this->apiServer = $apiServer; $this->sentry = $sentry; $this->excel = $excel; Blade::extend(function ($view) { return preg_replace(array('#@translate\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@translate\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Translate::t("$1")', 'Translate::t(\'$1\')'), $view); }); Blade::extend(function ($view) { return preg_replace(array('#@option\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@option\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Option::getAttribute("$1")', 'Option::getAttribute("$1")'), $view); }); $this->getLocale()->t('ebri'); }
/** * Bootstrap any application services. * * @return void */ public function boot() { $this->app['module.loader']->bootModules(); $this->app['cms']->shutdown(function () { $this->app['module.loader']->cacheFoundFiles(); }); Blade::extend(function ($view, $compiler) { $pattern = $compiler->createMatcher('event'); return preg_replace($pattern, '$1<?php event$2; ?>', $view); }); Event::listen('view.settings.bottom', function () { WYSIWYG::loadAll(); echo view('cms::ace.settings')->with('availableACEThemes', config('cms.wysiwyg.ace_themes')); }); }
public static function register() { Blade::extend(function ($view, $compiler) { $pattern = $compiler->createMatcher('dateonly'); return preg_replace($pattern, '$1<?php $date = new DateTime($2); echo $date->format(\'d/m/Y\'); ?>', $view); }); Blade::extend(function ($view, $compiler) { $pattern = $compiler->createMatcher('datetimeformat'); return preg_replace($pattern, '$1<?php $date = new DateTime($2); echo $date->format(\'d/m/Y\')." às ".$date->format(\'H:i\'); ?>', $view); }); Blade::extend(function ($view, $compiler) { $pattern = $compiler->createMatcher('monthname'); return preg_replace($pattern, '$1<?php $meses = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; echo $meses[$2 - 1] ?>', $view); }); }
/** * Bootstrap the application events. * * @return void */ public function boot() { $this->package('mschinis/braintree'); $this->app->bind('mschinis::command.braintree.example', function ($app) { return new BraintreeExampleCommand($app['files']); }); $this->commands(array('mschinis::command.braintree.example')); Braintree_Configuration::environment(Config::get('braintree::environment')); Braintree_Configuration::merchantId(Config::get('braintree::merchantId')); Braintree_Configuration::publicKey(Config::get('braintree::publicKey')); Braintree_Configuration::privateKey(Config::get('braintree::privateKey')); $encryptionKey = Config::get('braintree::config.CSEKey'); Blade::extend(function ($view, $compiler) use($encryptionKey) { $pattern = $compiler->createPlainMatcher('braintreeCSEKey'); return preg_replace($pattern, '$1<?php echo "' . $encryptionKey . '" ?>', $view); }); }
/** * Register any misc. blade extensions */ public function register() { /** * The block of code inside this directive indicates * the chosen language requests RTL support. */ Blade::directive('langRTL', function () { return "<?php if (session()->has('lang-rtl')): ?>"; }); /** * Sets a PHP variable in a blade view * Courtesy of https://github.com/sineld/bladeset */ Blade::extend(function ($value) { return preg_replace("/@set\\(['\"](.*?)['\"]\\,(.*)\\)/", '<?php $$1 = $2; ?>', $value); }); }
/** * Register blade extensions. */ protected function registerBladeExtensions() { Blade::extend(function ($view) { $pattern = $this->createMatcher('widget'); return preg_replace($pattern, '$1<?php echo app("arrilot.widget")->run$2; ?>', $view); }); Blade::extend(function ($view) { $pattern = $this->createMatcher('async-widget'); return preg_replace($pattern, '$1<?php app("arrilot.async-widget")->run$2; ?>', $view); }); Blade::extend(function ($view) { $pattern = $this->createMatcher('asyncWidget'); return preg_replace($pattern, '$1<?php echo app("arrilot.async-widget")->run$2; ?>', $view); }); Blade::extend(function ($view) { $pattern = $this->createMatcher('widgetGroup'); return preg_replace($pattern, '$1<?php echo Widget::group$2->display(); ?>', $view); }); }
/** * Bootstrap the application services. * * @return void */ public function boot(Request $request) { $this->loadViewsFrom(__DIR__ . '/views', 'geetest'); $this->publishes([__DIR__ . '/views' => base_path('resources/views/vendor/geetest'), __DIR__ . '/config.php' => config_path('geetest.php')]); Validator::extend('geetest', function () use($request) { list($geetest_challenge, $geetest_validate, $geetest_seccode) = array_values($request->only('geetest_challenge', 'geetest_validate', 'geetest_seccode')); if (session()->get('gtserver') == 1) { if (Geetest::successValidate($geetest_challenge, $geetest_validate, $geetest_seccode, session()->get('user_id'))) { return true; } return false; } else { if (Geetest::failValidate($geetest_challenge, $geetest_validate, $geetest_seccode, session()->get('user_id'))) { return true; } return false; } }); Blade::extend(function ($value) { return preg_replace('/@define(.+)/', '<?php ${1}; ?>', $value); }); }
public function registerCompiler() { Blade::extend(function ($view, $compiler) { while (preg_match_all('/@ab(?:.(?!@track|@ab))+.@track\\([^\\)]+\\)+/si', $view, $sections_matches)) { $sections = current($sections_matches); foreach ($sections as $block) { $instance_id = preg_replace('/[^0-9]/', '', microtime() . rand(100000, 999999)); if (preg_match("/@ab\\(([^\\)]+)\\)/", $block, $match)) { $experiment_name = preg_replace('/[^a-z0-9\\_]/i', '', $match[1]); $instance = $experiment_name . '_' . $instance_id; } else { throw new \Exception('Experiment with not name not allowed'); } $copy = preg_replace('/@ab\\(.([^\\)]+).\\)/i', "<?php \${$instance} = App::make('Ab')->experiment('{$experiment_name}'); ?>", $block); $copy = preg_replace('/@condition\\(([^\\)]+)\\)/i', "<?php \${$instance}->condition(\$1); ?>", $copy); $copy = preg_replace('/@track\\(([^\\)]+)\\)/i', "<?php echo \${$instance}->track(\$1); ?>", $copy); $view = str_replace($block, $copy, $view); } } $view = preg_replace('/@goal\\(([^\\)]+)\\)/i', "<?php App::make('Ab')->goal(\$1); ?>", $view); return $view; }); }
/** * Bootstrap any application services. * * @return void */ public function boot() { // validate alphabetical chars & spaces only Validator::extend('alpha_space', function ($attribute, $value, $parameters, $validator) { //return preg_match('/^([a-zA-Z ])+$/i', $value); return preg_match('/^[\\pL\\pM ]+$/u', $value); }); // validate alphabetical chars, numbers & spaces only Validator::extend('alpha_num_space', function ($attribute, $value, $parameters, $validator) { return preg_match('/^([a-zA-Z0-9 ])+$/i', $value); }); // validate alphabetical chars, dashes & spaces only Validator::extend('alpha_dash_space', function ($attribute, $value, $parameters, $validator) { return preg_match('/^[\\pL\\pM\\pN _-]+$/u', $value); }); // validate full alphabetical chars, dashes & spaces only Validator::extend('ands_full', function ($attribute, $value, $parameters, $validator) { return preg_match('/^[\\pL\\pM\\pN #\\/,.:%_-]+$/u', $value); }); // Extend blade to define a variable Blade::extend(function ($value) { return preg_replace('/\\@var(.+)/', '<?php ${1}; ?>', $value); }); }
/** * Create a new instance. * * @return void */ public function __construct() { //Set API base url if empty if (empty($this->apiBaseUrl)) { $this->apiBaseUrl = URL::to('/'); } //Set API url if empty if (empty($this->apiUrl)) { $this->apiUrl = $this->apiBaseUrl . '/api/' . $this->apiVersion; } //Get the webste OAuth Client credentials $oauthClient = OauthClient::where('name', '=', 'website')->first(); if (is_object($oauthClient)) { $this->clientId = $oauthClient->id; $this->clientSecret = $oauthClient->secret; } unset($oauthClient); Blade::extend(function ($view) { return preg_replace(array('#@translate\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@translate\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Translate::t("$1")', 'Translate::t(\'$1\')'), $view); }); Blade::extend(function ($view) { return preg_replace(array('#@option\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@option\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Option::getAttribute(\'$1\')', 'Option::getAttribute(\'$1\')'), $view); }); Blade::extend(function ($view) { return preg_replace(array('#@hasPermission\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@hasPermission\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Access::has(\'$1\')', 'Access::has(\'$1\')'), $view); }); $this->getAccessToken(); View::share('basePath', Request::getBaseURL()); }
/** * Bootstrap any application services. * * @return void */ public function boot() { Blade::extend(function ($value) { return preg_replace('/@define(.+)/', '<?php ${1}; ?>', $value); }); }
/** * register blade extensions. */ protected function registerBladeExtensions() { Blade::extend(BladeExtension::comment()); Blade::extend(BladeExtension::script()); }
private function registerBladeExtensions() { Blade::extend(function ($view, $compiler) { return preg_replace($compiler->createMatcher('tabs'), '$1<?php echo Tabs::make$2; ?>', $view); }); Blade::extend(function ($html, $compiler) { return preg_replace($compiler->createMatcher('menu'), '$1<?php echo Menu::make$2; ?>', $html); }); Blade::extend(function ($html) { return preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $html); }); Blade::extend(function ($html, $compiler) { return preg_replace($compiler->createMatcher('form'), '$1<?php echo Form::make$2; ?>', $html); }); Blade::extend(function ($html, $compiler) { return preg_replace($compiler->createMatcher('paginate'), '$1<?php echo paginate$2; ?>', $html); }); }
public function boot() { /*-------------------------------------------------------------------------- | Pulish configuration file |--------------------------------------------------------------------------*/ $this->publishes([__DIR__ . '/config.php' => config_path('themes.php')]); /*-------------------------------------------------------------------------- | Extend Blade to support Orcherstra\Asset (Asset Managment) | | Syntax: | | @css (filename, alias, depends-on-alias) | @js (filename, alias, depends-on-alias) |--------------------------------------------------------------------------*/ Blade::extend(function ($value) { return preg_replace_callback('/\\@js\\s*\\(\\s*([\\w\\-\\._:\\/]*)\\s*(?:,\\s*([\\w\\-\\._:\\/]*)\\s*,?\\s*(.*))?\\)/', function ($match) { $p1 = \Theme::url($match[1]); $p2 = empty($match[2]) ? $match[1] : $match[2]; $p3 = empty($match[3]) ? '' : $match[3]; if (empty($p2)) { return "<?php Asset::script('{$p2}', '{$p1}');?>"; } elseif (empty($p3)) { return "<?php Asset::script('{$p2}', '{$p1}');?>"; } else { return "<?php Asset::script('{$p2}', '{$p1}', '{$p3}');?>"; } }, $value); }); Blade::extend(function ($value) { return preg_replace_callback('/\\@css\\s*\\(\\s*([\\w\\-\\._:\\/]*)\\s*(?:,\\s*([\\w\\-\\._:\\/]*)\\s*,?\\s*(.*))?\\)/', function ($match) { $p1 = \Theme::url($match[1]); $p2 = empty($match[2]) ? $match[1] : $match[2]; $p3 = empty($match[3]) ? '' : $match[3]; if (empty($p2)) { return "<?php Asset::style('{$p2}', '{$p1}');?>"; } elseif (empty($p3)) { return "<?php Asset::style('{$p2}', '{$p1}');?>"; } else { return "<?php Asset::style('{$p2}', '{$p1}', '{$p3}');?>"; } }, $value); }); }
public function boot() { /*-------------------------------------------------------------------------- | Pulish configuration file |--------------------------------------------------------------------------*/ /*$this->publishes([ __DIR__.'/config.php' => config_path('themes.php'), ]);*/ /*-------------------------------------------------------------------------- | Extend Blade to support Orcherstra\Asset (Asset Managment) | | Syntax: | | @css (filename, alias, depends-on-alias) | @js (filename, alias, depends-on-alias) |--------------------------------------------------------------------------*/ Blade::extend(function ($value) { return preg_replace_callback('/\\@js\\s*\\(\\s*([^),]*)(?:,\\s*([^),]*))?(?:,\\s*([^),]*))?\\)/', function ($match) { $p1 = trim($match[1], " \t\n\r\v\"'"); $p2 = trim(empty($match[2]) ? $p1 : $match[2], " \t\n\r\v\"'"); $p3 = trim(empty($match[3]) ? '' : $match[3], " \t\n\r\v\"'"); if (empty($p3)) { return "<?php Asset::script('{$p2}', \\Theme::url('{$p1}'));?>"; } else { return "<?php Asset::script('{$p2}', \\Theme::url('{$p1}'), '{$p3}');?>"; } }, $value); }); Blade::extend(function ($value) { return preg_replace_callback('/\\@css\\s*\\(\\s*([^),]*)(?:,\\s*([^),]*))?(?:,\\s*([^),]*))?\\)/', function ($match) { $p1 = trim($match[1], " \t\n\r\v\"'"); $p2 = trim(empty($match[2]) ? $p1 : $match[2], " \t\n\r\v\"'"); $p3 = trim(empty($match[3]) ? '' : $match[3], " \t\n\r\v\"'"); if (empty($p3)) { return "<?php Asset::style('{$p2}', \\Theme::url('{$p1}'));?>"; } else { return "<?php Asset::style('{$p2}', \\Theme::url('{$p1}'), '{$p3}');?>"; } }, $value); }); }
/** * Register the service provider. * * @return void */ public function register() { Blade::extend(function ($value) { return preg_replace('/\\@set(.+)/', '<?php ${1}; ?>', $value); }); }