Problem/Motivation

The current approach where the steps taken to generate a theme are defined in a centralized place works well with one starterkit theme. However, in future we'd ideally like to make it possible to use different themes as the starting point.

Proposed resolution

Allow starterkit themes to control how the theme is generated by adding and potentially removing steps that are taken to generate a new theme. This way the process to generate a theme could vary depending on which theme is used for generating the new theme.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3206217

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lauriii created an issue. See original summary.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mglaman’s picture

In #3206219: Allow configuring which theme is used as a starterkit theme, we found areas of starterkit themes that may not be covered. This was done by allowing Olivero to be used as a starterkit in manual testing.

Specifically this comment: #3206219-11: Allow configuring which theme is used as a starterkit theme

Some of these may be gaps in the default centralized process and some may need to be handled by the themes themselves.

mherchel’s picture

Issue summary: View changes
mherchel’s picture

Issue summary: View changes

ahh! Posted summary change in the wrong issue.

lauriii’s picture

Good call on leaving out the Olivero specific problems found on #3206219-11: Allow configuring which theme is used as a starterkit theme. I think what's needed here is to come up with an API that would allow Olivero to extend the generic starterkit theme generator to correctly change the things mentioned there. I'm wondering if all that's needed is providing a "hook" for the starterkit themes to allow them to add additional code that should be executed towards the end of \Drupal\Core\Command\GenerateTheme::execute?

mglaman’s picture

I imagine a file that can be autoloaded/discovered like a module's ServiceProvider class. This has to implement an interface which contains various integration hooks. Maybe just one big one. It doesn't get copied over, though, to the new theme.

This is the escape hatch for weird bugs until they get fixed in Drupal core.

This is the code I'm referring to

    // Load each module's serviceProvider class.
    foreach ($module_filenames as $module => $filename) {
      $camelized = ContainerBuilder::camelize($module);
      $name = "{$camelized}ServiceProvider";
      $class = "Drupal\\{$module}\\{$name}";
      if (class_exists($class)) {
        $this->serviceProviderClasses['app'][$module] = $class;
      }

mglaman’s picture

Assigned: Unassigned » mglaman

Going to take a stab at this!

I don't remember our exact notes from our Slack discussions/calls. But I think the idea was:

* Themes provide a specific class to be invoked, which doesn't get copied over
* The class is invokable (__invoke) so we don't have to mess with methods names and bikeshedding, open-ended API
* The class __invoke should receive the destination path so it can make changes

mglaman’s picture

Status: Active » Needs work

Tossing up initial proof of concept. Words will need to be tossed around and decided upon.

mglaman’s picture

Component: other » Starterkit theme
Status: Needs work » Needs review

Changing the component to "Starterkit theme"

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

This looks great.

  • lauriii committed de48162 on 10.0.x
    Issue #3206217 by mglaman, lauriii, alexpott: Allow starterkit themes to...

  • lauriii committed 7651219 on 9.4.x
    Issue #3206217 by mglaman, lauriii, alexpott: Allow starterkit themes to...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed de48162 and pushed to 10.0.x. Also cherry-picked to 9.4.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.