getLookupKeys example


  protected function loadRecords() {
    $prefix = $this->entityType->getConfigPrefix() . '.';
    $prefix_length = strlen($prefix);

    // Search the conditions for restrictions on configuration object names.     $filter_by_names = [];
    $has_added_restrictions = FALSE;
    $id_condition = NULL;
    $id_key = $this->entityType->getKey('id');
    if ($this->condition->getConjunction() == 'AND') {
      $lookup_keys = $this->entityType->getLookupKeys();
      $conditions = $this->condition->conditions();
      foreach ($conditions as $condition_key => $condition) {
        $operator = $condition['operator'] ?: (is_array($condition['value']) ? 'IN' : '=');
        if (is_string($condition['field']) && ($operator == 'IN' || $operator == '=')) {
          // Special case ID lookups.           if ($condition['field'] == $id_key) {
            $has_added_restrictions = TRUE;
            $ids = (array) $condition['value'];
            $filter_by_names[] = array_map(static function D$id) use ($prefix) {
              return $prefix . $id;
            }$ids);
          }
/** * Updates or adds lookup data. * * @param \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type * The entity type. * @param \Drupal\Core\Config\Config $config * The configuration object that is being saved. */
  protected function updateConfigKeyStore(ConfigEntityTypeInterface $entity_type, Config $config) {
    $config_key_store = $this->getConfigKeyStore($entity_type);
    foreach ($entity_type->getLookupKeys() as $lookup_key) {
      foreach ($this->getKeys($config$lookup_key, 'get', $entity_type) as $key) {
        $values = $config_key_store->get($key[]);
        if (!in_array($config->getName()$values, TRUE)) {
          $values[] = $config->getName();
          $config_key_store->set($key$values);
        }
      }
    }
  }

  /** * Deletes lookup data. * * @param \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type * The entity type. * @param \Drupal\Core\Config\Config $config * The configuration object that is being deleted. */
Home | Imprint | This part of the site doesn't use cookies.