A Company object can have many Site Objects. For a given company I'd like to know the primary Site. (isPrimary is an attribute of Site).
I wrote a function in the Company class called getPrimarySite() and implemented it like this.
public function getPrimarySiteForCompany()
{
foreach($this->getSite() as $site)
{
if($site->isPrimary())
{
return $site;
}
}
return false;
}
Is this OK or is it better to write a custom repository function in CompanyRepository where I get the primary Site with DQL?