class DateFieldHandler in CRM Core 8.3
Same name and namespace in other branches
- 8 modules/crm_core_match/src/Plugin/crm_core_match/field/DateFieldHandler.php \Drupal\crm_core_match\Plugin\crm_core_match\field\DateFieldHandler
- 8.2 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
- class \Drupal\crm_core_match\Plugin\crm_core_match\field\FieldHandlerBase implements ContainerFactoryPluginInterface, FieldHandlerInterface
- class \Drupal\crm_core_match\Plugin\crm_core_match\field\DateFieldHandler uses StringTranslationTrait
Expanded class hierarchy of DateFieldHandler
File
- modules/
crm_core_match/ src/ Plugin/ crm_core_match/ field/ DateFieldHandler.php, line 11
Namespace
Drupal\crm_core_match\Plugin\crm_core_match\fieldView source
class DateFieldHandler extends FieldHandlerBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function getOperators($property = 'value') {
$operators = [
'=' => $this
->t('Equals'),
'>=' => $this
->t('Greater than'),
'<=' => $this
->t('Less than'),
];
return $operators;
}
/**
* {@inheritdoc}
*
* @todo Update to new query API.
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DateFieldHandler:: |
public | function |
Gets the operators. Overrides FieldHandlerInterface:: |
|
DateFieldHandler:: |
public | function |
@todo Update to new query API. Overrides FieldHandlerBase:: |
|
FieldHandlerBase:: |
protected | property | The settings. | 1 |
FieldHandlerBase:: |
protected | property | The plugin definition. | |
FieldHandlerBase:: |
protected | property | Entity type manager. | |
FieldHandlerBase:: |
protected | property | The field. | |
FieldHandlerBase:: |
protected | property | The plugin id. | |
FieldHandlerBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
FieldHandlerBase:: |
public | function |
Gets the property label. Overrides FieldHandlerInterface:: |
|
FieldHandlerBase:: |
public | function |
Gets the current selected operator. Overrides FieldHandlerInterface:: |
|
FieldHandlerBase:: |
public | function |
Gets the operator options. Overrides FieldHandlerInterface:: |
|
FieldHandlerBase:: |
public | function |
Returns the names of the field's subproperties. Overrides FieldHandlerInterface:: |
1 |
FieldHandlerBase:: |
public | function |
Gets the score. Overrides FieldHandlerInterface:: |
|
FieldHandlerBase:: |
public | function |
Gets the property status. Overrides FieldHandlerInterface:: |
|
FieldHandlerBase:: |
public | function |
Gets the field type. Overrides FieldHandlerInterface:: |
|
FieldHandlerBase:: |
public | function |
Gets the weight. Overrides FieldHandlerInterface:: |
|
FieldHandlerBase:: |
constant | The weight. | ||
FieldHandlerBase:: |
public | function | Constructs an plugin instance. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |