public function __construct(string $configFile) { // Load configuration from file }
services: my_service: class: MyService arguments: - '../config/config.yaml' # path to configuration file calls: - ['setFile', ['../config/config.yaml']]
use Symfony\Component\DependencyInjection\Definition; // Create a new Definition object $twigExtension = new Definition('MyTwigExtension'); // Set the file path $twigExtension->setFile('/path/to/MyTwigExtension.php'); // Register with Twig $container->setDefinition('my_twig_extension', $twigExtension);The `setFile` method belongs to the DependencyInjection component of Symfony library.