removeAlias example

return null !== $class ? $configurator->class($class) : $configurator;
    }

    /** * Removes an already defined service definition or alias. * * @return $this */
    final public function remove(string $id)static
    {
        $this->container->removeDefinition($id);
        $this->container->removeAlias($id);

        return $this;
    }

    /** * Creates an alias. */
    final public function alias(string $id, string $referencedId): AliasConfigurator
    {
        $ref = static::processValue($referencedId, true);
        $alias = new Alias((string) $ref);
        

      // Repeat if services have been removed.     } while ($has_changed);

    // Remove aliases to services that have been removed. This does not need to     // be part of the loop above because references to aliases have already been     // resolved by Symfony's ResolveReferencesToAliasesPass.     if ($process_aliases) {
      foreach ($container->getAliases() as $key => $alias) {
        $id = (string) $alias;
        if (!$container->has($id)) {
          $container->removeAlias($key);
          $container->log($thissprintf('Removed alias "%s"; reason: alias to non-existent service "%s".', $key$id));
        }
      }
    }
  }

  /** * Checks if a reference argument is to a missing service. * * @param mixed $argument * The argument to check. * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * The container. * * @return bool * TRUE if the argument is a reference to a service that is missing from the * container and the reference is required, FALSE if not. */
return null !== $class ? $configurator->class($class) : $configurator;
    }

    /** * Removes an already defined service definition or alias. * * @return $this */
    final public function remove(string $id)static
    {
        $this->container->removeDefinition($id);
        $this->container->removeAlias($id);

        return $this;
    }

    /** * Creates an alias. */
    final public function alias(string $id, string $referencedId): AliasConfigurator
    {
        $ref = static::processValue($referencedId, true);
        $alias = new Alias((string) $ref);
        

    public function process(ContainerBuilder $container)
    {
        foreach ($container->getAliases() as $id => $alias) {
            if ($alias->isPublic()) {
                continue;
            }

            $container->removeAlias($id);
            $container->log($thissprintf('Removed service "%s"; reason: private alias.', $id));
        }
    }
}

    public function process(ContainerBuilder $container)
    {
        foreach ($container->getAliases() as $id => $alias) {
            if ($alias->isPublic()) {
                continue;
            }

            $container->removeAlias($id);
            $container->log($thissprintf('Removed service "%s"; reason: private alias.', $id));
        }
    }
}


                if ('ignore' === ($attributes['on_invalid'] ?? null)) {
                    $attributes['method'] = '?'.$attributes['method'];
                }

                $methods[$id][] = $attributes['method'];
            }
        }

        if (!$services) {
            $container->removeAlias('services_resetter');
            $container->removeDefinition('services_resetter');

            return;
        }

        $container->findDefinition('services_resetter')
            ->setArgument(0, new IteratorArgument($services))
            ->setArgument(1, $methods);
    }
}
$aliasId = new Reference('alias_id');

        $container = new ContainerBuilder();
        $container->set($idnew \stdClass());
        $container->setAlias($aliasId, 'another_service');

        $this->assertTrue($container->has('another_service'));
        $this->assertTrue($container->has($id));
        $this->assertTrue($container->hasAlias('alias_id'));
        $this->assertTrue($container->hasAlias($aliasId));

        $container->removeAlias($aliasId);
        $container->removeDefinition($id);
    }

    public function testErroredDefinition()
    {
        $this->expectException(RuntimeException::class);
        $this->expectExceptionMessage('Service "errored_definition" is broken.');
        $container = new ContainerBuilder();

        $container->register('errored_definition', 'stdClass')
            ->addError('Service "errored_definition" is broken.')
            


                if ('ignore' === ($attributes['on_invalid'] ?? null)) {
                    $attributes['method'] = '?'.$attributes['method'];
                }

                $methods[$id][] = $attributes['method'];
            }
        }

        if (!$services) {
            $container->removeAlias('services_resetter');
            $container->removeDefinition('services_resetter');

            return;
        }

        $container->findDefinition('services_resetter')
            ->setArgument(0, new IteratorArgument($services))
            ->setArgument(1, $methods);
    }
}
if (class_exists(InstalledVersions::class) && InstalledVersions::isInstalled('symfony/symfony') && 'symfony/symfony' !== (InstalledVersions::getRootPackage()['name'] ?? '')) {
            trigger_deprecation('symfony/symfony', '6.1', 'Requiring the "symfony/symfony" package is deprecated; replace it with standalone components instead.');
        }

        $loader->load('web.php');
        $loader->load('services.php');
        $loader->load('fragment_renderer.php');
        $loader->load('error_renderer.php');

        if (!ContainerBuilder::willBeAvailable('symfony/clock', ClockInterface::class['symfony/framework-bundle'])) {
            $container->removeDefinition('clock');
            $container->removeAlias(ClockInterface::class);
            $container->removeAlias(PsrClockInterface::class);
        }

        $container->registerAliasForArgument('parameter_bag', PsrContainerInterface::class);

        $loader->load('process.php');

        if (!class_exists(RunProcessMessageHandler::class)) {
            $container->removeDefinition('process.messenger.process_message_handler');
        }

        

    public function getCompiledInsert(bool $reset = true)
    {
        if ($this->validateInsert() === false) {
            return false;
        }

        $sql = $this->_insert(
            $this->db->protectIdentifiers(
                $this->removeAlias($this->QBFrom[0]),
                true,
                null,
                false
            ),
            array_keys($this->QBSet),
            array_values($this->QBSet)
        );

        if ($reset === true) {
            $this->resetWrite();
        }

        
Home | Imprint | This part of the site doesn't use cookies.