<commit_before><?php

namespace Bolt\Filesystem;

use Silex\Application;
use League\Flysystem\Adapter\Local as FilesystemAdapter;
use League\Flysystem\Filesystem;

/**
* 
*/
class Manager
{
    
    
    public $app;
    public $managers = array();
    
    public function __construct(Application $app)
    {
        $this->app = $app;
        $this->managers['default'] = new Filesystem( new FilesystemAdapter($app['resources']->getPath('files')) );
        //$this->managers['default']->addPlugin(new PublicUrlPlugin('files'));
        
        $this->managers['config'] = new Filesystem( new FilesystemAdapter($app['resources']->getPath('config')) );
    }
    
    
    public function getManager($namespace = null)
    {
        if(isset($this->managers[$namespace])) {
            $manager = $this->managers[$namespace];
        } else {
            $manager = $this->managers['default'];
        }
        
        $manager->addPlugin(new SearchPlugin);
        $manager->addPlugin(new BrowsePlugin);
        return $manager;
    }
    
    public function setManager($namespace, $manager)
    {
        $this->managers[$namespace] = $manager;
    }
    
    <commit_msg>refactor init to be called on constructor<commit_after><?php

namespace Bolt\Filesystem;

use Silex\Application;
use League\Flysystem\Adapter\Local as FilesystemAdapter;
use League\Flysystem\Filesystem;

/**
* 
*/
class Manager
{
    
    
    public $app;
    public $managers = array();
    
    public function __construct(Application $app)
    {
        $this->app = $app;
        $this->managers['default'] = new Filesystem( new FilesystemAdapter($app['resources']->getPath('files')) );        
        $this->managers['config'] = new Filesystem( new FilesystemAdapter($app['resources']->getPath('config')) );
        $this->initManagers();
    }
    
    public function initManagers()
    {
        foreach($this->managers as $namespace=>$manager) {
            $manager->addPlugin(new SearchPlugin);
            $manager->addPlugin(new BrowsePlugin);
            if($namespace == 'default') {
                $manager->addPlugin(new PublicUrlPlugin('files'));
            } else {
                $manager->addPlugin(new PublicUrlPlugin($namespace));
            }
        }
    }
    
    
    public function getManager($namespace = null)
    {
        if(isset($this->managers[$namespace])) {
            $manager = $this->managers[$namespace];
        } else {
            $manager = $this->managers['default'];
        }
        
        return $manager;
    }
    
    public function setManager($namespace, $manager)
    {
        $this->managers[$namespace] = $manager;
    }
    
    
{'fraction_non_alphanumeric': 0.14365671641791045, 'fraction_numerical': 0.0, 'mean_word_length': 2.428388746803069, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3204775', 'n_tokens_mistral': 761, 'n_tokens_neox': 756, 'n_words': 134}