Mam takie entity:
<?php namespace Acme\Bundle\AdminBundle\Entity; use Cocur\Slugify\Slugify; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Mapping as ORM; /** * BrandDevice * * @ORM\Table(name="brand_device") * @ORM\Entity */ class BrandDevice { /** * @var string * * @ORM\Column(name="name", type="string", length=50, nullable=false) * @Assert\NotBlank(message="Te pole jest wymagane") */ private $name; /** * @var string * * @ORM\Column(name="description", type="text", nullable=false) */ private $description; /** * @var string * * @ORM\Column(name="logo", type="string", length=50, nullable=false) */ private $logo; /** * @var string * * @ORM\Column(name="website", type="string", length=100, nullable=false) * @Assert\NotBlank(message="Te pole jest wymagane") * @Assert\Url(message="Proszę podać poprawny adres strony www") */ private $website; /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; private $entityManager; public function __construct(EntityManager $entityManager) { $this->entityManager = $entityManager; } /** * Set name * * @param string $name * @return BrandDevice */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } /** * Set description * * @param string $description * @return BrandDevice */ public function setDescription($description) { $this->description = $description; return $this; } /** * Get description * * @return string */ public function getDescription() { return $this->description; } /** * Set logo * * @param string $logo * @return BrandDevice */ public function setLogo($logo) { $this->logo = $logo; return $this; } /** * Get logo * * @return string */ public function getLogo() { return $this->logo; } /** * Set website * * @param string $website * @return BrandDevice */ public function setWebsite($website) { $this->website = $website; return $this; } /** * Get website * * @return string */ public function getWebsite() { return $this->website; } /** * Get id * * @return integer */ public function getId() { return $this->id; } public function findLikeName($term) { $qb = $this->entityManager->createQueryBuilder(); $result = $qb->select('n')->from('AcmeAdminBundle:BrandDevice', 'n') ->where( $qb->expr()->like('n.name', $qb->expr()->literal('%' . $term . '%')) ) ->getQuery() ->getResult(); return $result; } }
i w controlerze daje:
... $brand = new BrandDevice(); $brand->findLikeName('asd'); ...
dostaję zwrotkę, że nie ma takiej metody: findLikeName
Wiecie dlaczego tak się dzieje?
Pzdr.