Если вы говорите о получении нулевых значений от объекта, напишите метод в вашей сущности
<?php
// Entities/SomeEntity.php
class Foo
{
private $a;
private $b;
// ...
// Your getters and setters are here
// ...
public function myNullFunction()
{
if($this->a === null AND $this->b !== null)
{
return $this->b;
}
elseif($this->b === null && $this->a !== null)
{
return $this->a;
}
else
{
// ... Do something if both are null
}
}
}
Затем вы можете использовать функцию всякий раз, когда вы загрузили свой объект (ы)
$foo = $some_repository->getFooObject();
// The function returning a value that is a or b
$bar = $foo->myNullFunction();