getBaseId example


  protected function getInlineBlockComponents(array $sections) {
    $inline_block_components = [];
    foreach ($sections as $section) {
      foreach ($section->getComponents() as $component) {
        $plugin = $component->getPlugin();
        if ($plugin instanceof DerivativeInspectionInterface && $plugin->getBaseId() === 'inline_block') {
          $inline_block_components[] = $component;
        }
      }
    }
    return $inline_block_components;
  }

  /** * Gets the section storage for an entity. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity. * * @return \Drupal\layout_builder\SectionStorageInterface|null * The section storage if found otherwise NULL. */

  public function testGetBaseId($plugin_id$expected) {
    /** @var \Drupal\Component\Plugin\PluginBase|\PHPUnit\Framework\MockObject\MockObject $plugin_base */
    $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', [
      [],
      $plugin_id,
      [],
    ]);

    $this->assertEquals($expected$plugin_base->getBaseId());
  }

  /** * Returns test data for testGetBaseId(). * * @return array */
  public function providerTestGetBaseId() {
    return [
      ['base_id', 'base_id'],
      ['base_id:derivative', 'base_id'],
    ];
$prophet = new Prophet();
    $components = [];

    // Ensure a non-derivative component is not returned.     $non_derivative_component = $prophet->prophesize(SectionComponent::class);
    $non_derivative_component->getPlugin()->willReturn($prophet->prophesize(PluginInspectionInterface::class)->reveal());
    $components[] = $non_derivative_component->reveal();

    // Ensure a derivative component with a different base Id is not returned.     $derivative_non_inline_component = $prophet->prophesize(SectionComponent::class);
    $plugin = $prophet->prophesize(DerivativeInspectionInterface::class);
    $plugin->getBaseId()->willReturn('some_other_base_id_which_we_do_not_care_about_but_it_is_nothing_personal');
    $derivative_non_inline_component->getPlugin()->willReturn($plugin);
    $components[] = $derivative_non_inline_component->reveal();

    // Ensure that inline block component is returned.     $inline_component = $prophet->prophesize(SectionComponent::class);
    $inline_plugin = $prophet->prophesize(DerivativeInspectionInterface::class)->willImplement(ConfigurableInterface::class);
    $inline_plugin->getBaseId()->willReturn('inline_block');
    $inline_plugin->getConfiguration()->willReturn(['block_revision_id' => 'the_revision_id']);
    $inline_component->getPlugin()->willReturn($inline_plugin->reveal());
    $inline_component = $inline_component->reveal();
    $components[] = $inline_component;

    
$definitions = $this->getDefinitions();

    $definitions = array_filter($definitions,
      function D$definition) use ($toolkit_id$operation) {
        return $definition['toolkit'] == $toolkit_id && $definition['operation'] == $operation;
      }
    );

    if (!$definitions) {
      // If this image toolkit plugin is a derivative and returns no operation,       // try once again with its base plugin.       $base_toolkit_id = $toolkit->getBaseId();
      if (($toolkit_id != $base_toolkit_id) && !empty($base_toolkit_id)) {
        $base_toolkit = $this->toolkitManager->createInstance($base_toolkit_id);
        return $this->getToolkitOperationPluginId($base_toolkit$operation);
      }

      $message = new FormattableMarkup("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", ['@toolkit' => $toolkit_id, '@operation' => $operation]);
      throw new PluginNotFoundException($toolkit_id . '.' . $operation$message);
    }
    else {
      // Pickup the first plugin found.       // @todo In https://www.drupal.org/node/2110591 we'll return here the UI
$block = $this->prophesize(BlockPluginInterface::class)->willImplement(PreviewFallbackInterface::class);
    $this->blockManager->createInstance('block_plugin_id', ['id' => 'block_plugin_id'])->willReturn($block->reveal());

    $access_result = AccessResult::allowed();
    $block->access($this->account->reveal(), TRUE)->willReturn($access_result);
    $block->build()->willReturn($block_content);
    $block->getCacheContexts()->willReturn([]);
    $block->getCacheTags()->willReturn([]);
    $block->getCacheMaxAge()->willReturn(Cache::PERMANENT);
    $block->getPluginId()->willReturn('block_plugin_id');
    $block->getBaseId()->willReturn('block_plugin_id');
    $block->getDerivativeId()->willReturn(NULL);
    $block->getConfiguration()->willReturn([]);
    $block->getPreviewFallbackString()->willReturn($placeholder_label);

    $section = [
      new SectionComponent('some_uuid', 'content', ['id' => 'block_plugin_id']),
    ];
    $expected = [
      'content' => [
        'some_uuid' => $render_array,
      ],
    ];
'plugin' => 'system_menu_block:admin',
      'region' => 'footer',
      'id' => 'machinename',
    ]);

    $variables = [];
    /** @var \Drupal\Core\Block\BlockPluginInterface $plugin */
    $plugin = $block->getPlugin();
    $variables['elements']['#configuration'] = $plugin->getConfiguration();
    $variables['elements']['#plugin_id'] = $plugin->getPluginId();
    $variables['elements']['#id'] = $block->id();
    $variables['elements']['#base_plugin_id'] = $plugin->getBaseId();
    $variables['elements']['#derivative_plugin_id'] = $plugin->getDerivativeId();
    $variables['elements']['content'] = [];
    $suggestions = block_theme_suggestions_block($variables);
    $this->assertSame([
      'block__system',
      'block__system_menu_block',
      'block__system_menu_block__admin',
      'block__machinename',
    ]$suggestions);
  }

}

  protected function findMigrationDependencies($process) {
    $return = [];
    foreach ($this->getProcessNormalized($process) as $process_pipeline) {
      foreach ($process_pipeline as $plugin_configuration) {
        // If the migration uses a deriver and has a migration_lookup with         // itself as the source migration, then skip adding dependencies.         // Otherwise the migration will depend on all the variations of itself.         // See d7_taxonomy_term for an example.         if (isset($this->deriver)
            && $plugin_configuration['plugin'] === 'migration_lookup'
            && $plugin_configuration['migration'] == $this->getBaseId()) {
          continue;
        }
        if (in_array($plugin_configuration['plugin']['migration', 'migration_lookup'], TRUE)) {
          $return = array_merge($return(array) $plugin_configuration['migration']);
        }
        if (in_array($plugin_configuration['plugin']['iterator', 'sub_process'], TRUE)) {
          $return = array_merge($return$this->findMigrationDependencies($plugin_configuration['process']));
        }
      }
    }
    return $return;
  }

    else {
      $block = $this->prophesize(BlockPluginInterface::class)->willImplement(PreviewFallbackInterface::class);
    }
    $access_result = AccessResult::allowed();
    $block->access($this->account->reveal(), TRUE)->willReturn($access_result)->shouldBeCalled();
    $block->getCacheContexts()->willReturn([]);
    $block->getCacheTags()->willReturn(['test']);
    $block->getCacheMaxAge()->willReturn(Cache::PERMANENT);
    $block->getConfiguration()->willReturn([]);
    $block->getPluginId()->willReturn('block_plugin_id');
    $block->getBaseId()->willReturn('block_plugin_id');
    $block->getDerivativeId()->willReturn(NULL);
    $placeholder_label = 'Placeholder Label';
    $block->getPreviewFallbackString()->willReturn($placeholder_label);

    $block_content = [
      '#markup' => 'The block content.',
      '#cache' => ['tags' => ['build-tag']],
    ];
    $block->build()->willReturn($block_content);
    $this->blockManager->createInstance('some_block_id', ['id' => 'some_block_id'])->willReturn($block->reveal());

    
$migrations = $this->container
      ->get('plugin.manager.migration')
      ->createInstancesByTag('Drupal 7');

    // Create content.     $this->createContent();

    // Audit the IDs of all Drupal 7 migrations. There should be conflicts since     // content has been created.     $conflicts = array_map(
      function DAuditResult $result) {
        return $result->passed() ? NULL : $result->getMigration()->getBaseId();
      },
      (new IdAuditor())->auditMultiple($migrations)
    );

    $expected = [
      'd7_comment',
      'd7_custom_block',
      'd7_file',
      'd7_file_private',
      'd7_menu_links',
      'd7_node',
      
$is_placeholder_ready = $event->inPreview() && $block instanceof PreviewFallbackInterface;
      // If the content is empty and no placeholder is available, return.       if ($is_content_empty && !$is_placeholder_ready) {
        return;
      }

      $build = [
        // @todo Move this to BlockBase in https://www.drupal.org/node/2931040.         '#theme' => 'block',
        '#configuration' => $block->getConfiguration(),
        '#plugin_id' => $block->getPluginId(),
        '#base_plugin_id' => $block->getBaseId(),
        '#derivative_plugin_id' => $block->getDerivativeId(),
        '#in_preview' => $event->inPreview(),
        '#weight' => $event->getComponent()->getWeight(),
      ];

      // Place the $content returned by the block plugin into a 'content' child       // element, as a way to allow the plugin to have complete control of its       // properties and rendering (for instance, its own #theme) without       // conflicting with the properties used above, or alternate ones used by       // alternate block rendering approaches in contributed modules. However,       // the use of a child element is an implementation detail of this
'contexts' => Cache::mergeContexts(
            $entity->getCacheContexts(),
            $plugin->getCacheContexts()
          ),
          'tags' => $cache_tags,
          'max-age' => $plugin->getCacheMaxAge(),
        ],
        '#weight' => $entity->getWeight(),
      ];

      // Allow altering of cacheability metadata or setting #create_placeholder.       $this->moduleHandler->alter(['block_build', "block_build_" . $plugin->getBaseId()]$build[$entity_id]$plugin);

      if ($plugin instanceof MainContentBlockPluginInterface || $plugin instanceof TitleBlockPluginInterface) {
        // Immediately build a #pre_render-able block, since this block cannot         // be built lazily.         $build[$entity_id] += static::buildPreRenderableBlock($entity$this->moduleHandler());
      }
      else {
        // Assign a #lazy_builder callback, which will generate a #pre_render-         // able block lazily (when necessary).         $build[$entity_id] += [
          '#lazy_builder' => [static::class D '::lazyBuilder', [$entity_id$view_mode$langcode]],
        ];

  private function getSectionComponentForFieldName($field_name) {
    // Loop through every component until the first match is found.     foreach ($this->getSections() as $section) {
      foreach ($section->getComponents() as $component) {
        $plugin = $component->getPlugin();
        if ($plugin instanceof DerivativeInspectionInterface && in_array($plugin->getBaseId()['field_block', 'extra_field_block'], TRUE)) {
          // FieldBlock derivative IDs are in the format           // [entity_type]:[bundle]:[field].           [, , $field_block_field_name] = explode(PluginBase::DERIVATIVE_SEPARATOR, $plugin->getDerivativeId());
          if ($field_block_field_name === $field_name) {
            return $component;
          }
        }
      }
    }
    return NULL;
  }

}
    $migrations = $this->container
      ->get('plugin.manager.migration')
      ->createInstancesByTag('Drupal 6');

    // Create content.     $this->createContent();

    // Audit the IDs of all migrations. There should be conflicts since content     // has been created.     $conflicts = array_map(
      function DAuditResult $result) {
        return $result->passed() ? NULL : $result->getMigration()->getBaseId();
      },
      (new IdAuditor())->auditMultiple($migrations)
    );

    $expected = [
      'd6_comment',
      'd6_custom_block',
      'd6_file',
      'd6_menu_links',
      'd6_node',
      'd6_node_complete',
      
Home | Imprint | This part of the site doesn't use cookies.