本文整理汇总了PHP中League\Flysystem\FilesystemInterface::addPlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface::addPlugin方法的具体用法?PHP FilesystemInterface::addPlugin怎么用?PHP FilesystemInterface::addPlugin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\FilesystemInterface
的用法示例。
在下文中一共展示了FilesystemInterface::addPlugin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Prepare driver before mount volume.
* Return true if volume is ready.
*
* @return bool
**/
protected function init()
{
$this->fs = $this->options['filesystem'];
if (!$this->fs instanceof FilesystemInterface) {
return $this->setError('A filesystem instance is required');
}
// flysystem cache object instance (cached adapter dose not have method like a `getCache()`.
if (isset($this->options['fscache']) && interface_exists('\\League\\Flysystem\\Cached\\CacheInterface', false)) {
if ($this->options['fscache'] instanceof \League\Flysystem\Cached\CacheInterface) {
$this->fscache = $this->options['fscache'];
}
}
$this->fs->addPlugin(new GetUrl());
$this->fs->addPlugin(new HasDir());
$this->options['icon'] = $this->options['icon'] ?: $this->getIcon();
$this->root = $this->options['path'];
if ($this->options['glideURL']) {
$this->urlBuilder = UrlBuilderFactory::create($this->options['glideURL'], $this->options['glideKey']);
}
if ($this->options['imageManager']) {
$this->imageManager = $this->options['imageManager'];
} else {
$this->imageManager = new ImageManager();
}
return true;
}
示例2: init
/**
* Prepare driver before mount volume.
* Return true if volume is ready.
*
* @return bool
**/
protected function init()
{
$this->fs = $this->options['filesystem'];
if (!$this->fs instanceof FilesystemInterface) {
return $this->setError('A filesystem instance is required');
}
$this->fs->addPlugin(new GetUrl());
$this->options['icon'] = $this->options['icon'] ?: $this->getIcon();
$this->root = $this->options['path'];
if ($this->options['glideURL']) {
$this->urlBuilder = UrlBuilderFactory::create($this->options['glideURL'], $this->options['glideKey']);
}
if ($this->options['imageManager']) {
$this->imageManager = $this->options['imageManager'];
} else {
$this->imageManager = new ImageManager();
}
return true;
}
示例3: createFromFilesystem
/**
* Creates a Memory adapter from a Flysystem filesystem.
*
* @param FilesystemInterface $filesystem The Flysystem filesystem.
*
* @return self A new memory adapter.
*/
public static function createFromFilesystem(FilesystemInterface $filesystem)
{
$filesystem->addPlugin(new ListWith());
$adapter = new static();
$config = new Config();
foreach ($filesystem->listWith(['timestamp', 'visibility'], '', true) as $meta) {
if ($meta['type'] === 'dir') {
$adapter->createDir($meta['path'], $config);
continue;
}
$adapter->write($meta['path'], (string) $filesystem->read($meta['path']), $config);
$adapter->setVisibility($meta['path'], $meta['visibility']);
$adapter->setTimestamp($meta['path'], $meta['timestamp']);
}
return $adapter;
}
示例4: init
/**
* Prepare driver before mount volume.
* Return true if volume is ready.
*
* @return bool
**/
protected function init()
{
$this->fs = $this->options['filesystem'];
if (!$this->fs instanceof FilesystemInterface) {
return $this->setError('A filesystem instance is required');
}
if ($this->fs instanceof Filesystem) {
$adapter = $this->fs->getAdapter();
// If the Flysystem adapter already is a cache, try to determine the cache.
if ($adapter instanceof CachedAdapter) {
// Try to get the cache (method doesn't exist in all versions)
if (method_exists($adapter, 'getCache')) {
$this->fscache = $adapter->getCache();
} elseif ($this->options['fscache'] instanceof CacheInterface) {
$this->fscache = $this->options['fscache'];
}
} elseif ($this->options['cache']) {
switch ($this->options['cache']) {
case 'session':
$this->fscache = new SessionStore($this->session, 'fls_cache_' . $this->id);
break;
case 'memory':
$this->fscache = new MemoryStore();
break;
}
if ($this->fscache) {
$adapter = new CachedAdapter($adapter, $this->fscache);
$this->fs = new Filesystem($adapter);
}
}
}
$this->fs->addPlugin(new GetUrl());
$this->options['icon'] = $this->options['icon'] ?: (empty($this->options['rootCssClass']) ? $this->getIcon() : '');
$this->root = $this->options['path'];
if ($this->options['glideURL']) {
$this->urlBuilder = UrlBuilderFactory::create($this->options['glideURL'], $this->options['glideKey']);
}
if ($this->options['imageManager']) {
$this->imageManager = $this->options['imageManager'];
} else {
$this->imageManager = new ImageManager();
}
return true;
}
示例5: register
public static function register(FilesystemInterface $outerFileSystem, $secondArgument)
{
foreach (["addPathToIndex", "removePathFromIndex", "getMetadataFromIndex"] as $method) {
$outerFileSystem->addPlugin(new static($method, $secondArgument));
}
}
示例6: ListWith
/**
* @param FilesystemInterface $filesystem
*/
function __construct(FilesystemInterface $filesystem)
{
$this->filesystem = $filesystem;
$this->filesystem->addPlugin(new ListWith());
}
示例7: registerPlugins
/**
* Registers plugins on the filesystem.
*
* @param string $protocol
* @param FilesystemInterface $filesystem
*/
protected static function registerPlugins($protocol, FilesystemInterface $filesystem)
{
$filesystem->addPlugin(new ForcedRename());
$filesystem->addPlugin(new Mkdir());
$filesystem->addPlugin(new Rmdir());
$stat = new Stat(static::$config[$protocol]['permissions'], static::$config[$protocol]['metadata']);
$filesystem->addPlugin($stat);
$filesystem->addPlugin(new Touch());
}
示例8: addPlugin
/**
* Register a plugin.
*
* @param PluginInterface $plugin The plugin to register.
*
* @return $this
*/
public function addPlugin(PluginInterface $plugin)
{
return $this->fileSystem->addPlugin($plugin);
}