Мой код Helper класса, как показано ниже:Как получить путь корня в вспомогательном классе - Symfony2
public function getPlaceholders()
{
try {
echo $this->getParameter('kernel.root_dir');
} catch (ParseException $e) {
printf("Unable to parse the YAML string: %s", $e->getMessage());
}
return $this->placeholders;
}
Это возвращение ошибки, как показано ниже:
Attempted to call an undefined method named "getParameter" of class "AppBundle\Helper\Placeholders".
Пожалуйста, советы мне на него.
Средства ошибок, не существует 'метода getParameter' на классе' Placeholders'. – Federkun
Итак, как использовать getParameter в моем классе помощников? @Federkun –
'getParameter' - это метод контейнера, просто введите его в« Placeholders »и используйте его. (http://stackoverflow.com/questions/17126277/how-to-give-container-as-argument-to-services) – Federkun