isConfigurable example

protected function setUp(): void {
    parent::setUp();
    $this->manager = $this->container->get('plugin.manager.ckeditor5.plugin');
  }

  /** * Tests default settings for configurable CKEditor 5 plugins. */
  public function testDefaults() {
    $all_definitions = $this->manager->getDefinitions();
    $configurable_definitions = array_filter($all_definitionsfunction DCKEditor5PluginDefinition $definition): bool {
      return $definition->isConfigurable();
    });
    $default_plugin_settings = [];
    foreach (array_keys($configurable_definitions) as $plugin_name) {
      $default_plugin_settings[$plugin_name] = $this->manager->getPlugin($plugin_name, NULL)->defaultConfiguration();
    }

    $expected_default_plugin_settings = [
      'ckeditor5_heading' => [
        'enabled_headings' => [
          'heading2',
          'heading3',
          
$container->get('entity_type.manager')->getStorage($entity_type->id()),
      $container->get('plugin.manager.action')
    );
  }

  /** * {@inheritdoc} */
  public function load() {
    $entities = parent::load();
    foreach ($entities as $entity) {
      if ($entity->isConfigurable()) {
        $this->hasConfigurableActions = TRUE;
        break;
      }
    }
    return $entities;
  }

  /** * {@inheritdoc} */
  public function buildRow(EntityInterface $entity) {
    
'producerName' => $app->getAuthor(),
            'license' => $app->getLicense(),
            'version' => $app->getVersion(),
            'privacyPolicyLink' => $app->getPrivacy(),
            'iconRaw' => $app->getIcon(),
            'installedAt' => $app->getCreatedAt(),
            'permissions' => $app->getAclRole() !== null ? $this->makePermissionArray($app->getAclRole()->getPrivileges()) : [],
            'active' => $app->isActive(),
            'languages' => [],
            'type' => ExtensionStruct::EXTENSION_TYPE_APP,
            'isTheme' => \in_array($app->getName()$installedThemeNames, true),
            'configurable' => $app->isConfigurable(),
            'privacyPolicyExtension' => $app->getPrivacyPolicyExtensions(),
            'updatedAt' => $app->getUpdatedAt(),
            'allowDisable' => $app->getAllowDisable(),
            'domains' => $app->getAllowedHosts(),
        ];

        $appTranslations = $app->getTranslations();

        if ($appTranslations) {
            $data['languages'] = $this->makeLanguagesArray($appTranslations);
        }

        

  private function shouldHaveVisiblePluginSettingsForm(CKEditor5PluginDefinition $definition, EditorInterface $editor): bool {
    assert($definition->isConfigurable());
    $enabled_plugins = $this->ckeditor5PluginManager->getEnabledDefinitions($editor);

    $plugin_id = $definition->id();

    // Enabled plugins should be configurable.     if (isset($enabled_plugins[$plugin_id])) {
      return TRUE;
    }

    // There are two circumstances where a plugin not listed in $enabled_plugins     // due to isEnabled() returning false, that should still have its config
/** * Gets all configurable CKEditor 5 plugin definitions that are enabled. * * @return \Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition[] * An array of enabled configurable CKEditor 5 plugin definitions. */
  private function getConfigurableEnabledDefinitions(): array {
    $text_editor = $this->createTextEditorObjectFromContext();
    $enabled_definitions = $this->pluginManager->getEnabledDefinitions($text_editor);
    $configurable_enabled_definitions = array_filter($enabled_definitionsfunction DCKEditor5PluginDefinition $definition): bool {
      return $definition->isConfigurable();
    });

    return $configurable_enabled_definitions;
  }

}
/** * Adds default settings for all enabled CKEditor 5 plugins. * * @param \Drupal\editor\EditorInterface $editor * The text editor config entity to update. */
  private function addDefaultSettingsForEnabledConfigurablePlugins(EditorInterface $editor): void {
    $settings = $editor->getSettings();
    $update_settings = FALSE;
    $enabled_definitions = $this->pluginManager->getEnabledDefinitions($editor);
    $configurable_definitions = array_filter($enabled_definitionsfunction DCKEditor5PluginDefinition $definition): bool {
      return $definition->isConfigurable();
    });

    foreach ($configurable_definitions as $plugin_name => $definition) {
      $default_plugin_configuration = $this->pluginManager->getPlugin($plugin_name, NULL)->defaultConfiguration();
      // Skip plugins with an empty default configuration, the plugin       // configuration is most likely stored elsewhere. Also skip any plugin       // that already has configuration data as default values are not needed.       if ($default_plugin_configuration === [] || isset($settings['plugins'][$plugin_name])) {
        continue;
      }
      $update_settings = TRUE;
      
// assert formatting with \n and \t is preserved         static::assertEquals(
            'Following personal information will be processed on shopware AG\'s servers: - Name - Billing address - Order value',
            $appEntity->getPrivacyPolicyExtensions()
        );

        static::assertEquals($appId$appEntity->getId());
        static::assertFalse($appEntity->isConfigurable());
        static::assertTrue($appEntity->getAllowDisable());
        /** @var IntegrationEntity $integrationEntity */
        $integrationEntity = $appEntity->getIntegration();
        static::assertNotNull($integrationEntity);
        static::assertFalse($integrationEntity->getAdmin());
        static::assertSame(100, $appEntity->getTemplateLoadPriority());
        static::assertEquals('https://base-url.com', $appEntity->getBaseAppUrl());

        $this->assertDefaultActionButtons();
        $this->assertDefaultModules($appEntity);
        $this->assertDefaultPrivileges($appEntity->getAclRoleId());
        
/** * @coversDefaultClass \Drupal\Component\Plugin\PluginHelper * @group Plugin * @group legacy */
class PluginHelperLegacyTest extends TestCase {
  use ExpectDeprecationTrait;

  public function testPluginHelperDeprecation(): void {
    $this->expectDeprecation('The Drupal\Component\Plugin\PluginHelper is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Instead, use instanceof() to check for \Drupal\Component\Plugin\ConfigurableInterface. See http://drupal.org/node/3198285');
    $this->assertEquals($this instanceof ConfigurableInterface, PluginHelper::isConfigurable($this));
    $plugin = $this->createMock(ConfigurableInterface::class);
    $this->assertEquals($plugin instanceof ConfigurableInterface, PluginHelper::isConfigurable($plugin));
  }

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