class DepCalcExcludeLingotekContentMetadataSubscriber in Lingotek Translation 3.6.x
Same name and namespace in other branches
- 4.0.x src/EventSubscriber/DepCalcExcludeLingotekContentMetadataSubscriber.php \Drupal\lingotek\EventSubscriber\DepCalcExcludeLingotekContentMetadataSubscriber
- 3.7.x src/EventSubscriber/DepCalcExcludeLingotekContentMetadataSubscriber.php \Drupal\lingotek\EventSubscriber\DepCalcExcludeLingotekContentMetadataSubscriber
- 3.8.x src/EventSubscriber/DepCalcExcludeLingotekContentMetadataSubscriber.php \Drupal\lingotek\EventSubscriber\DepCalcExcludeLingotekContentMetadataSubscriber
Hierarchy
- class \Drupal\lingotek\EventSubscriber\DepCalcExcludeLingotekContentMetadataSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of DepCalcExcludeLingotekContentMetadataSubscriber
1 string reference to 'DepCalcExcludeLingotekContentMetadataSubscriber'
1 service uses DepCalcExcludeLingotekContentMetadataSubscriber
File
- src/
EventSubscriber/ DepCalcExcludeLingotekContentMetadataSubscriber.php, line 9
Namespace
Drupal\lingotek\EventSubscriberView source
class DepCalcExcludeLingotekContentMetadataSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
// DependencyCalculatorEvents::FILTER_FIELDS from depcalc module.
$events['depcalc_filter_fields'][] = [
'onFilterFields',
1002,
];
return $events;
}
/**
* Filter fields.
*
* @param \Drupal\depcalc\Event\FilterDependencyCalculationFieldsEvent $event
* Filter Dependency Calculation Fields.
*/
public function onFilterFields(FilterDependencyCalculationFieldsEvent $event) {
$fields = array_filter($event
->getFields(), function ($field) {
return $this
->includeField($field);
}, ARRAY_FILTER_USE_BOTH);
$event
->setFields(...$fields);
}
/**
* Whether we should include this field in the dependency calculation.
*
* @param \Drupal\Core\Field\FieldItemListInterface $field
* The entity field.
*
* @return bool
* TRUE if we should include the field, FALSE otherwise.
*/
protected function includeField(FieldItemListInterface $field) {
$definition = $field
->getFieldDefinition();
if ($definition
->getType() === 'entity_reference' && $field
->getSetting('target_type') === 'lingotek_content_metadata') {
return FALSE;
}
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DepCalcExcludeLingotekContentMetadataSubscriber:: |
public static | function | ||
DepCalcExcludeLingotekContentMetadataSubscriber:: |
protected | function | Whether we should include this field in the dependency calculation. | |
DepCalcExcludeLingotekContentMetadataSubscriber:: |
public | function | Filter fields. |