Q:

Symfony: How to load custom bundle config from file?

I am using Symfony 3.4. How can I add a custom config file to a custom bundle which should hold a list of names and regular expressions? For example:
// Config file content = list of names and regular expressions
NameA
NameB
Name[cC]+
Some\w+Other(Name|Pattern)
...

// Symfony controller
$patterns = $this->getPatternConfigFromFileSomehow(...);

In in the Symfony docs I found information on adding custom config to the .yml files in the app/config or MyBundle/Resources/config dirs. However, this is not about a small set of well defined parameters (e.g. mailaddress: xyz) but list of any number of entries.
Additionally the config should only be loaded if its actually used and not every time the kernel or a services is created.
Of course I could simply use file_get_contents or any similar PHP method to load any file, however this seems to be quite hacky and not the "Symfony way"...
So, what is the "correct" way of doing this?
EDIT:
yml files are great to configure parameters, but this is not about parameters (= key + value) but a list of file names and regular expressions. This list does not have a defined length and the entries do not have defined names. Thus .yml is not the right solution here, is it?
Additionally config files which are added using the ConfigTreeBuilder are loaded when the kernel is loaded, aren't they? I am looking for a lazy solution which loads the list only when needed. 

A:

Put your yml file in any config directory (app/config,config,Resources/config) that is loaded. How you name the file does not 'really' matter. What matter is that your root node in this yml is the root node you define in 
/your-bundle/src/DependencyInjection/Configuration.php
if you defined it like this :
public function getConfigTreeBuilder()
{
    $treeBuilder = new TreeBuilder('your_root_node' );
    $treeBuilder->getRootNode()... 

    // with use of array prototypes... 

    $treeBuilder = new TreeBuilder('your_root_node');
    $rootNode = $treeBuilder->getRootNode();

    $rootNode
        ->children()
            ->arrayNode('fields')
                ->arrayPrototype()
                    ->children()
                        ->enumNode('type')
                            ->values(['iris','iri','entity','entities','datetime','string','integer','boolean','custom_class'])
                            ->defaultNull()
                        ->end()
                        ->enumNode('type_out')
                            ->values(['iris','iri','entity','entities','datetime','string','integer','boolean','custom_class'])
                            ->defaultNull()
                        ->end()
                        ->scalarNode('entity')->defaultNull()->end()
                        ->scalarNode('customClass')->defaultNull()->end()
                        ->arrayNode('parameters')
                            ->useAttributeAsKey('name')
                            ->scalarPrototype()->end()
                        ->end()
                        ->booleanNode('nullable')->defaultFalse()->end()
                    ->end()
                ->end()
            ->end()
        ->end()
    ;

    ...
}

Then you should have a yml file starting like this:
your_root_node:
    my_parameter:
    my_other_parameter:
        and_so_on:

Also, config file with definition don't have to be loaded with kernel and can be loaded 'lazily' in a service like this: 
    use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Processor;
class SchemaConfiguration implements ConfigurationInterface
{
    /**
     * {@inheritdoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('schema');
        $rootNode
            ... // Tree definition
            ->end()
        ;
        return $treeBuilder;
    }
    /**
     * @param $schemaConfig
     * @return mixed
     */
    public function getSchemaFromYaml($schemaConfig){
        $configuration = new SchemaConfiguration();
        $processor = new Processor();
        $processed = $processor->processConfiguration($configuration, $schemaConfig);
        $schema = $processed['fields'];
        return $schema ;
    }

}

