Registers plugins on the filesystem.
@param string $protocol
@param FilesystemInterface $filesystem
424569
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());
    }
169591
public function handle(Filesystem $filesystem)
    {
        $this->filesystem = $filesystem;

        $this->extensionDir = config('admin.extension_dir');

        InputExtensionDir:
        if (empty($this->extensionDir)) {
            $this->extensionDir = $this->ask('Please input a directory to store your extension:');
        }

        if (!file_exists($this->extensionDir)) {
            $this->makeDir();
        }

        $this->package = $this->argument('extension');

        InputExtensionName:
        if (!$this->validateExtensionName($this->package)) {
            $this->package = $this->ask("[$this->package] is not a valid package name, please input a name like (<vendor>/<name>)");
            goto InputExtensionName;
        }

        $this->makeDirs();
        $this->makeFiles();

        $this->info("The extension scaffolding generated successfully. \r\n");
        $this->showTree();
    }
1064924
private function registerPlugin(Plugin $plugin): void
    {
        if ($this->hasPlugin($plugin->getName())) {
            return;
        }

        $this->plugins[$plugin->getName()] = $plugin;
    }
247698
protected function publishing(Filesystem $filesystem, $force = false)
    {
        $this->publishFiles($filesystem, (array) $this->publishes(), $force);
    }
303937
private function composeWebController(
        SettingsProviderInterface $settingsProvider,
        FileSystemInterface $fileSystem,
        string $singular,
        string $plural
    ): TemplateOutput {
        $folder = $settingsProvider
                      ->get(FluteSettingsInterface::class)[FluteSettingsInterface::KEY_WEB_CONTROLLERS_FOLDER];

        $outputRootFolder = $this->filterOutFolderMask($folder);
        $outputFileName   = $plural . 'Controller.php';
        $outputContent    = $this->composeTemplateContent(
            $fileSystem,
            $this->getTemplatePath('WebController.txt'),
            [
                '{%SINGULAR_CC%}' => $singular,
                '{%PLURAL_CC%}'   => $plural,
                '{%PLURAL_LC%}'   => strtolower($plural),
                '{%PLURAL_UC%}'   => strtoupper($plural),
            ]
        );

        return new TemplateOutput($outputRootFolder, $outputFileName, $outputContent);
    }
842443
public void registerProtocol(String protocol, IOProviderFrom<URL> provider) {
		protocols.put(protocol.toLowerCase(), provider);
	}
511257
public function process(ContainerBuilder $container): void
    {
        if (true === self::enabled($container))
        {
            $excludedFiles = canonicalizeFilesPath(self::getExcludedFiles($container));

            $files = searchFiles(self::getDirectories($container), '/\.php/i');

            $this->registerClasses($container, $files, $excludedFiles);
        }
    }
997128
public function setProtectedFilesystem(Filesystem $filesystem)
    {
        if (!$filesystem->getAdapter() instanceof ProtectedAdapter) {
            throw new InvalidArgumentException("Configured adapter must implement ProtectedAdapter");
        }
        $this->protectedFilesystem = $filesystem;
        return $this;
    }
946811
public function registerPlugin($plugin)
    {
        if ($plugin instanceof IOrmPlugin) {
            $this->plugins[] = $plugin;
        } elseif (is_string($plugin) && $this->iocContainer) {
            $this->plugins[] = $this->iocContainer->get($plugin);
        } else {
            throw InvalidArgumentException::format(
                'Invalid plugin supplied to %s: ioc container must be available to resolve class',
                __METHOD__
            );
        }
    }
1129754
public function listContents($filesystem, $path = '')
    {
        $this->set([
            '_serialize' => [
                'directoryContents',
            ],
            'directoryContents' => $this->filesystem($filesystem)->listContents($path),
        ]);
    }
521030
protected function publishRoute(Filesystem $filesystem, $route)
    {
        if (is_null($route)) {
            return ;
        }

        $routeFile = app_path('Http/routes.php');

        if ($filesystem->exists($routeFile) && $filesystem->exists($route)) {
            $filesystem->append($routeFile, $filesystem->get($route));

            $this->line('<info>Append routes from</info> <comment>['.$route.']</comment>');
        }
    }
1041569
public function install(PluginBundleInterface $plugin)
    {
        $this->checkInstallationStatus($plugin, false);
        $this->validatePlugin($plugin);
        $this->log('Saving plugin configuration...');
        $this->recorder->register($plugin, $this->validator->getPluginConfiguration());
        $this->baseInstaller->install($plugin);
    }
752608
protected function run(ContainerInterface $container, IoInterface $inOut): void
    {
        $item     = $inOut->getArguments()[static::ARG_ITEM];
        $singular = $inOut->getArguments()[static::ARG_SINGULAR];
        $plural   = $inOut->getArguments()[static::ARG_PLURAL];

        if ($this->isValidShortClassName($singular) === false) {
            throw new InvalidArgumentException("`$singular` is not a valid class name.");
        }
        if ($this->isValidShortClassName($plural) === false) {
            throw new InvalidArgumentException("`$plural` is not a valid class name.");
        }

        /** @var FileSystemInterface $fileSystem */
        $fileSystem = $container->get(FileSystemInterface::class);
        /** @var SettingsProviderInterface $settingsProvider */
        $settingsProvider = $container->get(SettingsProviderInterface::class);

        $dataTemplates = function () use ($settingsProvider, $fileSystem, $singular, $plural) : array {
            return [
                $this->composeMigration($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeSeed($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeModel($settingsProvider, $fileSystem, $singular, $plural),
            ];
        };

        $basicTemplates = function () use ($settingsProvider, $fileSystem, $singular, $plural) : array {
            return [
                $this->composeSchema($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeAuthorization($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeApi($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeValidationRules($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeQueryValidationOnReadRules($settingsProvider, $fileSystem, $singular, $plural),
            ];
        };

        $webTemplates = function () use ($settingsProvider, $fileSystem, $singular, $plural) : array {
            return [
                $this->composeWebValidationOnCreateRules($settingsProvider, $fileSystem, $singular),
                $this->composeWebValidationOnUpdateRules($settingsProvider, $fileSystem, $singular),
                $this->composeWebController($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeWebRoute($settingsProvider, $fileSystem, $singular, $plural),
            ];
        };

        $jsonTemplates = function () use ($settingsProvider, $fileSystem, $singular, $plural) : array {
            return [
                $this->composeJsonValidationOnCreateRules($settingsProvider, $fileSystem, $singular),
                $this->composeJsonValidationOnUpdateRules($settingsProvider, $fileSystem, $singular),
                $this->composeJsonController($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeJsonRoute($settingsProvider, $fileSystem, $singular, $plural),
            ];
        };

        switch ($item) {
            case static::ITEM_DATA_RESOURCE:
                $this->createTemplates($fileSystem, array_merge(
                    $dataTemplates()
                ));
                break;
            case static::ITEM_WEB_RESOURCE:
                $this->createTemplates($fileSystem, array_merge(
                    $dataTemplates(),
                    $basicTemplates(),
                    $webTemplates()
                ));
                break;
            case static::ITEM_JSON_API_RESOURCE:
                $this->createTemplates($fileSystem, array_merge(
                    $dataTemplates(),
                    $basicTemplates(),
                    $jsonTemplates()
                ));
                break;
            case static::ITEM_FULL_RESOURCE:
                $this->createTemplates($fileSystem, array_merge(
                    $dataTemplates(),
                    $basicTemplates(),
                    $webTemplates(),
                    $jsonTemplates()
                ));
                break;
            default:
                $inOut->writeError("Unsupported item type `$item`." . PHP_EOL);
                break;
        }
    }
1012840
static function register($protocol = 'sftp')
    {
        if (in_array($protocol, stream_get_wrappers(), true)) {
            return false;
        }
        $class = function_exists('get_called_class') ? get_called_class() : __CLASS__;
        return stream_wrapper_register($protocol, $class);
    }
625453
public static function configureAsRoot(): void
    {
        $filesystem = new Filesystem();
        $vendor_dir = Path::VENDOR_DIR . '/hostnet/phpcs-tool/src';
        if ($filesystem->exists($vendor_dir)) {
            return;
        }

        self::configure();

        $filesystem->mkdir($vendor_dir . '/Hostnet');
        $filesystem->symlink(__DIR__ . '/../../Sniffs', $vendor_dir . '/Hostnet/Sniffs');
        $filesystem->copy(__DIR__ . '/../../ruleset.xml', $vendor_dir . '/Hostnet/ruleset.xml');

        $filesystem->mkdir($vendor_dir . '/HostnetPaths');
        $filesystem->copy(__DIR__ . '/../../../HostnetPaths/ruleset.xml', $vendor_dir . '/HostnetPaths/ruleset.xml');
    }
879839
public function registerModules(string $filePath = null)
    {
        is_file($filePath) || $filePath = App::getBasePath() . $filePath;

        if (is_file($filePath)) {
            /** @var Registry $modules */

            /** @noinspection PhpIncludeInspection */
            $modules = require_once $filePath;

            $modules = is_array($modules) ? $modules : [];

            foreach ($modules as $module) {
                IOC::resolve('Modules')->register($module);
            }

            Event::dispatch('minimal.loaded.modules', [$filePath, $modules]);
        }
    }
118427
private function registerGuzzlePlugin(Definition $clientDefinition, array $plugins)
    {
        foreach ($plugins as $pluginId => $attributes) {
            $clientDefinition->addMethodCall(
                'addSubscriber',
                array(new Reference($pluginId))
            );
        }
    }