小编Rod*_* R.的帖子

未定义的方法'getDoctrine'.方法名称必须以findBy或findOneBy开头

我目前正在使用Symfony2,我收到此错误消息:

未定义的方法'getDoctrine'.方法名称必须以findBy或findOneBy开头!500内部服务器错误 - BadMethodCallException

这是我的实体类:

 <?php

namespace Gestionresiduos\ResiduoBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass="ResiduoRepository")
*/

class BodegaContieneResiduo
{


    /**
    * @ORM\Id
    * @ORM\column(type="integer")
    * @ORM\GeneratedValue
    */

    protected $idContiene;

.....

}
Run Code Online (Sandbox Code Playgroud)

这是Controller的页面Action方法:

 <?php

namespace Gestionresiduos\ResiduoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
    public function portadaAction()
    {
        $em = $this->getDoctrine()->getEntityManager();

        $ofertas= $em->getRepository('ResiduoBundle:BodegaContieneResiduo')->findResiduosAlmacenados();
        return $this->render('ResiduoBundle:Default:index.html.twig');
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的EntityRepository:

    <?php
namespace Gestionresiduos\ResiduoBundle\Entity;

use Doctrine\ORM\EntityRepository;

class ResiduoRepository extends EntityRepository
{

    public function findResiduosAlmacenados()
    {
        $em = $this->getDoctrine()->getEntityManager();
        $consulta = $em->createQuery('SELECT r FROM ResiduoBundle:BodegaContieneResiduo');
        return …
Run Code Online (Sandbox Code Playgroud)

doctrine symfony

4
推荐指数
1
解决办法
6108
查看次数

退出状态代码'1'表示出错了[knp snappy]

我正在使用knp snappy bundle从我的应用程序生成报告.但是不起作用,当我调用我的控制器生成pdf时会抛出下一个错误:

The exit status code '1' says something went wrong:
stderr: "Loading pages (1/6)
[> ] 0%
[======> ] 10%
[=======> ] 12%
Warning: Failed to load file:///gestionresiduospel/web/bundles/usuario/css/bootstrap.css (ignore)
Warning: Failed to load file:///gestionresiduospel/web/bundles/usuario/js/bootstrap.js (ignore)
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing
[============================================================] Page 1 of 1
Done
Exit with code 1 due to network error: …
Run Code Online (Sandbox Code Playgroud)

pdf-generation wkhtmltopdf symfony

2
推荐指数
1
解决办法
7033
查看次数

标签 统计

symfony ×2

doctrine ×1

pdf-generation ×1

wkhtmltopdf ×1