I am adding virtual property to the Symfony entity class. This property should be calculated based on other tabular data - in particular, for a column of the Doctrine array type .
class RelatedEntity
{
protected $type;
Point I would like to use the Doctrine criterion for this, since it must be optimized at the SQL level. So I did this:
public function getCreated()
{
$criteria = Criteria::create()->where(Criteria::expr()->contains('type', 'create'));
$relatedEntity = $this->getRelatedEntities()->matching($criteria);
if (!$relatedEntity) {
return null;
}
return $relatedEntity->getTimestamp();
}
But I get an empty result set. Despite the fact that Doctrine creates the correct SQL statement that works when I manually enter it into the PostgreSQL database.
...WHERE type LIKE '%create%'
? ArrayCollection, , .
.
EDIT. , EntityManager EntityRepository . , , , .