【发布时间】:2013-03-11 05:25:21
【问题描述】:
我需要让教义在我的助手中工作,我试图像我通常在控制器中那样使用:
$giftRepository = $this->getDoctrine( )->getRepository( 'DonePunctisBundle:Gift' );
但这给了我:
致命错误:调用未定义的方法 完成\PUNCTISBUNDLE\HELPER\UTILITYHELPER::GETDOCTRIN() IN /VAR/WWW/VHOSTS/PUNCTIS.COM/HTTPDOCS/SRC/DONE/PUNCTISBUNDLE/HELPER/UTILITYHELPER.PH
我在这里缺少什么?
编辑:
服务文件
services:
templating.helper.utility:
class: Done\PunctisBundle\Helper\UtilityHelper
arguments: [@service_container]
tags:
- { name: templating.helper, alias: utility }
帮助文件的前几行
<?php
namespace Done\PunctisBundle\Helper;
use Symfony\Component\Templating\Helper\Helper;
use Symfony\Component\Templating\EngineInterface;
class UtilityHelper extends Helper {
/*
* Dependency injection
*/
private $container;
public function __construct( $container )
{
$this->container = $container;
}
【问题讨论】:
标签: php symfony dependency-injection doctrine