src/Repository/RepositoryManager.php
public function createRepository($model, $config)
    {
        $defaults = [
            'type' => 'db-soft',
            'key' => 'id',
            'deleted' => 'deleted'
        ];
        $config = array_merge($defaults, $config);
        
        switch ($config['type']) {
            case 'db':
                $repo = new DbRepository($config['db'], $config['table'], $model, $config['key']);
                break;
            case 'db-soft':
                $repo = new SoftDbRepository($config['db'], $config['table'], $model, $config['deleted'], $config['key']);
                break;
            default:
                throw new RepositoryException("Repository type '" . $config['type'] . "' not implemented");
        }
        
        $this->addRepository($repo);
        return $repo;
    }
public function createRepository($model, $config)
    {
        $defaults = [
            'type' => 'db-soft',
            'key' => 'id',
            'deleted' => 'deleted'
        ];
        $config = array_merge($defaults, $config);
        
        switch ($config['type']) {
            case 'db':
                $repo = new DbRepository($config['db'], $config['table'], $model, $config['key']);
                break;
            case 'db-soft':
                $repo = new SoftDbRepository($config['db'], $config['table'], $model, $config['deleted'], $config['key']);
                break;
            default:
                throw new RepositoryException("Repository type '" . $config['type'] . "' not implemented");
        }
        
        $this->addRepository($repo);
        return $repo;
    }
public function createRepository ( $ model , $ config ) { $ defaults = [ 'type' => 'db-soft' , 'key' => 'id' , 'deleted' => 'deleted' ] ; $ config = array_merge ( $ defaults , $ config ) ; switch ( $ config [ 'type' ] ) { case 'db' : $ repo = new DbRepository ( $ config [ 'db' ] , $ config [ 'table' ] , $ model , $ config [ 'key' ] ) ; break ; case 'db-soft' : $ repo = new SoftDbRepository ( $ config [ 'db' ] , $ config [ 'table' ] , $ model , $ config [ 'deleted' ] , $ config [ 'key' ] ) ; break ; default : throw new RepositoryException ( "Repository type '" . $ config [ 'type' ] . "' not implemented" ) ; } $ this -> addRepository ( $ repo ) ; return $ repo ; }
Create a new repository and add it to the manager.

@param string            $model  Model class.
@param array             $config Repository configuration.

@return ManagedRepository        The created repository.

@throws RepositoryException      If the requested repository type is not implemented.
Create a new repository and add it to the manager .