当前位置: 首页>>代码示例>>PHP>>正文


PHP Blade::extend方法代码示例

本文整理汇总了PHP中Blade::extend方法的典型用法代码示例。如果您正苦于以下问题:PHP Blade::extend方法的具体用法?PHP Blade::extend怎么用?PHP Blade::extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Blade的用法示例。


在下文中一共展示了Blade::extend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: boot

 public function boot()
 {
     $directivesDirectory = base_path() . '/resources/views/directives';
     // Check if directory exists
     if (!File::exists($directivesDirectory)) {
         return;
     }
     $directivePaths = File::files($directivesDirectory);
     // Check if we have at least one file
     if (empty($directivePaths)) {
         return;
     }
     $regex = $this->buildRegex($directivePaths);
     \Blade::extend(function ($view) use($regex) {
         $offset = 0;
         while (preg_match($regex, $view, $matches, PREG_OFFSET_CAPTURE, $offset)) {
             // Store directive name
             $directiveName = $matches[1][0];
             // Store start and length of pattern
             $patternStart = $matches[0][1];
             $patternLength = strlen($matches[0][0]);
             $expressionStart = $matches[2][1];
             // Fetch expression
             $expr = $this->fetchExpression($view, $expressionStart, $patternStart + $patternLength);
             // Store beginning and end
             $beginning = substr($view, 0, $patternStart);
             $end = substr($view, $expressionStart + strlen($expr) + 1);
             // Construct view
             $view = $beginning . "@include('directives.{$directiveName}', array('param' => ({$expr})))" . $end;
             // Compute new offset to search from
             $offset = $patternStart + strlen($expr);
         }
         return $view;
     });
 }
开发者ID:thejager,项目名称:directives,代码行数:35,代码来源:DirectivesServiceProvider.php

示例2: registerBladeTemplate

 /**
  * Register the view environment.
  */
 public function registerBladeTemplate()
 {
     /*
     |--------------------------------------------------------------------------
     | @lm-attrs
     |--------------------------------------------------------------------------
     |
     | Buffers the output if there's any.
     | The output will be passed to mergeStatic()
     | where it is merged with item's attributes
     |
     */
     \Blade::extend(function ($view, $compiler) {
         $pattern = '/(\\s*)@lm-attrs\\s*\\((\\$[^)]+)\\)/';
         return preg_replace($pattern, '$1<?php $lm_attrs = $2->attr(); ob_start(); ?>', $view);
     });
     /*
     |--------------------------------------------------------------------------
     | @lm-endattrs
     |--------------------------------------------------------------------------
     |
     | Reads the buffer data using ob_get_clean()
     | and passes it to MergeStatic().
     | mergeStatic() takes the static string,
     | converts it into a normal array and merges it with others.
     |
     */
     \Blade::extend(function ($view, $compiler) {
         $pattern = $compiler->CreatePlainMatcher('lm-endattrs');
         return preg_replace($pattern, '$1<?php echo \\Lavary\\Menu\\Builder::mergeStatic(ob_get_clean(), $lm_attrs); ?>$2', $view);
     });
 }
开发者ID:sunel,项目名称:laravel-layout,代码行数:35,代码来源:LavaryMenuServiceProvider.php

示例3: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     /* @eval($var++) */
     \Blade::extend(function ($view) {
         return preg_replace('/\\@eval\\((.+)\\)/', '<?php ${1}; ?>', $view);
     });
 }
开发者ID:codex-project,项目名称:develop,代码行数:12,代码来源:AppServiceProvider.php

示例4: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \Blade::extend(function ($value) {
         $value = preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
         return $value;
     });
 }
开发者ID:synthx,项目名称:infuse,代码行数:12,代码来源:AppServiceProvider.php

示例5: register

 /**
  * 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);
     });
 }
开发者ID:onefasteuro,项目名称:theme,代码行数:30,代码来源:ThemeServiceProvider.php

示例6: boot

 public function boot()
 {
     //@define $i = 'whatever'
     \Blade::extend(function ($value) {
         return preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
     });
 }
开发者ID:Synthx,项目名称:Acamar,代码行数:7,代码来源:BladeServiceProvider.php

示例7: registerPHP

 /**
  * register `@php()` directive
  */
 public static function registerPHP($tagName = 'php')
 {
     \Blade::extend(function ($view, $compiler) use($tagName) {
         $pattern = $compiler->createMatcher($tagName);
         $code = "<?php \$2 ?" . ">";
         return preg_replace($pattern, $code, $view);
     });
 }
开发者ID:grohiro,项目名称:laravel-blade-macro,代码行数:11,代码来源:Macro.php

示例8: boot

 /**
  * 引导任何应用服务。
  *
  * @return void
  */
 public function boot()
 {
     \Blade::extend(function ($view, $compiler) {
         $this->app->make('phpBlade')->php($view, $compiler);
         $this->app->make('phpBlade')->endphp($view, $compiler);
         $this->app->make('phpBlade')->datetime($view, $compiler);
         return $view;
     });
 }
开发者ID:shsrain,项目名称:SimpleCms,代码行数:14,代码来源:BladeServiceProvider.php

示例9: register

 public static function register()
 {
     foreach (static::$compiles as $function) {
         if (!method_exists(__CLASS__, $function = 'compile_' . $function)) {
             continue;
         }
         \Blade::extend(function ($view, $compiler) use($function) {
             return call_user_func([__CLASS__, $function], $view, $compiler);
         });
     }
 }
开发者ID:ycms,项目名称:framework,代码行数:11,代码来源:BladeExtend.php

示例10: boot

 public function boot()
 {
     /* @datetime($var) */
     \Blade::extend(function ($view, $compiler) {
         $pattern = $compiler->createOpenMatcher('datetime');
         return preg_replace($pattern, '$1<?php echo $2->format(\'m/d/Y H:i\')); ?>', $view);
     });
     /* @eval($var++) */
     \Blade::extend(function ($view) {
         return preg_replace('/\\@eval\\((.+)\\)/', '<?php ${1}; ?>', $view);
     });
 }
开发者ID:fetch404,项目名称:fetch404,代码行数:12,代码来源:BladeServiceProvider.php

示例11: boot

 public function boot()
 {
     $this->publishes([__DIR__ . '/../../../database/migrations/' => database_path('/migrations')], 'migrations');
     $this->publishes([__DIR__ . '/../../../config/' => config_path()], 'config');
     SiteConfig::macro('has_bonus', function () {
         return config('bonus') != null;
     });
     \Blade::extend(function ($view, $compiler) {
         $pattern = "/(?<!\\w)(\\s*)@blink\\(\\s*(.*?)\\)/";
         return preg_replace($pattern, '$1' . '<?php if($auth->admin || $auth->id == $2->user->id || $auth->id == $2->user->referral_id|| $auth->id == $2->user->new_referral_id) {?>' . PHP_EOL . '<a href="/bonus-management/view/<?php echo $2->id ?>">' . PHP_EOL . '#<?php echo (1024 + $2->id) ?>' . PHP_EOL . '</a>' . PHP_EOL . '<?php } else { ?>' . PHP_EOL . '<?php echo (1024 + $2->id) ?>' . PHP_EOL . '<?php }?>', $view);
     });
 }
开发者ID:mrwaim,项目名称:BonusModel,代码行数:12,代码来源:BonusModelServiceProvider.php

示例12: boot

 public function boot()
 {
     /*
     |--------------------------------------------------------------------------
     | Extend blade so we can define a variable
     | <code>
     | @define $variable = "whatever"
     | </code>
     |--------------------------------------------------------------------------
     */
     \Blade::extend(function ($value) {
         return preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
     });
 }
开发者ID:vazmer,项目名称:mudrosti-laravel,代码行数:14,代码来源:BladeServiceProvider.php

示例13: boot

 public function boot()
 {
     \Blade::extend(function ($view, $compiler) {
         $pattern = $compiler->createOpenMatcher('tab');
         return str_replace('-Ab-', '<a href="chords.php" class="Ab">Ab</a>', $view);
     });
     \Blade::extend(function ($view, $compiler) {
         $pattern = $compiler->createOpenMatcher('datetime');
         return preg_replace($pattern, '$1<?php echo $2->format(\'m/d/Y H:i\')); ?>', $view);
     });
     /* @eval($var++) */
     \Blade::extend(function ($view) {
         return preg_replace('/\\@eval\\((.+)\\)/', '<?php ${1}; ?>', $view);
     });
 }
开发者ID:Zizazao,项目名称:guitaleletabs,代码行数:15,代码来源:BladeServiceProvider.php

示例14: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \HTML::macro('activeClass', function ($path, $active = 'active') {
         if (Request::is($path . "*")) {
             return $active;
         }
         return '';
     });
     \Validator::resolver(function ($translator, $data, $rules, $messages) {
         return new CustomValidator($translator, $data, $rules, $messages);
     });
     \Blade::extend(function ($value) {
         return preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
     });
 }
开发者ID:GMSteuart,项目名称:PandaLove,代码行数:20,代码来源:AppServiceProvider.php

示例15: registerBladeExtensions

 public function registerBladeExtensions()
 {
     \Blade::extend(function ($view, $compiler) {
         $pattern = '/@content\\(\'(.*?)\'\\)(.*?)@endcontent/is';
         preg_match_all($pattern, $view, $result);
         if (is_array($result)) {
             for ($i = 0; count($result[1]) > $i; $i++) {
                 $replace = $result[0][$i];
                 $key = $result[1][$i];
                 $value = $result[2][$i];
                 if ($key && $value) {
                     $o = \KSPM\LCMS\Model\Content::where('key', '=', $key)->first();
                     if (!$o) {
                         $o = \KSPM\LCMS\Model\Content::create(array('key' => $key, 'value' => $value));
                     }
                     $o = "<?php echo \\KSPM\\LCMS\\Model\\Content::where('key', '=', '{$key}')->first()->value; ?>";
                     $view = str_replace($replace, $o, $view);
                 }
             }
         }
         $pattern = '/@editable_content\\(\'(.*?)\'\\)(.*?)@endeditable_content/is';
         preg_match_all($pattern, $view, $result);
         $cmswrapper = '<div class="laikacms-editable" data-id="%%%oid%%%">%%%php%%%</div>';
         if (is_array($result)) {
             for ($i = 0; count($result[1]) > $i; $i++) {
                 $replace = $result[0][$i];
                 $key = $result[1][$i];
                 $value = $result[2][$i];
                 if ($key && $value) {
                     $o = \KSPM\LCMS\Model\Content::where('key', '=', $key)->first();
                     if (!$o) {
                         $o = \KSPM\LCMS\Model\Content::create(array('key' => $key, 'value' => $value));
                     }
                     $o = "<?php \$c = \\KSPM\\LCMS\\Model\\Content::where('key', '=', '{$key}')->first()->value; echo str_replace('%%%oid%%%','{$o->id}', str_replace('%%%php%%%', \$c, '{$cmswrapper}')); ?>";
                     $view = str_replace($replace, $o, $view);
                 }
             }
         }
         return $view;
     });
 }
开发者ID:ksp-media,项目名称:laikacms,代码行数:41,代码来源:LCMSNextServiceProvider.php


注:本文中的Blade::extend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。