Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 1.11 KB

filesystem_plugin.md

File metadata and controls

47 lines (33 loc) · 1.11 KB

Create a filesystem plugin

The only thing you have to do is to respect the Flysystem plugin API as all the plugins must implement the PluginInterface provided by the flysystem library.

<?php

namespace Acme\WebBundle\Services;

use League\Flysystem\Plugin\AbstractPlugin;

class ExamplePlugin extends AbstractPlugin
{
    public function getMethod()
    {
        return 'performThisMethod';
    }

    public function handle($dirname)
    {
        $filesystem = $this->filesystem;

        // Do something meaningfull.
    }
}

Register your plugin by creating a service:

<service id="acme_web.example_plugin" class="Acme\WebBundle\Services\ExamplePlugin" />

And configure your filesystem to use this plugin:

oneup_flysystem:
    filesystems:
        my_filesystem:
            adapter: #
            plugins:
                - acme_web.example_plugin

Afterwards, the plugin is registered on the configured filesystem and you should be able to call the performThisMethod method on that particular object.