ParserConfigurator.php 751 Bytes
<?php
namespace yii\multiparser;

class ParserConfigurator
{

    protected static $configuration = [
        'csv' =>
            ['web' =>
                ['class' => 'backend\components\parsers\CustomCsvParser',
                    'auto_detect_first_line' => true,]]];


    public static function getConfiguration($extension, $mode)
    {
        if (!isset( self::$configuration[$extension] )){
            throw new \ErrorException( "Parser do not maintain file with extension  {$extension}");
        }
        if (!isset( self::$configuration[$extension][$mode] )){
            throw new \ErrorException( "Parser configurator do not have settings for {$mode} mode");
        }

        return self::$configuration[$extension][$mode];
    }

}