public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) { $mappings = $targetEntity->getAssociationMappings(); if (!array_key_exists('journal', $mappings) || $mappings['journal']['targetEntity'] !== 'Ojs\\JournalBundle\\Entity\\Journal') { return ''; } $selectedJournal = $this->journalService->getSelectedJournal(); if (!$selectedJournal) { return ''; } $journalJoinColumn = $mappings['journal']['joinColumns'][0]['name']; $addCondSql = $targetTableAlias . '.' . $journalJoinColumn . ' = ' . $selectedJournal->getId(); return $addCondSql; }
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) { $mappings = $targetEntity->getAssociationMappings(); if (!array_key_exists('journal', $mappings) || $mappings['journal']['targetEntity'] !== 'Ojs\\JournalBundle\\Entity\\Journal') { return ''; } //return if journal filter disabled globally for current entity if (isset($GLOBALS[$targetEntity->getName() . '#journalFilter']) && $GLOBALS[$targetEntity->getName() . '#journalFilter'] == false) { return ''; } try { $selectedJournal = $this->journalService->getSelectedJournal(); } catch (\Exception $e) { return ''; } if (!$selectedJournal) { return ''; } $journalJoinColumn = $mappings['journal']['joinColumns'][0]['name']; $addCondSql = $targetTableAlias . '.' . $journalJoinColumn . ' = ' . $selectedJournal->getId(); return $addCondSql; }