localgovdrupal / localgov_workflows

Default editorial workflow for LocalGov Drupal content.
GNU General Public License v2.0
0 stars 1 forks source link

Install contributor role if it doesn't already exist. #6

Closed stephen-cox closed 2 years ago

stephen-cox commented 2 years ago

Added update hook to install contributor role if it doesn't already exists

Closes #5

Adnan-cds commented 2 years ago

Hi Steve, Thanks for this change. I have test it and may have spotted two issues:

So this change clearly works on a site where localgov_workflows is already installed but perhaps not on sites which never installed localgov_workflows. This may be a nonissue given that every LocalGov site probably already have the localgov_workflows module installed, right?

After doing drush updatedb, I exported the config and noticed that the exported user.role.localgov_contributor.yml file is missing the UUID property. This may be an issue given that other role config files do have a UUID (and also the _core) property :(

stephen-cox commented 2 years ago

Thanks for taking a look @Adnan-cds

I should have fixed both issue.

stephen-cox commented 2 years ago

Thanks @Adnan-cds for the pointer the where we're doing this already. I realised it's better to use create the user role with

\Drupal::entityTypeManager()->getStorage('user_role')
  ->create($contributor_config)
  ->save();

as this adds the UUID without needing to do it manually.

Adnan-cds commented 2 years ago

Thanks Steve. Feel free to merge.