有没有办法扩展 Laravel 4 的分页类?
我尝试了一些东西,但没有什么好...
我在这 :
分页服务提供者.php
class PaginationServiceProvider extends \Illuminate\Pagination\PaginationServiceProvider {
/**
* Indicates if loading of the provider is deferred.
* @var bool
*/
protected $defer = false;
/**
* Bootstrap the application events.
* @return void
*/
public function boot(){
$this->package('thujohn/pagination');
}
/**
* Register the service provider.
* @return void
*/
public function register(){
$this->app['paginator'] = $this->app->share(function($app){
$paginator = new Environment($app['request'], $app['view'], $app['translator']);
$paginator->setViewName($app['config']['view.pagination']);
return $paginator;
});
}
/**
* Get the services provided by the provider.
* @return array
*/
public function provides(){
return array();
}
}
环境.php
class Environment extends \Illuminate\Pagination\Environment {
public function hello(){
return 'hello';
}
}
我用 'Thujohn\Pagination\PaginationServiceProvider' 替换了' Illuminate \Pagination\ PaginationServiceProvider',
当我调用$test->links()就可以了
当我调用$test->hello()它失败了
当我打电话给Paginator::hello()没关系
任何的想法 ?