-
-
Save pedrorvidal/2aba1cd81820892f4f71 to your computer and use it in GitHub Desktop.
| $arrayRelacoes = array(); | |
| if (!is_null($idNoticia)) { | |
| $relacoes = $this->getEm()->getRepository('Entity\NoticiaGaleria')->getNoticiaGaleriaIdsNoticias($idNoticia); | |
| foreach ($relacoes as $relacao) { | |
| $arrayRelacoes[$relacao->getGaleria()->getId()] = $relacao->getPosicaoPagina(); | |
| } | |
| } |
| <?php | |
| namespace Entity\Repository; | |
| use \Doctrine\ORM\EntityRepository; | |
| /** | |
| * Description of NoticiaGaleriaRepository | |
| * | |
| * @author Vidal | |
| */ | |
| class NoticiaGaleriaRepository extends BaseRepository | |
| { | |
| /** | |
| * | |
| * @param array $ids | |
| * @return array | |
| */ | |
| public function getNoticiaGaleriaIdsNoticias($id) | |
| { | |
| $dql = "SELECT ng FROM Entity\NoticiaGaleria ng JOIN ng.noticia nt WHERE nt.id = {$id} "; | |
| $query = $this->getEntityManager()->createQuery($dql); | |
| return $query->getResult(); | |
| } | |
| } |
| <?php | |
| namespace Entity; | |
| use Doctrine\ORM\Mapping as ORM; | |
| /** | |
| * NoticiaGaleria | |
| * | |
| * @ORM\Table(name="tb_noticia_galeria", indexes={@ORM\Index(name="IDX_3135593E478D78F9", columns={"id_galeria"}), @ORM\Index(name="IDX_3135593ED8407959", columns={"id_noticia"})}) | |
| * @ORM\Entity(repositoryClass="Entity\Repository\NoticiaGaleriaRepository") | |
| */ | |
| class NoticiaGaleria extends AbstractEntity implements EntityInterface | |
| { | |
| /** | |
| * @var integer | |
| * | |
| * @ORM\Column(name="id_noticia_galeria", type="bigint", nullable=false) | |
| * @ORM\Id | |
| * @ORM\GeneratedValue(strategy="SEQUENCE") | |
| * @ORM\SequenceGenerator(sequenceName="tb_noticia_galeria_id_noticia_galeria_seq", allocationSize=1, initialValue=1) | |
| */ | |
| private $id; | |
| /** | |
| * @var integer | |
| * | |
| * @ORM\Column(name="st_posicao_pagina", type="bigint", nullable=false) | |
| */ | |
| private $posicaoPagina; | |
| /** | |
| * @var Galeria | |
| * | |
| * @ORM\ManyToOne(targetEntity="Galeria") | |
| * @ORM\JoinColumns({ | |
| * @ORM\JoinColumn(name="id_galeria", referencedColumnName="id_galeria") | |
| * }) | |
| */ | |
| private $galeria; | |
| /** | |
| * @var Noticia | |
| * | |
| * @ORM\ManyToOne(targetEntity="Noticia") | |
| * @ORM\JoinColumns({ | |
| * @ORM\JoinColumn(name="id_noticia", referencedColumnName="id_noticia") | |
| * }) | |
| */ | |
| private $noticia; | |
| /** | |
| * | |
| * @return integer | |
| */ | |
| public function getId() | |
| { | |
| return $this->id; | |
| } | |
| /** | |
| * | |
| * @return integer | |
| */ | |
| public function getPosicaoPagina() | |
| { | |
| return $this->posicaoPagina; | |
| } | |
| /** | |
| * | |
| * @return Galeria | |
| */ | |
| public function getGaleria() | |
| { | |
| return $this->galeria; | |
| } | |
| /** | |
| * | |
| * @return Noticia | |
| */ | |
| public function getNoticia() | |
| { | |
| return $this->Noticia; | |
| } | |
| /** | |
| * | |
| * @param integer $id | |
| */ | |
| public function setId($id) | |
| { | |
| $this->id = $id; | |
| } | |
| /** | |
| * | |
| * @param integer $posicaoPagina | |
| */ | |
| public function setPosicaoPagina($posicaoPagina) | |
| { | |
| $this->posicaoPagina = $posicaoPagina; | |
| } | |
| /** | |
| * | |
| * @param Galeria $galeria | |
| */ | |
| public function setGaleria(Galeria $galeria) | |
| { | |
| $this->galeria = $galeria; | |
| } | |
| /** | |
| * | |
| * @param Noticia $noticia | |
| */ | |
| public function setNoticia(Noticia $noticia) | |
| { | |
| $this->noticia = $noticia; | |
| } | |
| /** | |
| * | |
| * @return integer | |
| */ | |
| public function getLabel() | |
| { | |
| return $this->getPosicaoPagina(); | |
| } | |
| /** | |
| * | |
| * @return array | |
| */ | |
| public function toArray() | |
| { | |
| return array( | |
| "id" => $this->getId(), | |
| "noticia" => $this->getNoticia(), | |
| "galeria" => $this->getGaleria(), | |
| "posicaoPagina" => $this->getPosicaoPagina() | |
| ); | |
| } | |
| } |
| <?php | |
| namespace Entity; | |
| use Doctrine\ORM\Mapping as ORM; | |
| /** | |
| * PaginaEstaticaGaleria | |
| * | |
| * @ORM\Table(name="tb_pagina_estatica_galeria", indexes={@ORM\Index(name="IDX_3135593E478D78F9", columns={"id_galeria"}), @ORM\Index(name="IDX_3135593ED8407959", columns={"id_pagina_estatica"})}) | |
| * @ORM\Entity(repositoryClass="Entity\Repository\PaginaEstaticaGaleriaRepository") | |
| */ | |
| class PaginaEstaticaGaleria extends AbstractEntity implements EntityInterface | |
| { | |
| /** | |
| * @var integer | |
| * | |
| * @ORM\Column(name="id_pagina_estatica_galeria", type="bigint", nullable=false) | |
| * @ORM\Id | |
| * @ORM\GeneratedValue(strategy="SEQUENCE") | |
| * @ORM\SequenceGenerator(sequenceName="tb_pagina_estatica_galeria_id_pagina_estatica_galeria_seq", allocationSize=1, initialValue=1) | |
| */ | |
| private $id; | |
| /** | |
| * @var integer | |
| * | |
| * @ORM\Column(name="st_posicao_pagina", type="bigint", nullable=false) | |
| */ | |
| private $posicaoPagina; | |
| /** | |
| * @var Galeria | |
| * | |
| * @ORM\ManyToOne(targetEntity="Galeria") | |
| * @ORM\JoinColumns({ | |
| * @ORM\JoinColumn(name="id_galeria", referencedColumnName="id_galeria") | |
| * }) | |
| */ | |
| private $galeria; | |
| /** | |
| * @var PaginaEstatica | |
| * | |
| * @ORM\ManyToOne(targetEntity="PaginaEstatica") | |
| * @ORM\JoinColumns({ | |
| * @ORM\JoinColumn(name="id_pagina_estatica", referencedColumnName="id_pagina_estatica") | |
| * }) | |
| */ | |
| private $paginaEstatica; | |
| /** | |
| * | |
| * @return integer | |
| */ | |
| public function getId() | |
| { | |
| return $this->id; | |
| } | |
| /** | |
| * | |
| * @return integer | |
| */ | |
| public function getPosicaoPagina() | |
| { | |
| return $this->posicaoPagina; | |
| } | |
| /** | |
| * | |
| * @return Galeria | |
| */ | |
| public function getGaleria() | |
| { | |
| return $this->galeria; | |
| } | |
| /** | |
| * | |
| * @return PaginaEstatica | |
| */ | |
| public function getPaginaEstatica() | |
| { | |
| return $this->paginaEstatica; | |
| } | |
| /** | |
| * | |
| * @param integer $id | |
| */ | |
| public function setId($id) | |
| { | |
| $this->id = $id; | |
| } | |
| /** | |
| * | |
| * @param integer $posicaoPagina | |
| */ | |
| public function setPosicaoPagina($posicaoPagina) | |
| { | |
| $this->posicaoPagina = $posicaoPagina; | |
| } | |
| /** | |
| * | |
| * @param Galeria $galeria | |
| */ | |
| public function setGaleria(Galeria $galeria) | |
| { | |
| $this->galeria = $galeria; | |
| } | |
| /** | |
| * | |
| * @param PaginaEstatica $paginaEstatica | |
| */ | |
| public function setPaginaEstatica(PaginaEstatica $paginaEstatica) | |
| { | |
| $this->paginaEstatica = $paginaEstatica; | |
| } | |
| /** | |
| * | |
| * @return integer | |
| */ | |
| public function getLabel() | |
| { | |
| return $this->getPosicaoPagina(); | |
| } | |
| /** | |
| * | |
| * @return array | |
| */ | |
| public function toArray() | |
| { | |
| return array( | |
| "id" => $this->getId(), | |
| "paginaEstatica" => $this->getPaginaEstatica(), | |
| "galeria" => $this->getGaleria(), | |
| "posicaoPagina" => $this->getPosicaoPagina() | |
| ); | |
| } | |
| } |
teste
vardump
Fatal error: Uncaught exception 'BadMethodCallException' with message 'Undefined method 'getNoticiaGaleriaIdsNoticias'. The method name must start with either findBy or findOneBy!' in /opt/lampp/htdocs/portaliphan/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:226
Stack trace:
#0 /opt/lampp/htdocs/portaliphan/src/CMS/Controller/NoticiaController.php(329): Doctrine\ORM\EntityRepository->__call('getNoticiaGaler...', Array)
#1 /opt/lampp/htdocs/portaliphan/src/CMS/Controller/NoticiaController.php(329): Doctrine\ORM\EntityRepository->getNoticiaGaleriaIdsNoticias('74')
#2 /opt/lampp/htdocs/portaliphan/src/CMS/Controller/NoticiaController.php(180): CMS\Controller\NoticiaController->getHtmlGalerias('55', '74')
#3 [internal function]: CMS\Controller\NoticiaController->form('74')
#4 /opt/lampp/htdocs/portaliphan/lib/LibraryController/FrontControllerCMS.php(198): call_user_func_array(Array, Array)
#5 /opt/lampp/htdocs/portaliphan/index.php(58): LibraryController\FrontControllerCMS->run()
#6 {main}
thrown in /opt/lampp/htdocs/portaliphan/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php on line 226
perae que postei o erro "errado"
O $teste..... está na linha 329 do arquivo NoticiaController.php?
O SEU "BaseRepository" está extendendo "Doctrine\ORM\EntityRepository" ?