All Downloads are FREE. Search and download functionalities are using the official Maven repository.

php-symfony.ApiPass.mustache Maven / Gradle / Ivy

There is a newer version: 3.0.0-rc1
Show newest version
partial_header}}
/**
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen
 * Do not edit the class manually.
 */

namespace {{invokerPackage}}\DependencyInjection\Compiler;

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

/**
 * {{bundleName}}ApiPass Class Doc Comment
 *
 * @category Class
 * @package  {{invokerPackage}}\DependencyInjection\Compiler
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class {{bundleName}}ApiPass implements CompilerPassInterface
{

    /**
     * You can modify the container here before it is dumped to PHP code.
     *
     * @param ContainerBuilder $container
     */
    public function process(ContainerBuilder $container) {
        // always first check if the primary service is defined
        if (!$container->has('{{bundleAlias}}.api.api_server')) {
            return;
        }

        $definition = $container->findDefinition('{{bundleAlias}}.api.api_server');

        // find all service IDs with the {{bundleAlias}}.api tag
        $taggedServices = $container->findTaggedServiceIds('{{bundleAlias}}.api');

        foreach ($taggedServices as $id => $tags) {
            foreach ($tags as $tag) {
                // add the transport service to the ChainTransport service
                $definition->addMethodCall('addApiHandler', [$tag['api'], new Reference($id)]);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy