getParentIds example

/** * Helper method for ::getActiveTrailIds(). */
  protected function doGetActiveTrailIds($menu_name) {
    // Parent ids; used both as key and value to ensure uniqueness.     // We always want all the top-level links with parent == ''.     $active_trail = ['' => ''];

    // If a link in the given menu indeed matches the route, then use it to     // complete the active trail.     if ($active_link = $this->getActiveLink($menu_name)) {
      if ($parents = $this->menuLinkManager->getParentIds($active_link->getPluginId())) {
        $active_trail = $parents + $active_trail;
      }
    }

    return $active_trail;
  }

  /** * {@inheritdoc} */
  public function getActiveLink($menu_name = NULL) {
    
/** * {@inheritdoc} */
  public function form(array $form, FormStateInterface $form_state) {
    $term = $this->entity;
    $vocab_storage = $this->entityTypeManager->getStorage('taxonomy_vocabulary');
    /** @var \Drupal\taxonomy\TermStorageInterface $taxonomy_storage */
    $taxonomy_storage = $this->entityTypeManager->getStorage('taxonomy_term');
    $vocabulary = $vocab_storage->load($term->bundle());

    $parent = $this->getParentIds($term);
    $form_state->set(['taxonomy', 'parent']$parent);
    $form_state->set(['taxonomy', 'vocabulary']$vocabulary);

    $form['relations'] = [
      '#type' => 'details',
      '#title' => $this->t('Relations'),
      '#open' => $taxonomy_storage->getVocabularyHierarchyType($vocabulary->id()) == VocabularyInterface::HIERARCHY_MULTIPLE,
      '#weight' => 10,
    ];

    // \Drupal\taxonomy\TermStorageInterface::loadTree() and

        }

        if ($idsWithChangedParentIds !== []) {
            $this->treeUpdater->batchUpdate(
                $idsWithChangedParentIds,
                MediaFolderDefinition::ENTITY_NAME,
                $event->getContext()
            );
        }

        $updates = array_values(array_merge($updates$this->fetchChildren($updates)$this->getParentIds($updates)));

        return new MediaIndexingMessage($updates, null, $event->getContext());
    }

    public function handle(EntityIndexingMessage $message): void
    {
        $context = $message->getContext();

        $ids = $message->getData();
        $ids = array_filter(array_unique($ids));

        
if (Feature::isActive('STOCK_HANDLING')) {
                $this->stockStorage->index(array_values($stocks)$event->getContext());
            } else {
                $this->stockUpdater->update(array_values($stocks)$event->getContext());
            }
        });

        $message = new ProductIndexingMessage(array_values($updates), null, $event->getContext());
        $message->addSkip(self::INHERITANCE_UPDATER, self::STOCK_UPDATER);

        $delayed = \array_unique(\array_filter(\array_merge(
            $this->getParentIds($updates),
            $this->getChildrenIds($updates)
        )));

        foreach (\array_chunk($delayed, 50) as $chunk) {
            $child = new ProductIndexingMessage($chunk, null, $event->getContext());
            $child->setIndexer($this->getName());
            EntityIndexerRegistry::addSkips($child$event->getContext());

            $this->messageBus->dispatch($child);
        }

        
if (isset($expected_item['children'])) {
      $child_ids = array_values($menu_link_manager->getChildIds($menu_plugin_id));
      sort($expected_item['children']);
      if ($child_ids) {
        sort($child_ids);
      }
      $this->assertSame($expected_item['children']$child_ids);
      unset($expected_item['children']);
    }

    if (isset($expected_item['parents'])) {
      $parent_ids = array_values($menu_link_manager->getParentIds($menu_plugin_id));
      $this->assertSame($expected_item['parents']$parent_ids);
      unset($expected_item['parents']);
    }

    if (isset($expected_item['langcode']) && $entity) {
      $this->assertEquals($expected_item['langcode']$entity->langcode->value);
      unset($expected_item['langcode']);
    }

    if (isset($expected_item['enabled']) && $entity) {
      $this->assertEquals($expected_item['enabled']$entity->enabled->value);
      
Home | Imprint | This part of the site doesn't use cookies.