/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
public static function register(FilesystemInterface $outerFileSystem, $secondArgument) { foreach (["addPathToIndex", "removePathFromIndex", "getMetadataFromIndex"] as $method) { $outerFileSystem->addPlugin(new static($method, $secondArgument)); } }
/** * @param FilesystemInterface $filesystem */ function __construct(FilesystemInterface $filesystem) { $this->filesystem = $filesystem; $this->filesystem->addPlugin(new ListWith()); }
/** * 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()); }
/** * Register a plugin. * * @param PluginInterface $plugin The plugin to register. * * @return $this */ public function addPlugin(PluginInterface $plugin) { return $this->fileSystem->addPlugin($plugin); }