Redefine Response object

@param array|ContainerInterface $container Instancia de Container o array de configuración.

@return void
321590
protected function redefineResponse(&$container)
    {
        // Redefine - response
        $container['response'] = function (Container $container) {
            $headers = new Headers(['Content-Type' => 'application/json;charset=utf-8']);
            $response = new Response(200, $headers);
            return $response->withProtocolVersion($container->get('settings')['httpVersion']);
        };
    }
765868
public function setContainer(Container $container = null)
    {
        $this->container = $container;
        $this->parameters = array();

        return $this;
    }
1251746
public function setContainer(ContainerInterface $container = null)
    {
        $this->abortIf(is_null($container), 'Requires DI container');

        $this->fs = $container->get('filesystem');
        $this->em = $container->get('doctrine.orm.entity_manager');
        $this->target = $container->getParameter('kernel.root_dir').'/../web/media/example/';
        $this->source = $container->get('kernel')->locateResource('@AnimeDbDevBundle/Resource/private/images/');
    }
314314
public function withContainer(ContainerInterface $container): ContainerizedInterface
    {
        $route = clone $this;
        $route->container = $container;
        if ($route->target instanceof TargetInterface) {
            $route->target = clone $route->target;
        }

        $route->pipeline = $route->makePipeline();

        return $route;
    }
134024
public function process(ContainerBuilder $container): void
    {
        $servicesReference = [];
        $serviceIds        = [];

        /**
         * @psalm-var array<string, array<mixed, string>> $taggedServices
         *
         * @var array $taggedServices
         */
        $taggedServices = $container->findTaggedServiceIds('service_bus.service');

        foreach ($taggedServices as $id => $tags)
        {
            /** @psalm-var class-string|null $serviceClass */
            $serviceClass = $container->getDefinition($id)->getClass();

            if (null !== $serviceClass)
            {
                $this->collectServiceDependencies($serviceClass, $container, $servicesReference);

                $serviceIds[] = $serviceClass;

                $servicesReference[\sprintf('%s_service', $serviceClass)] = new ServiceClosureArgument(
                    new Reference($id)
                );
            }
        }

        $container->setParameter('service_bus.services_map', $serviceIds);

        $container
            ->register('service_bus.services_locator', ServiceLocator::class)
            ->setPublic(true)
            ->setArguments([$servicesReference]);
    }
787371
protected function setDependencies(Container $container)
    {
        parent::setDependencies($container);

        if (isset($container['admin/config']['apis.google.map.key'])) {
            $this->setApiKey($container['admin/config']['apis.google.map.key']);
        } elseif (isset($container['config']['apis.google.map.key'])) {
            $this->setApiKey($container['config']['apis.google.map.key']);
        }

        /**
         * @todo Make this configurable
         */
        if (isset($appConfig['alert.map.map'])) {
            $this->setMapOptions($appConfig['alert.map']);
        }
    }
900243
public function prepareHandler(Container $container)
    {
        $handler = $container->get('config')->get('user.handler') ?: NullUserHandler::class;

        $container->bindShared(UserHandlerInterface::class, $handler);
    }
1267863
public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
        $this->application = null !== $container ? $this->container->get('bbapp') : null;
    }
1192067
public function handle(Container $container)
    {
        $class = new \ReflectionClass(get_class($this->methodInvocation->getThis()));
        if ($class->getFileName()) {
            $method = $this->methodInvocation->getMethod()->getName();
            $container->call(
                [
                    $this->methodInvocation->getThis(),
                    $method,
                ],
                $this->methodInvocation->getArguments()->getArrayCopy()
            );
        }
    }
777066
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition($this->subjectService)) {
            return;
        }

        $subjects = $this->findTaggedServices($container, $this->subjectTag, SubjectInterface::class, 'support', false);

        $subjectDefinition = $container->getDefinition($this->subjectService);
        $subjectDefinition->replaceArgument(0, $subjects);
    }
149355
protected function registerMethods(Container $container)
    {
        $orderedMethods = [];

        foreach ($this->methods as $methodClass) {
            /** @var MethodInterface $method */
            $method = new $methodClass();

            if ($method->isSupported()) {
                $container['method.'.$method->getName()] = function() use ($methodClass) {
                    return new $methodClass();
                };

                $orderedMethods[] = 'method.'.$method->getName();
            }
        }

        // order methods
        usort($orderedMethods, function ($methodName1, $methodName2) use ($container) {
            $value1 = ((int) $container[$methodName1]->isSupported()) + ($container[$methodName1]->getUncompressionSpeedLevel() / 10);
            $value2 = ((int) $container[$methodName2]->isSupported()) + ($container[$methodName2]->getUncompressionSpeedLevel() / 10);

            if ($value1 == $value2) {
                return 0;
            }

            return ($value1 > $value2) ? -1 : 1;
        });

        $container['method.__ordered'] = $orderedMethods;
    }
14660
public function process(ContainerBuilder $container)
    {
        $this->setServiceAlias( $container, HeliopsisEzFormsExtension::FACADE_SERVICE_ID );
        $this->setServiceAlias( $container, HeliopsisEzFormsExtension::FORM_PROVIDER_SERVICE_ID );
        $this->setServiceAlias( $container, HeliopsisEzFormsExtension::HANDLER_PROVIDER_SERVICE_ID );
        $this->setServiceAlias( $container, HeliopsisEzFormsExtension::RESPONSE_PROVIDER_SERVICE_ID );
    }
651845
private function getRedisConfig(ContainerInterface $container)
    {
        if (!$container->has('config')) {
            return [];
        }

        $config = $container->get('config');

        if (!isset($config['doctrine']['cache']['redis'])) {
            return [];
        }

        return $config['doctrine']['cache']['redis'];
    }
941907
public function register(Container $container)
    {
        $this->container = $container;

        // Register the PHP view loader if configuration says so
        if (strtolower($container["config.service"]["view.loader"]) === "php") {
            $container->register(new PHPLoaderProvider);
        }

        // Define view class loader
        $container["loadView.service"] = $container->protect(
            function (string $view, bool $useLayout = true) use ($container) {
                $cacheName = "loadView.service-{$view}" . ($useLayout ? "1" : "0");
                if (isset($container[$cacheName]) && isset($container["view.skipCache"]) === false) {
                    return $container[$cacheName];
                }

                $class = $container["view.className"] ?? $this->getViewClass($view);
                $view = new $class(
                    $container["config.service"],
                    $container["tplLoader.service"],
                    $container["response.service"]
                );

                if (method_exists($view, "init")) {
                    $args = func_get_args();
                    $args = array_slice($args, 2);
                    $view->init(...$args);
                }

                if ($useLayout && ($layoutName = $container["config.service"]["view.defaultLayout"]) !== "") {
                    $this->setLayout($layoutName, $view);
                }

                return $container[$cacheName] = $view;
            }
        );

        $container["loadTemplate.service"] = $container->protect(
            function (string $template, bool $useLayout = true) use ($container) {
                $cacheName = "loadTemplate.service-{$template}" . ($useLayout ? "1" : "0");
                if (isset($container[$cacheName])) {
                    return $container[$cacheName];
                }

                $container["view.skipCache"] = true;
                $container["view.className"] = \SlaxWeb\View\Base::class;
                $view = $container["loadView.service"]("", false);
                $view->template = $template;
                unset($container["view.skipCache"], $container["view.className"]);

                if ($useLayout && ($layoutName = $container["config.service"]["view.defaultLayout"]) !== "") {
                    $this->setLayout($layoutName, $view);
                }

                return $container[$cacheName] = $view;
            }
        );
    }
1293454
public function process(ContainerBuilder $container)
    {
        // First collect all alias targets that need to be replaced
        $seenAliasTargets = array();
        $replacements = array();
        foreach ($container->getAliases() as $definitionId => $target) {
            $targetId = $container->normalizeId($target);
            // Special case: leave this target alone
            if ('service_container' === $targetId) {
                continue;
            }
            // Check if target needs to be replaces
            if (isset($replacements[$targetId])) {
                $container->setAlias($definitionId, $replacements[$targetId])->setPublic($target->isPublic())->setPrivate($target->isPrivate());
            }
            // No need to process the same target twice
            if (isset($seenAliasTargets[$targetId])) {
                continue;
            }
            // Process new target
            $seenAliasTargets[$targetId] = true;
            try {
                $definition = $container->getDefinition($targetId);
            } catch (InvalidArgumentException $e) {
                throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with actual definition "%s".', $definitionId, $targetId), null, $e);
            }
            if ($definition->isPublic() || $definition->isPrivate()) {
                continue;
            }
            // Remove private definition and schedule for replacement
            $definition->setPublic(!$target->isPrivate());
            $definition->setPrivate($target->isPrivate());
            $container->setDefinition($definitionId, $definition);
            $container->removeDefinition($targetId);
            $replacements[$targetId] = $definitionId;
        }
        $this->replacements = $replacements;

        parent::process($container);
        $this->replacements = array();
    }
494392
public function addContainer(MutableContainerInterface $container): void
    {
        $containerName = get_class($container);
        if (array_key_exists($containerName, $this->registry)) {
            throw new ContainerAlreadyRegisteredException($containerName);
        }

        $this->registry[$containerName] = $container;
    }
797197
public function setContainer(ContainerInterface $container)
    {
        $application = $this;
        $container->share(ApplicationInterface::class, $application);
        $container->share(\Interop\Container\ContainerInterface::class, $container);

        $this->container = $container;

        return $this;
    }