Created
August 25, 2014 09:00
-
-
Save ytake/e8c834e88473ea3f10e7 to your computer and use it in GitHub Desktop.
laravel-smarty registerFilter in ServiceProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
class ApplicationServiceProvider extends ServiceProvider | |
{ | |
public function boot() | |
{ | |
$this->registerFilters(); | |
} | |
/** | |
* Register the service provider. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
} | |
public function registerFilters() | |
{ | |
$smarty = $this->app['view']->getSmarty(); | |
$smarty->registerFilter('post', [$this, 'add_header_comment']); | |
} | |
/** | |
* @param $tpl_source | |
* @param $smarty | |
* @return string | |
*/ | |
public function add_header_comment($tpl_source, $smarty) | |
{ | |
return "<?php echo \"<!-- Created by Smarty From ServiceProvider! -->\n\"; ?>\n".$tpl_source; | |
} | |
} |
Same error,
Call to undefined method Illuminate\View\Factory::getSmarty()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's get that error "Method Illuminate\View\Factory::getSmarty does not exist."