You are here

class DateFieldHandler in CRM Core 8.2

Same name and namespace in other branches
  1. 8.3 modules/crm_core_match/src/Plugin/crm_core_match/field/DateFieldHandler.php \Drupal\crm_core_match\Plugin\crm_core_match\field\DateFieldHandler
  2. 8 modules/crm_core_match/src/Plugin/crm_core_match/field/DateFieldHandler.php \Drupal\crm_core_match\Plugin\crm_core_match\field\DateFieldHandler

Class for evaluating date fields.

Hierarchy

Expanded class hierarchy of DateFieldHandler

File

modules/crm_core_match/src/Plugin/crm_core_match/field/DateFieldHandler.php, line 10

Namespace

Drupal\crm_core_match\Plugin\crm_core_match\field
View source
class DateFieldHandler extends FieldHandlerBase {

  /**
   * {@inheritdoc}
   */
  public function getOperators($property = 'value') {
    $operators = array(
      '=' => t('Equals'),
      '>=' => t('Greater than'),
      '<=' => t('Less than'),
    );
    return $operators;
  }

  /**
   * {@inheritdoc}
   *
   * @todo Update to new query API.
   */
  public function match(ContactInterface $contact, $property = 'value') {
    $results = array();
    $field_item = 'value';
    $field = field_get_items('crm_core_contact', $contact, $rule->field_name);
    $needle = isset($field[0]['value']) ? $field[0]['value'] : '';
    if (!empty($needle)) {
      $query = new EntityFieldQuery();
      $query
        ->entityCondition('entity_type', 'crm_core_contact')
        ->entityCondition('bundle', $contact->type)
        ->entityCondition('entity_id', $contact->contact_id, '<>')
        ->fieldCondition($rule->field_name, $field_item, $needle, $rule->operator);
      $results = $query
        ->execute();
    }
    return isset($results['crm_core_contact']) ? array_keys($results['crm_core_contact']) : $results;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DateFieldHandler::getOperators public function Gets the operators. Overrides FieldHandlerInterface::getOperators
DateFieldHandler::match public function @todo Update to new query API. Overrides FieldHandlerBase::match
FieldHandlerBase::$configuration protected property The settings. 1
FieldHandlerBase::$definition protected property The plugin definition.
FieldHandlerBase::$field protected property The field.
FieldHandlerBase::$id protected property The plugin id.
FieldHandlerBase::$queryFactory protected property A Contact query object.
FieldHandlerBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
FieldHandlerBase::getLabel public function Gets the property label. Overrides FieldHandlerInterface::getLabel
FieldHandlerBase::getOperator public function Gets the current selected operator. Overrides FieldHandlerInterface::getOperator
FieldHandlerBase::getOptions public function Gets the operator options. Overrides FieldHandlerInterface::getOptions
FieldHandlerBase::getPropertyNames public function Returns the names of the field's subproperties. Overrides FieldHandlerInterface::getPropertyNames 1
FieldHandlerBase::getScore public function Gets the score. Overrides FieldHandlerInterface::getScore
FieldHandlerBase::getStatus public function Gets the property status. Overrides FieldHandlerInterface::getStatus
FieldHandlerBase::getType public function Gets the field type. Overrides FieldHandlerInterface::getType
FieldHandlerBase::getWeight public function Gets the weight. Overrides FieldHandlerInterface::getWeight
FieldHandlerBase::WEIGHT_DELTA constant The weight.
FieldHandlerBase::__construct public function Constructs an plugin instance.