, , , Repository, :
class PageRepository extends EntityRepository
{
protected $_switchEntityNameSave = null;
protected function _swapEntityDiscriminator($fqcn = null){
if(isset($fqcn)){
$this->_switchEntityNameSave = $this->_entityName;
$this->_entityName = $fqcn;
} else {
$this->_entityName = $this->_switchEntityNameSave;
unset($this->_switchEntityNameSave);
}
}
public function findSomeStuff()
{
$this->_swapEntityDiscriminator(News::getFqcn());
$this->_swapEntityDiscriminator();
return $q->getQuery();
}
}
, , Getter getFqcn(), :
abstract class BaseEntity {
public static function getFqcn()
{
return get_called_class();
}
}
Late static binding ( News, Page).
, .
, :
class News extends Page {
const HUMAN_READABLE = "News";
const DISCRIMINATOR = "news";
}
, Repository .