<?php

namespace Becklyn\AssetsBundle\Entry;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;


/**
 * A helper compiler pass that automatically registers the given asset namespaces
 */
class RegisterEntryNamespacesCompilerPass implements CompilerPassInterface
{
    /**
     * Mapping from namespace => path.
     * {@see EntryNamespaces::addNamespace()}
     *
     * @var array
     */
    private $mapping;

    /**
     * @param array $mapping
     */
    public function __construct (array $mapping)
    {
        $this->mapping = $mapping;
    }


    /**
     * @inheritdoc
     */
    public function process (ContainerBuilder $container)
    {
        $entryNamespaces = $container->getDefinition(EntryNamespaces::class);

        foreach ($this->mapping as $namespace => $path)
        {
            $entryNamespaces->addMethodCall("addNamespace", [$namespace, $path]);
        }
    }
}

Add helper compiler pass to register entry namespaces
Add helper compiler pass to register entry namespaces
