cforge-2.0.x-dev/modules/cforge_docs/cforge_docs.install

modules/cforge_docs/cforge_docs.install
<?php

/**
 * @file
 * Installation hooks.
 */

use \Drupal\user\Entity\Role;
use \Drupal\taxonomy\Entity\Term;

/**
 * Implements hook_install().
 */
function cforge_docs_install() {
  $terms = [
    (string) t('Our organisation') => t('Documents associated with this group'),
    (string) t('Media coverage') => t('Press, media and internet exposure.'),
    (string) t('Publicity materials') => t('Leaflets, posters etc.'),
    (string) t('Minutes') => t('Create your meeting agenda, and after the meeting edit the agenda so it can be viewed as minutes'),
    (string) t('Misc') => t('Anything else'),
  ];

  $w = 0;
  foreach ($terms as $name => $description) {
    $properties = [
      'name' => $name,
      'description' => $description,
      'vid' => 'binders',
      'format' => 'plain_text',
      'weight' => $w++,
    ];
    Term::create($properties)->save();
  }

  Role::load('committee')
    ->grantPermission('create document content')
    ->grantPermission('delete any document content')
    ->grantPermission('edit any document content')
    ->grantPermission('edit terms in binders')
    ->save();
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc