Commit 157f82aa authored by Tim Bozeman's avatar Tim Bozeman Committed by Tim Bozeman
Browse files

Issue #3281241 by Tim Bozeman, heddn: Namespace for assets is under component_library

parent 22b6b3a4
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ use Drupal\Core\Entity\EntityStorageInterface;
 *   config_export = {
 *     "id",
 *     "label",
 *     "theme",
 *     "files",
 *   }
 * )
@@ -62,11 +61,6 @@ final class ComponentLibraryAsset extends ConfigEntityBase {
   */
  protected string $label;

  /**
   * The theme the component_library_asset entity is associated with.
   */
  protected string $theme;

  /**
   * An array of file attributes with the following elements:
   * - 'code': The JS or CSS file contents.
+0 −36
Original line number Diff line number Diff line
@@ -5,37 +5,13 @@ declare(strict_types=1);
namespace Drupal\component_library\Form;

use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * The configuration form for component_library_asset entities.
 */
final class ComponentLibraryAssetForm extends EntityForm {

  protected ThemeHandlerInterface $themeHandler;

  /**
   * Constructs a new ComponentLibraryAssetForm.
   *
   * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
   *   The theme handler.
   */
  public function __construct(ThemeHandlerInterface $theme_handler) {
    $this->themeHandler = $theme_handler;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container): self {
    return new self(
      $container->get('theme_handler'),
    );
  }

  /**
   * {@inheritdoc}
   */
@@ -60,18 +36,6 @@ final class ComponentLibraryAssetForm extends EntityForm {
      '#disabled' => !$this->entity->isNew(),
    ];

    $themes = $this->themeHandler->listInfo();
    $themes = \array_filter($themes, fn (Extension $theme) => $this->themeHandler->hasUi($theme->getName()));
    $themes = \array_combine(\array_keys($themes), \array_keys($themes));
    $form['theme'] = [
      '#type' => 'select',
      '#title' => $this->t('Theme'),
      '#empty_option' => $this->t('- Select -'),
      '#default_value' => $form_state->getValue('theme') ?? $this->entity->get('theme') ?? '',
      '#options' => $themes,
      '#required' => TRUE,
    ];

    $form['files'] = [
      '#type' => 'fieldset',
      '#tree' => TRUE,
+4 −1
Original line number Diff line number Diff line
@@ -626,7 +626,10 @@ final class ComponentOverrideForm extends EntityForm {
        }
      }
      $this->cacheDefault->set(self::COLLECTED_LIBRARIES_CID, $available_libraries, Cache::PERMANENT, ['library_info']);
      return $available_libraries;
      $component_library_libraries = $available_libraries['component_library'];
      // Move Component Libraries to the front of the line.
      unset($available_libraries['component_library']);
      return ['component_library' => $component_library_libraries] + $available_libraries;
    }
  }