0
有沒有辦法將一個bundle注入到服務中?在symfony 2中注入bundle服務
我想我寫服務的構造是這樣的:
<?php
use Symfony\Component\HttpKernel\Bundle\Bundle;
class MyService
{
/** @var Bundle */
private $bundle;
public function __construct(Bundle $bundle)
{
$this->bundle = $bundle;
}
}
對於services.yml
我想有這樣的事情:
services:
my_service:
class: MyService
arguments: ['how_can_i_reference_a_bundle']
爲什麼你需要它? –
我需要收集每包的對象。當然,我可以用一些字符串標識符來做到這一點,但我更願意使用已經存在的東西。但我不知道如何獲得捆綁。 – BetaRide
我很確定你做錯了。你需要收集哪些物品?其他服務?閱讀使用標記的服務:http://symfony.com/doc/current/components/dependency_injection/tags.html –