In order to overcome the issue of a stylesheet not being generated when the configuration changes, as highlighted in point 4 of this comment #3114980-7: Add some automated tests

The creation of the stylesheet should be moved to an event subscriber instead. This should function as a good start for creating one: https://www.drupal.org/docs/8/creating-custom-modules/subscribe-to-and-d...

Comments

Neograph734 created an issue. See original summary.

neograph734’s picture

Status: Active » Needs review
StatusFileSize
new3.41 KB

Something like this I think..

Status: Needs review » Needs work

The last submitted patch, 2: 3115713-stylesheet-event-subscriber-2.diff, failed testing. View results

neograph734’s picture

Status: Needs work » Needs review
hkirsman’s picture

I haven't worked with events but I see this is pretty cool.

I tested with drush cim and worked nicely.

I also see that it's good opportunity get rid of some code duplication. We don't need install hook anymore as on module install the configuration is created and hook is triggered. We also don't need to duplicate the css saving in update hook because if we trigger configuration save, css is also saved.

Adding patch and interdiff.

PS: I noticed there's no uninstall hook so the css is left behind. Added task here https://www.drupal.org/project/high_contrast/issues/3116364

Status: Needs review » Needs work

The last submitted patch, 5: high_contrast-stylesheet-event-subscriber-3115713-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

hkirsman’s picture

Last build failed as the use is not needed in install file anymore. It might be that it still fails - not sure if it's looking for tests? Adding patch.

  • Neograph734 committed f848fbd on 8.x-1.x
    Issue #3115713 by hkirsman, Neograph734: Move stylesheet generation to...
neograph734’s picture

Status: Needs work » Fixed

The 'unused use' is just a coding standards message. It probably failed because there are no tests.
But the code looks good to me.

Status: Fixed » Closed (fixed)

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