You are here

public function BaseUpdateRunner::getReferencingFieldIds in Scheduled Updates 8

Get all field ids that are attached to the entity type to be updated and target this update type.

Return value

array

Overrides UpdateRunnerInterface::getReferencingFieldIds

4 calls to BaseUpdateRunner::getReferencingFieldIds()
BaseUpdateRunner::getEntityIdsReferencingReadyUpdates in src/Plugin/BaseUpdateRunner.php
Get all entity ids for entities that reference updates that are ready to run.
EmbeddedUpdateRunner::getEmbeddedUpdates in src/Plugin/UpdateRunner/EmbeddedUpdateRunner.php
Return all schedule updates that are referenced via Entity Reference fields.
EmbeddedUpdateRunner::getUpdateIdsOnEntity in src/Plugin/UpdateRunner/EmbeddedUpdateRunner.php
Get all update ids for this connected Update type.
LatestRevisionUpdateRunner::getEntityIdsReferencingReadyUpdates in src/Plugin/UpdateRunner/LatestRevisionUpdateRunner.php
This method is overridden because the version in BaseUpdateRunner only needs to get default revisions so does not call $query->allRevisions().

File

src/Plugin/BaseUpdateRunner.php, line 297
Contains \Drupal\scheduled_updates\Plugin\BaseUpdateRunner.

Class

BaseUpdateRunner

Namespace

Drupal\scheduled_updates\Plugin

Code

public function getReferencingFieldIds() {
  if (!isset($this->field_ids)) {
    $this->field_ids = [];
    $entity_reference_fields = $this->fieldManager
      ->getFieldMapByFieldType('entity_reference');
    $update_entity_type = $this
      ->updateEntityType();
    if (empty($entity_reference_fields[$update_entity_type])) {
      return $this->field_ids;
    }
    $entity_reference_fields = $entity_reference_fields[$update_entity_type];
    foreach ($entity_reference_fields as $field_id => $entity_reference_field) {
      foreach ($entity_reference_field['bundles'] as $bundle) {
        $field = $this->fieldManager
          ->getFieldDefinitions($update_entity_type, $bundle)[$field_id];
        if ($field instanceof FieldConfig) {
          if ($field
            ->getSetting('target_type') == 'scheduled_update' && !empty($field
            ->getSetting('handler_settings')['target_bundles']) && in_array($this->configuration['updater_type'], $field
            ->getSetting('handler_settings')['target_bundles'])) {
            $this->field_ids[] = $field_id;
          }
        }
      }
    }
  }
  return $this->field_ids;
}