DEV Community

Cover image for Managing Drupal Like Salesforce
Kevin Reynen
Kevin Reynen

Posted on • Edited on

Managing Drupal Like Salesforce

These are the links and resources from my presentation at https://webcamp.stanford.edu/session/managing-drupal-like-salesforce. The recording is available on YouTube, but it captured presenter mode instead of the presentation.

The difference in the amount our dev team has been able to contribute before vs. after completing the customized
version of the training Mike Anello did for the University of Denver.

Image description

https://mediaspace.du.edu/media/D10%20Contribution%20Animation/1_x8yhqfz4

The module we are using that provides a UI within Drupal export config YML changes as a PR is appropriately named Config PR. I included screenshots of the steps required to enable GitHub's new Fine Grained Access Token in https://www.drupal.org/project/config_pr/issues/3509254.

In the presentation, I asked users to use Pantheon's new roadmap site to indicate that GitHub, GitLab, and Bitbucket integration is a feature they would use. A few days after my presentation, Pantheon announced that Native GitHub Integrations were available for public beta.

One "trick" I didn't highlight enough is the use of a hook_ENTITY_TYPE_presave to adjust role access based on the environment the user is authenticating on. This is much easier to do in an enterprise environment where we are leveraging a module like simpleSAMLphp_auth or samlauth is often configured to update values passed with the SAML post like first name, last name, email, etc.

By checking $_ENV['PANTHEON_ENVIRONMENT'] before determining which role to assign the user to, we can grant site builders full admin access on the dev, test and multidev environments. A simple example of this would be something like this function in your install profile.

function ducore_user_presave(UserInterface $user) {
  $site_builders =  array('first1.last1','first2.last3','first3.last3');
  // Check to see if this user is on the list of campus or system support users
  if (in_array(strtolower($user->getAccountName()), $site_builders)) {
    //check to see if the Pantheon environment is live
    if (isset($_ENV['PANTHEON_ENVIRONMENT']) && php_sapi_name() != 'cli') {
      if ($_ENV['PANTHEON_ENVIRONMENT'] != 'live') {
        $user->addRole('administrator');
      } else {
        $user->addRole('site_admin');
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

A more complicated example that handles developers, site builders and role limited to adding and removing users from sites is available for reference in the University of Denver's GitHub Repo.

Top comments (0)