invokeAll example

$this->entityTypeBundleInfo->clearCachedBundles();
  }

  /** * Tests the getBundleInfo() method. * * @covers ::getBundleInfo * * @dataProvider providerTestGetBundleInfo */
  public function testGetBundleInfo($entity_type_id$expected) {
    $this->moduleHandler->invokeAll('entity_bundle_info')->willReturn([]);
    $this->moduleHandler->alter('entity_bundle_info', Argument::type('array'))->willReturn(NULL);

    $apple = $this->prophesize(EntityTypeInterface::class);
    $apple->getLabel()->willReturn('Apple');
    $apple->getBundleEntityType()->willReturn(NULL);

    $banana = $this->prophesize(EntityTypeInterface::class);
    $banana->getLabel()->willReturn('Banana');
    $banana->getBundleEntityType()->willReturn(NULL);

    $this->setUpEntityTypeDefinitions([
      
/** * {@inheritdoc} */
  public function onBundleCreate($bundle$entity_type_id) {
    $this->entityTypeBundleInfo->clearCachedBundles();
    // Notify the entity storage.     $storage = $this->entityTypeManager->getStorage($entity_type_id);
    if ($storage instanceof EntityBundleListenerInterface) {
      $storage->onBundleCreate($bundle$entity_type_id);
    }
    // Invoke hook_entity_bundle_create() hook.     $this->moduleHandler->invokeAll('entity_bundle_create', [$entity_type_id$bundle]);
    $this->entityFieldManager->clearCachedFieldDefinitions();
  }

  /** * {@inheritdoc} */
  public function onBundleDelete($bundle$entity_type_id) {
    $this->entityTypeBundleInfo->clearCachedBundles();
    // Notify the entity storage.     $storage = $this->entityTypeManager->getStorage($entity_type_id);
    if ($storage instanceof EntityBundleListenerInterface) {
      
return Database::getConnection()->query('SELECT COUNT(*) FROM {shortcut_set_users} WHERE [set_name] = :name', [':name' => $shortcut_set->id()])->fetchField();
  }

  /** * {@inheritdoc} */
  public function getDefaultSet(AccountInterface $account) {
    // Allow modules to return a default shortcut set name. Since we can only     // have one, we allow the last module which returns a valid result to take     // precedence. If no module returns a valid set, fall back on the site-wide     // default, which is the lowest-numbered shortcut set.     $suggestions = array_reverse($this->moduleHandler->invokeAll('shortcut_default_set', [$account]));
    $suggestions[] = 'default';
    $shortcut_set = NULL;
    foreach ($suggestions as $name) {
      if ($shortcut_set = $this->load($name)) {
        break;
      }
    }

    return $shortcut_set;
  }

}
/** * {@inheritdoc} */
  public function getAllBundleInfo() {
    if (empty($this->bundleInfo)) {
      $langcode = $this->languageManager->getCurrentLanguage()->getId();
      if ($cache = $this->cacheGet("entity_bundle_info:$langcode")) {
        $this->bundleInfo = $cache->data;
      }
      else {
        $this->bundleInfo = $this->moduleHandler->invokeAll('entity_bundle_info');
        foreach ($this->entityTypeManager->getDefinitions() as $type => $entity_type) {
          // First look for entity types that act as bundles for others, load them           // and add them as bundles.           if ($bundle_entity_type = $entity_type->getBundleEntityType()) {
            foreach ($this->entityTypeManager->getStorage($bundle_entity_type)->loadMultiple() as $entity) {
              $this->bundleInfo[$type][$entity->id()]['label'] = $entity->label();
            }
          }
          // If entity type bundles are not supported and           // hook_entity_bundle_info() has not already set up bundle           // information, use the entity type name and label.
'display' => [],
    ];
    $cache_id = 'entity_extra_field_info:' . $language_code;

    $language = new Language(['id' => $language_code]);
    $this->languageManager->getCurrentLanguage()
      ->willReturn($language)
      ->shouldBeCalledTimes(1);

    $this->cacheBackend->get($cache_id)->shouldBeCalled();

    $this->moduleHandler->invokeAll('entity_extra_field_info')->willReturn($hook_bundle_extra_fields);
    $this->moduleHandler->alter('entity_extra_field_info', $hook_bundle_extra_fields)->shouldBeCalled();

    $this->cacheBackend->set($cache_id$processed_hook_bundle_extra_fields, Cache::PERMANENT, ['entity_field_info'])->shouldBeCalled();

    $this->assertSame($processed_hook_bundle_extra_fields[$entity_type_id][$bundle]$this->entityFieldManager->getExtraFields($entity_type_id$bundle));
  }

  /** * @covers ::getFieldMap */
  public function testGetFieldMap() {
    
$files = $archive->listContents();
    if (!$files) {
      $this->messenger()->addError($this->t('Provided archive contains no files.'));
      return;
    }

    // Unfortunately, we can only use the directory name to determine the     // project name. Some archivers list the first file as the directory (i.e.,     // MODULE/) and others list an actual file (i.e., MODULE/README.TXT).     $project = strtok($files[0], '/\\');

    $archive_errors = $this->moduleHandler->invokeAll('verify_update_archive', [$project$local_cache$directory]);
    if (!empty($archive_errors)) {
      $this->messenger()->addError(array_shift($archive_errors));
      // @todo: Fix me in D8: We need a way to set multiple errors on the same       // form element and have all of them appear!       if (!empty($archive_errors)) {
        foreach ($archive_errors as $error) {
          $this->messenger()->addError($error);
        }
      }
      return;
    }

    

    return $this->languageTypes;
  }

  /** * {@inheritdoc} */
  public function getDefinedLanguageTypesInfo() {
    if (!isset($this->languageTypesInfo)) {
      $defaults = parent::getDefinedLanguageTypesInfo();

      $info = $this->moduleHandler->invokeAll('language_types_info');
      $language_info = $info + $defaults;

      // Let other modules alter the list of language types.       $this->moduleHandler->alter('language_types_info', $language_info);
      $this->languageTypesInfo = $language_info;
    }
    return $this->languageTypesInfo;
  }

  /** * {@inheritdoc} */

  public function invokeDeprecated($description$module$hook, array $args = []) {
    $result = $this->invoke($module$hook$args);
    $this->triggerDeprecationError($description$hook);
    return $result;
  }

  /** * {@inheritdoc} */
  public function invokeAllDeprecated($description$hook, array $args = []) {
    $result = $this->invokeAll($hook$args);
    $this->triggerDeprecationError($description$hook);
    return $result;
  }

  /** * Triggers an E_USER_DEPRECATED error if any module implements the hook. * * @param string $description * Helpful text describing what to do instead of implementing this hook. * @param string $hook * The name of the hook. */

  protected function getFieldAccess(ResourceType $resource_type$internal_field_name) {
    $definitions = $this->fieldManager->getFieldDefinitions($resource_type->getEntityTypeId()$resource_type->getBundle());
    assert(isset($definitions[$internal_field_name]), 'The field name should have already been validated.');
    $field_definition = $definitions[$internal_field_name];
    $filter_access_results = $this->moduleHandler->invokeAll('jsonapi_entity_field_filter_access', [$field_definition$this->currentUser]);
    $filter_access_result = array_reduce($filter_access_resultsfunction DAccessResultInterface $combined_result, AccessResultInterface $result) {
      return $combined_result->orIf($result);
    }, AccessResult::neutral());
    if (!$filter_access_result->isNeutral()) {
      return $filter_access_result;
    }
    $entity_access_control_handler = $this->entityTypeManager->getAccessControlHandler($resource_type->getEntityTypeId());
    $field_access = $entity_access_control_handler->fieldAccess('view', $field_definition, NULL, NULL, TRUE);
    return $filter_access_result->orIf($field_access);
  }

}
    if ($this->limit) {
      $query->pager($this->limit);
    }
    return $query;
  }

  /** * {@inheritdoc} */
  public function getOperations(EntityInterface $entity) {
    $operations = $this->getDefaultOperations($entity);
    $operations += $this->moduleHandler()->invokeAll('entity_operation', [$entity]);
    $this->moduleHandler->alter('entity_operation', $operations$entity);
    uasort($operations, '\Drupal\Component\Utility\SortArray::sortByWeightElement');

    return $operations;
  }

  /** * Gets this list's default operations. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity the operations are for. * * @return array * The array structure is identical to the return value of * self::getOperations(). */


  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    foreach ($this->mapper->getConfigNames() as $name) {
      $this->languageManager->getLanguageConfigOverride($this->language->getId()$name)->delete();
    }

    // Flush all persistent caches.     $this->moduleHandler->invokeAll('cache_flush');
    foreach (Cache::getBins() as $cache_backend) {
      $cache_backend->deleteAll();
    }

    $this->messenger()->addStatus($this->t('@language translation of %label was deleted', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]));

    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}
$query->comment($this->options['query_comment']);
    }

    // Add the query tags.     if (!empty($this->options['query_tags'])) {
      foreach ($this->options['query_tags'] as $tag) {
        $query->addTag($tag);
      }
    }

    // Add all query substitutions as metadata.     $query->addMetaData('views_substitutions', \Drupal::moduleHandler()->invokeAll('views_query_substitutions', [$this->view]));

    return $query;
  }

  /** * Get the arguments attached to the WHERE and HAVING clauses of this query. */
  public function getWhereArgs() {
    return array_merge(...array_column($this->where, 'args'), ...array_column($this->having, 'args'));
  }

  

  protected function loadExtraFields(): array {
    // Read from the persistent cache. Since hook_entity_extra_field_info() and     // hook_entity_extra_field_info_alter() might contain t() calls, we cache     // per language.     $cache_id = 'entity_extra_field_info:' . $this->languageManager->getCurrentLanguage()->getId();
    $cached = $this->cacheGet($cache_id);
    if ($cached) {
      return $cached->data;
    }

    $extra = $this->moduleHandler->invokeAll('entity_extra_field_info');
    $this->moduleHandler->alter('entity_extra_field_info', $extra);

    // Apply default values to each bundle.     foreach ($extra as $entity_type_id => $extra_fields_by_bundle) {
      foreach ($extra_fields_by_bundle as $bundle => $bundle_extra_fields) {
        $extra[$entity_type_id][$bundle] += [
          'form' => [],
          'display' => [],
        ];
      }
    }

    


      $themes_installed[] = $key;
      // Record the fact that it was installed.       $this->logger->info('%theme theme installed.', ['%theme' => $key]);
    }

    $this->cssCollectionOptimizer->deleteAll();
    $this->resetSystem();

    // Invoke hook_themes_installed() after the themes have been installed.     $this->moduleHandler->invokeAll('themes_installed', [$themes_installed]);

    return !empty($themes_installed);
  }

  /** * {@inheritdoc} */
  public function uninstall(array $theme_list) {
    $extension_config = $this->configFactory->getEditable('core.extension');
    $theme_config = $this->configFactory->getEditable('system.theme');
    $list = $this->themeHandler->listInfo();
    
/** * {@inheritdoc} */
  public function disable() {
    if ($this->isFallbackFormat()) {
      throw new \LogicException("The fallback text format '{$this->id()}' cannot be disabled.");
    }

    parent::disable();

    // Allow modules to react on text format deletion.     \Drupal::moduleHandler()->invokeAll('filter_format_disable', [$this]);

    // Clear the filter cache whenever a text format is disabled.     filter_formats_reset();

    return $this;
  }

  /** * {@inheritdoc} */
  public function preSave(EntityStorageInterface $storage) {
    
Home | Imprint | This part of the site doesn't use cookies.