You are here

class CerPresetSelectionHandler in Corresponding Entity References 7.3

Hierarchy

Expanded class hierarchy of CerPresetSelectionHandler

1 string reference to 'CerPresetSelectionHandler'
cer.inc in extensions/cer_entity_settings/plugins/entityreference/selection/cer.inc

File

extensions/cer_entity_settings/plugins/entityreference/selection/CerPresetSelectionHandler.class.php, line 3

View source
class CerPresetSelectionHandler implements EntityReference_SelectionHandler {
  private $entity;
  public static function getInstance($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
    return new CerPresetSelectionHandler($entity_type, $entity);
  }
  public function __construct($entity_type, $entity) {
    if ($entity_type && $entity) {
      $this->entity = new EntityDrupalWrapper($entity_type, $entity);
    }
  }
  public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
    $options = array();
    if ($this->entity) {
      $finder = new CerPresetFinder($this->entity);
      $finder
        ->execute();
      foreach ($finder->result['cer'] as $preset) {
        $options['cer'][$preset->pid] = $preset->label_variables['@right'];
      }
      foreach ($finder->result['cer__invert'] as $preset) {
        $options['cer'][$preset->pid] = $preset->label_variables['@left'];
      }
    }
    return $options;
  }
  public function countReferencableEntities($match = NULL, $match_operator = 'CONTAINS') {
    return sizeof($this
      ->getReferencableEntities());
  }
  public function validateReferencableEntities(array $IDs) {

    // Don't bother validating preset IDs.
    return $IDs;
  }
  public function validateAutocompleteInput($input, &$element, &$form_state, $form) {
    return NULL;
  }
  public function entityFieldQueryAlter(SelectQueryInterface $query) {

    // NOP
  }
  public function getLabel($entity) {
    return entity_label('cer', $entity);
  }
  public static function settingsForm($field, $instance) {
    return array();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CerPresetSelectionHandler::$entity private property
CerPresetSelectionHandler::countReferencableEntities public function Count entities that are referencable by a given field. Overrides EntityReference_SelectionHandler::countReferencableEntities
CerPresetSelectionHandler::entityFieldQueryAlter public function Give the handler a chance to alter the SelectQuery generated by EntityFieldQuery. Overrides EntityReference_SelectionHandler::entityFieldQueryAlter
CerPresetSelectionHandler::getInstance public static function Factory function: create a new instance of this handler for a given field. Overrides EntityReference_SelectionHandler::getInstance
CerPresetSelectionHandler::getLabel public function Return the label of a given entity. Overrides EntityReference_SelectionHandler::getLabel
CerPresetSelectionHandler::getReferencableEntities public function Return a list of referencable entities. Overrides EntityReference_SelectionHandler::getReferencableEntities
CerPresetSelectionHandler::settingsForm public static function Generate a settings form for this handler. Overrides EntityReference_SelectionHandler::settingsForm
CerPresetSelectionHandler::validateAutocompleteInput public function Validate Input from autocomplete widget that has no Id. Overrides EntityReference_SelectionHandler::validateAutocompleteInput
CerPresetSelectionHandler::validateReferencableEntities public function Validate that entities can be referenced by this field. Overrides EntityReference_SelectionHandler::validateReferencableEntities
CerPresetSelectionHandler::__construct public function