protected function getWheres(ContentType $contentType) { // filter if filter=true, only filter when filter=false if the user is an admin if ($contentType->get('filter', true) == false && $this->app['user']->hasRole('ROLE_ADMIN')) { return array(); } if ($this->app['projects']->count() == 0) { return array('outgoing.from_id' => $this->app['user']->getId()); } // if we are filtering projects, it cannot be done by the relationship but must be filtered on the id $contentTypeIsCurrentProject = $this->app['project.service']->isProjectsContentType($contentType); if ($contentTypeIsCurrentProject) { return array($contentType->getTableName() . '.id' => $this->app['project.service']->getCurrentProjectId()); } // filter on the relation to a project return array('incoming.to_id' => $this->app['project.service']->getCurrentProjectId()); }
public function isProjectsContentType(ContentType $contentType) { return $contentType->getKey() == $this->getProjectKey(); }