- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我按照此处所述创建了 symfony 服务:Symfony2: get Doctrine in a generic PHP class
服务.yml
app.lib.helpers:
class: AppBundle\Lib\Helpers
arguments: [doctrine.orm.entity_manager]
类(class)助手
class Helpers
{
protected $em;
public function __construct($entityManager)
{
$this->em = $entityManager;
}
public function checkStatuses()
{
$orderId = $this->em->getRepository('AppBundle:Orders')->findAll();
}
}
在 Controller Action 中
$helper = $this->get('app.lib.helpers');
$helper->checkStatuses();
但是我收到错误:
Error: Call to a member function getRepository() on string
是什么导致了这个问题?
最佳答案
我觉得应该是
arguments: [ "@doctrine.orm.entity_manager" ]
在你的 Service.yml 中
关于php - 在字符串上调用成员函数 getRepository(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40506650/
我按照此处所述创建了 symfony 服务:Symfony2: get Doctrine in a generic PHP class 服务.yml app.lib.helpers: clas
我按照此处所述创建了 symfony 服务:Symfony2: get Doctrine in a generic PHP class 服务.yml app.lib.helpers: clas
我是 Doctrine 和交响乐的新手。我创建了一个使用 Dotent ORM 进行 bean 腐操作的小应用程序。我的插入操作正在运行,但我的列表操作抛出 错误 作为 [Doctrine\Commo
我正在尝试获取我的 entity 中包含的所有列,但我只能从其他实体中获取没有任何关系的列。 我使用此代码块将所有行获取到此存储库。 private translationTextRepository
如何像 doctrine2 那样编写查询 SELECT * from table where field = value1 or field = value2 我发现了类似的东西 $em->getR
我正在尝试清理一些代码,但遇到了一些麻烦。我在路由文件中反复使用了一些实体。例如: $categories = $em->getRepository('SixString\Entities\Categ
本文整理了Java中org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.getRepository()方法的一些代码示例,展示了XM
我需要用 sinon 多次包装一个方法,以便能够根据参数返回不同的对象。我该怎么做? 我要测试的 Controller 看起来像这样: const servicePackagesOfferingRep
有实体 /** * @ORM\Entity(repositoryClass="Some\Namspace\CustomRepository") * @ORM\Table(name="image_t
我使用的代码: $userRepository = $this->getDoctrine() ->getManager() ->ge
我想返回一个包含记录信息的\Symfony\Component\HttpFoundation\JsonResponse,但我需要将它作为数组传递。 目前我这样做: $repository = $thi
Symfony2 文档说我应该使用别名快捷方式 'ByBundle:myEntity' 作为实体路径: $em->getRepository('ByBundle:myEntity'); 但是这个字符串
我是一名优秀的程序员,十分优秀!