Adds the object class hierarchy as resources.
public addObjectResource ( object $object ) : |
||
$object | object | An object instance |
return | The current instance |
use Doctrine\ORM\Mapping\Entity; use Symfony\Component\DependencyInjection\ContainerBuilder; $container = new ContainerBuilder(); $entity = new Entity(); // configure the entity as needed $container->addObjectResource($entity);
use App\Service\MyCustomService; use Symfony\Component\DependencyInjection\ContainerBuilder; $container = new ContainerBuilder(); $service = new MyCustomService(); // configure the service as needed $container->addObjectResource($service);
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Bridge\Twig\AppVariable; use Twig\Environment; use Twig\Loader\FilesystemLoader; $container = new ContainerBuilder(); $loader = new FilesystemLoader('/path/to/templates'); $twig = new Environment($loader); $variable = new AppVariable(); // configure the variable as needed $twig->addGlobal('app', $variable); $template = $twig->load('my_template.html.twig'); $container->addObjectResource($template);In this example, we create a Twig template and add it to the container as a resource using addObjectResource. This ensures that the container is aware of the template and will rebuild its configuration if any changes are made to it. Package library: Twig and Symfony\Bridge\Twig
public addObjectResource ( object $object ) : |
||
$object | object | An object instance |
return | The current instance |