array_intersect_key example



    // Get a list of formats that the current user has access to.     $formats = filter_formats($user);

    // Allow the list of formats to be restricted.     if (isset($element['#allowed_formats'])) {
      // We do not add the fallback format here to allow the use-case of forcing       // certain text formats to be used for certain text areas. In case the       // fallback format is supposed to be allowed as well, it must be added to       // $element['#allowed_formats'] explicitly.       $formats = array_intersect_key($formatsarray_flip($element['#allowed_formats']));
    }

    if (!isset($element['#format']) && !empty($formats)) {
      // If no text format was selected, use the allowed format with the highest       // weight. This is equivalent to calling filter_default_format().       $element['#format'] = reset($formats)->id();
    }

    // If #allowed_formats is set, the list of formats must not be modified in     // any way. Otherwise, however, if all of the following conditions are true,     // remove the fallback format from the list of formats:
/** * The method `headers` returns all request headers as an array. * It is possible to access only the following headers: content-type, content-length, accept, accept-language, user-agent, referer * * @return array<string, array<int, string|null>|string|null> request headers */
    public function headers(): array
    {
        $headers = array_change_key_case($this->request->headers->all());

        return array_intersect_key($headersarray_flip(self::ALLOWED_PARAMETERS));
    }

    /** * The method `cookies` returns all request cookies as an array. * * @return array<string, array<mixed>|bool|float|int|string> request cookies */
    public function cookies(): array
    {
        return $this->request->cookies->all();
    }
}
$data = get_metadata( $object_type$object_id );
    if ( ! $data ) {
        return array();
    }

    $meta_keys = get_registered_meta_keys( $object_type );
    if ( ! empty( $object_subtype ) ) {
        $meta_keys = array_merge( $meta_keysget_registered_meta_keys( $object_type$object_subtype ) );
    }

    return array_intersect_key( $data$meta_keys );
}

/** * Filters out `register_meta()` args based on an allowed list. * * `register_meta()` args may change over time, so requiring the allowed list * to be explicitly turned off is a warranty seal of sorts. * * @access private * @since 5.5.0 * * @param array $args Arguments from `register_meta()`. * @param array $default_args Default arguments for `register_meta()`. * @return array Filtered arguments. */


    private function resolveParameters(ControllerArgumentsEvent $event, ?array $vars): array
    {
        if ([] === $vars) {
            return [];
        }

        $parameters = $event->getNamedArguments();

        if (null !== $vars) {
            $parameters = array_intersect_key($parametersarray_flip($vars));
        }

        return $parameters;
    }
}
$configuration = $this->getConfiguration();
    $entity_type_id = $configuration['target_type'];
    $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
    $bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id);

    if ($entity_type->hasKey('bundle')) {
      $bundle_options = [];
      foreach ($bundles as $bundle_name => $bundle_info) {
        $bundle_options[$bundle_name] = $bundle_info['label'];
      }
      natsort($bundle_options);
      $selected_bundles = array_intersect_key(
        $bundle_options,
        array_filter((array) $configuration['target_bundles'])
      );

      $form['target_bundles'] = [
        '#type' => 'checkboxes',
        '#title' => $entity_type->getBundleLabel(),
        '#options' => $bundle_options,
        '#default_value' => (array) $configuration['target_bundles'],
        '#required' => TRUE,
        '#size' => 6,
        
// Fill in blank post format.         $post_fields['post_format'] = get_post_format( $post['ID'] );
        if ( empty( $post_fields['post_format'] ) ) {
            $post_fields['post_format'] = 'standard';
        }

        // Merge requested $post_fields fields into $_post.         if ( in_array( 'post', $fields, true ) ) {
            $_post = array_merge( $_post$post_fields );
        } else {
            $requested_fields = array_intersect_key( $post_fieldsarray_flip( $fields ) );
            $_post            = array_merge( $_post$requested_fields );
        }

        $all_taxonomy_fields = in_array( 'taxonomies', $fields, true );

        if ( $all_taxonomy_fields || in_array( 'terms', $fields, true ) ) {
            $post_type_taxonomies = get_object_taxonomies( $post['post_type'], 'names' );
            $terms                = wp_get_object_terms( $post['ID']$post_type_taxonomies );
            $_post['terms']       = array();
            foreach ( $terms as $term ) {
                $_post['terms'][] = $this->_prepare_term( $term );
            }
/** * Computes intersection of two HTML restrictions, without wildcard support. * * @param \Drupal\ckeditor5\HTMLRestrictions $other * The HTML restrictions to compare to. * * @return \Drupal\ckeditor5\HTMLRestrictions * Returns a new HTML restrictions value object with all the elements that * are also allowed in $other. */
  public function doIntersect(HTMLRestrictions $other): HTMLRestrictions {
    $intersection_based_on_tags = array_intersect_key($this->elements, $other->elements);
    $intersection = [];
    // Additional filtering is necessary beyond the array_intersect_key that     // computed $intersection_based_on_tags because tag configuration can have     // boolean values that have different logic than array values.     foreach (array_keys($intersection_based_on_tags) as $tag) {
      // If either does not allow attributes, neither does the intersection.       if ($this->elements[$tag] === FALSE || $other->elements[$tag] === FALSE) {
        $intersection[$tag] = FALSE;
        continue;
      }
      // If both allow all attributes, so does the intersection.
$original = !empty($entity->original) ? $entity->original : NULL;

    // Use the loaded revision instead of default one to check for data change.     if ($original && !$entity->isNewRevision() && !$entity->isDefaultRevision()) {
      $original = $this->loadRevision($entity->getLoadedRevisionId());
    }

    // Determine which fields should be actually stored.     $definitions = $this->entityFieldManager->getFieldDefinitions($entity_type$bundle);
    if ($names) {
      $definitions = array_intersect_key($definitionsarray_flip($names));
    }

    foreach ($definitions as $field_name => $field_definition) {
      $storage_definition = $field_definition->getFieldStorageDefinition();
      if (!$table_mapping->requiresDedicatedTableStorage($storage_definition)) {
        continue;
      }

      // When updating an existing revision, keep the existing records if the       // field values did not change.       if (!$entity->isNewRevision() && $original && !$this->hasFieldValueChanged($field_definition$entity$original)) {
        
// Ensure the correct dependencies are present. If the configuration is       // being written during a configuration synchronization then there is no       // need to recalculate the dependencies.       $this->calculateDependencies();
      // If the data is trusted we need to ensure that the dependencies are       // sorted as per their schema. If the save is not trusted then the       // configuration will be sorted by StorableConfigBase.       if ($this->trustedData) {
        $mapping = ['config' => 0, 'content' => 1, 'module' => 2, 'theme' => 3, 'enforced' => 4];
        $dependency_sort = function D$dependencies) use ($mapping) {
          // Only sort the keys that exist.           $mapping_to_replace = array_intersect_key($mapping$dependencies);
          return array_replace($mapping_to_replace$dependencies);
        };
        $this->dependencies = $dependency_sort($this->dependencies);
        if (isset($this->dependencies['enforced'])) {
          $this->dependencies['enforced'] = $dependency_sort($this->dependencies['enforced']);
        }
      }
    }
  }

  /** * {@inheritdoc} */
return $query->execute()->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_UNIQUE);
    }

    /** * @return array */
    private function getPluginsForPreset(array $preset, array $localPlugins)
    {
        $required = $preset['requiredPlugins'];
        $merged = array_merge_recursive($required$localPlugins);
        $plugins = array_values(array_intersect_key($merged$required));

        return array_map(
            function D$plugin) {
                $plugin = array_merge([
                    'active' => false,
                    'plugin_exists' => false,
                    'installed' => false,
                    'plugin_label' => $plugin['label'],
                    'plugin_name' => $plugin['name'],
                    'current_version' => '',
                    'valid' => false,
                ],

    unset($id_definition['type']);

    // Get the field storage definition.     $definition = BaseFieldDefinition::create($type_parts[0]);

    // Get a list of setting keys belonging strictly to the field definition.     $default_field_settings = $definition->getSettings();
    // Separate field definition settings from custom settings. Custom settings     // are settings passed in $id_definition that are not part of field storage     // definition settings.     $field_settings = array_intersect_key($id_definition$default_field_settings);
    $custom_settings = array_diff_key($id_definition$default_field_settings);

    // Resolve schema from field storage definition settings.     $schema = $definition
      ->setSettings($field_settings)
      ->getColumns()[$type_parts[1]];

    // Merge back custom settings.     return $schema + $custom_settings;
  }

  
$namespace = $request['namespace'];

        if ( ! isset( $this->namespaces[ $namespace ] ) ) {
            return new WP_Error(
                'rest_invalid_namespace',
                __( 'The specified namespace could not be found.' ),
                array( 'status' => 404 )
            );
        }

        $routes    = $this->namespaces[ $namespace ];
        $endpoints = array_intersect_key( $this->get_routes()$routes );

        $data     = array(
            'namespace' => $namespace,
            'routes'    => $this->get_data_for_routes( $endpoints$request['context'] ),
        );
        $response = rest_ensure_response( $data );

        // Link to the root index.         $response->add_link( 'up', rest_url( '/' ) );

        /** * Filters the REST API namespace index data. * * This typically is just the route data for the namespace, but you can * add any data you'd like here. * * @since 4.4.0 * * @param WP_REST_Response $response Response data. * @param WP_REST_Request $request Request data. The namespace is passed as the 'namespace' parameter. */
/** * {@inheritdoc} */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  }

  /** * {@inheritdoc} */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    foreach (array_intersect_key($form_state->getValues()$this->configuration) as $config_key => $config_value) {
      $this->configuration[$config_key] = $config_value;
    }

    // If no source field is explicitly set, create it now.     if (empty($this->configuration['source_field'])) {
      $field_storage = $this->createSourceFieldStorage();
      $field_storage->save();
      $this->configuration['source_field'] = $field_storage->getName();
    }
  }

  
list($service_id$unqualified_context_id) = explode(':', $id, 2);
      // Remove the leading '@'.       $service_id = substr($service_id, 1);
      $context_ids_by_service[$service_id][] = $unqualified_context_id;
    }

    // Iterate over all missing context providers (services), gather the     // runtime contexts and assign them as requested.     foreach ($context_ids_by_service as $service_id => $unqualified_context_ids) {
      $contexts_by_service = $this->container->get($service_id)->getRuntimeContexts($unqualified_context_ids);

      $wanted_contexts = array_intersect_key($contexts_by_servicearray_flip($unqualified_context_ids));
      foreach ($wanted_contexts as $unqualified_context_id => $context) {
        $context_id = '@' . $service_id . ':' . $unqualified_context_id;
        $this->contexts[$context_id] = $contexts[$context_id] = $context;
      }
    }

    return $contexts;
  }

  /** * {@inheritdoc} */
// Create a list of options to check.     // @see \Drupal\views\Plugin\views\area\DisplayLink::validate()     $options = [
      'filters' => 'Filter criteria',
      'sorts' => 'Sort criteria',
      'pager' => 'Pager',
      'arguments' => 'Contextual filters',
    ];

    // Create a list of options to check.     // @see \Drupal\views\Plugin\views\area\DisplayLink::validate()     $unequal_options_text = implode(', ', array_intersect_key($optionsarray_flip($unequal_options)));

    $errors = $view->validate();
    $messages = $messenger->messagesByType(MessengerInterface::TYPE_WARNING);

    $this->assertCount(0, $errors);
    $this->assertCount(3, $messages);
    $this->assertSame('<em class="placeholder">Block 1</em>: The link in the <em class="placeholder">header</em> area points to the <em class="placeholder">Page 1</em> display which uses different settings than the <em class="placeholder">Block 1</em> display for: <em class="placeholder">' . $unequal_options_text . '</em>. To make sure users see the exact same result when clicking the link, please check that the settings are the same.', $messages[0]->__toString());
    $this->assertSame('<em class="placeholder">Page 1</em>: The link in the <em class="placeholder">header</em> area points to the <em class="placeholder">Page 2</em> display which uses different settings than the <em class="placeholder">Page 1</em> display for: <em class="placeholder">' . $unequal_options_text . '</em>. To make sure users see the exact same result when clicking the link, please check that the settings are the same.', $messages[1]->__toString());
    $this->assertSame('<em class="placeholder">Page 2</em>: The link in the <em class="placeholder">header</em> area points to the <em class="placeholder">Page 1</em> display which uses different settings than the <em class="placeholder">Page 2</em> display for: <em class="placeholder">' . $unequal_options_text . '</em>. To make sure users see the exact same result when clicking the link, please check that the settings are the same.', $messages[2]->__toString());

    $messenger->deleteAll();

    
Home | Imprint | This part of the site doesn't use cookies.