基於我的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