基于我的PHP知识,我不知道Laravel门面如何工作,我尝试扩展存储外观以添加一些新功能。如何扩展Laravel仓库门面?
我有这样的代码:
class MyStorageFacade extends Facade {
/**
* Get the binding in the IoC container
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'MyStorage'; // the IoC binding.
}
}
虽然启动服务提供商:
$this->app->bind('MyStorage',function($app){
return new MyStorage($app);
});
,门面是:
class MyStorage extends \Illuminate\Support\Facades\Storage{
}
当使用它:
use Namespace\MyStorage\MyStorageFacade as MyStorage;
MyStorage::disk('local');
我得到这个错误:
FatalThrowableError in Facade.php line 237: Call to undefined method Namespace\MyStorage\MyStorage::disk()
也试图扩大MyStorage
形式Illuminate\Filesystem\Filesystem
并得到了在其他的方式相同的错误:
BadMethodCallException in Macroable.php line 74: Method disk does not exist.
正如我所说,我测试过,并得到这个错误:'BadMethodCallException在Macroable.php线74:方法磁盘不exist.' – Omid
@Omid'disk'是没有定义是怎样的任何地方。 – apokryfos
那么'\ Storage :: disk('local')'如何在这种情况下工作? @apokryfos – Omid