Skip to content

Commit

Permalink
Revert "Laravel 7 and autoload blade custom directives (#59)" (#62)
Browse files Browse the repository at this point in the history
This reverts commit 695330f. moved to new branch
  • Loading branch information
TerrePorter authored Aug 31, 2020
1 parent 695330f commit cfd8609
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 46 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/.netbeans/
/bkp/
vendor/
/bkp/
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,7 @@ In config\app.php, providers section:
Config
=======================

Default cache time for the compiled string template is 300 seconds (5 mins), this can be changed in the config file, env file, or when calling a view. The change is global to all string templates.

`STRING_BLADE_CACHE_TIMEOUT=300`

Autoloading of blade custom directives can be changed in the config and env files.

`STRING_BLADE_AUTOLOAD=false`
Default cache time for the compiled string template is 300 seconds (5 mins), this can be changed in the config file or when calling a view. The change is global to all string templates.

Note: If using homestead or some other vm, the host handles the filemtime of the cache file. This means the vm may have a different time than the file. If the cache is not expiring as expected, check the times between the systems.

Expand Down
4 changes: 1 addition & 3 deletions config/blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// How many seconds past compiled file last modified time to recompile the template
// A value of 0 is always recompile
// Note: homestead time verses pc time may be off
'secondsTemplateCacheExpires' => env('STRING_BLADE_CACHE_TIMEOUT', 300),
'secondsTemplateCacheExpires' => 300

// Determine whether the service provider to autoload blade custom directives.
'autoload_custom_directives' => env('STRING_BLADE_AUTOLOAD', false),
];
1 change: 1 addition & 0 deletions src/Compilers/StringBladeCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@ public function isExpired($viewData)

return time() >= ($this->files->lastModified($compiled) + $viewData->secondsTemplateCacheExpires) ;
}

}
38 changes: 4 additions & 34 deletions src/StringBladeServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?php
namespace Wpb\String_Blade_Compiler;

use Illuminate\View\Engines\EngineResolver;
use Illuminate\View\FileViewFinder;
use Illuminate\View\ViewServiceProvider;
use Illuminate\View\Engines\EngineResolver;
use Illuminate\Contracts\Support\DeferrableProvider;
use Wpb\String_Blade_Compiler\Engines\CompilerEngine;
use Wpb\String_Blade_Compiler\Compilers\StringBladeCompiler;
use Wpb\String_Blade_Compiler\Engines\CompilerEngine;

class StringBladeServiceProvider extends ViewServiceProvider implements DeferrableProvider
{
class StringBladeServiceProvider extends ViewServiceProvider{

/**
* Register the service provider.
Expand Down Expand Up @@ -150,32 +148,4 @@ public function registerStringBladeEngine($resolver)
return new CompilerEngine($app['stringblade.compiler']);
});
}

/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if(config('blade.autoload_custom_directives')) {
$blade = app('blade.compiler');
$string_blade = app('stringblade.compiler');

collect($blade->getCustomDirectives())
->each(function($directive, $name) use ($string_blade) {
$string_blade->directive($name, $directive);
});
}
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [StringBlade::class];
}
}
}

0 comments on commit cfd8609

Please sign in to comment.