You are here

public function CerPresetFinder::find in Corresponding Entity References 7.3

Return value

EntityFieldQuery

File

includes/CerPresetFinder.inc, line 55

Class

CerPresetFinder
This class is a unified way for CER to find the presets that apply to a given entity. The result set is segmented into two parts: presets where the entity is on the left side, and bidirectional presets with the entity on the right side (i.e., the ones…

Code

public function find($left = NULL, $right = NULL, $bidirectional = NULL, $operator = 'STARTS_WITH') {
  $query = new EntityFieldQuery();
  if ($left) {
    $query
      ->fieldCondition('cer_left', 'path', $left, $operator);
  }
  if ($right) {
    $query
      ->fieldCondition('cer_right', 'path', $right, $operator);
  }
  if (isset($bidirectional)) {
    $query
      ->fieldCondition('cer_bidirectional', 'value', (bool) $bidirectional);
  }
  return $query
    ->entityCondition('entity_type', 'cer')
    ->fieldCondition('cer_enabled', 'value', TRUE);
}