DateFieldHandler.php in CRM Core 8.3
File
modules/crm_core_match/src/Plugin/crm_core_match/field/DateFieldHandler.php
View source
<?php
namespace Drupal\crm_core_match\Plugin\crm_core_match\field;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\crm_core_contact\ContactInterface;
class DateFieldHandler extends FieldHandlerBase {
use StringTranslationTrait;
public function getOperators($property = 'value') {
$operators = [
'=' => $this
->t('Equals'),
'>=' => $this
->t('Greater than'),
'<=' => $this
->t('Less than'),
];
return $operators;
}
public function match(ContactInterface $contact, $property = 'value') {
$results = [];
$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;
}
}
class DateTimeFieldHandler extends DateFieldHandler {
}
class DateStampFieldHandler extends DateFieldHandler {
}