Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / modules / paragraphs_type_permissions / src / ParagraphsTypePermissions.php
1 <?php
2
3 namespace Drupal\paragraphs_type_permissions;
4
5 use Drupal\Core\Routing\UrlGeneratorTrait;
6 use Drupal\Core\StringTranslation\StringTranslationTrait;
7 use Drupal\paragraphs\Entity\ParagraphsType;
8
9 /**
10  * Defines a class containing permission callbacks.
11  */
12 class ParagraphsTypePermissions {
13
14   use StringTranslationTrait;
15   use UrlGeneratorTrait;
16
17   /**
18    * Returns an array of content permissions.
19    *
20    * @return array
21    */
22   public function globalPermissions() {
23     return array(
24       'bypass paragraphs type content access' => array(
25         'title' => $this->t('Bypass Paragraphs type content access control'),
26         'description' => $this->t('Is able to administer content for all Paragraph types'),
27       ),
28     );
29   }
30
31   /**
32    * Returns an array of Paragraphs type permissions.
33    *
34    * @return array
35    */
36   public function paragraphTypePermissions() {
37     $perms = array();
38
39     // Generate paragraph permissions for all Paragraphs types.
40     foreach (ParagraphsType::loadMultiple() as $type) {
41       $perms += $this->buildPermissions($type);
42     }
43
44     return $perms;
45   }
46
47   /**
48    * Builds a standard list of node permissions for a given type.
49    *
50    * @param \Drupal\paragraphs\Entity\ParagraphsType $type
51    *   The machine name of the node type.
52    *
53    * @return array
54    *   An array of permission names and descriptions.
55    */
56   protected function buildPermissions(ParagraphsType $type) {
57     $type_id = $type->id();
58     $type_params = array('%type_name' => $type->label());
59
60     return array(
61       'view paragraph content ' .$type_id => array(
62         'title' => $this->t('%type_name: View content', $type_params),
63         'description' => $this->t('Is able to view Paragraphs content of type %type_name', $type_params),
64       ),
65       'create paragraph content ' . $type_id => array(
66         'title' => $this->t('%type_name: Create content', $type_params),
67         'description' => $this->t('Is able to create Paragraphs content of type %type_name', $type_params),
68       ),
69       'update paragraph content ' . $type_id => array(
70         'title' => $this->t('%type_name: Edit content', $type_params),
71         'description' => $this->t('Is able to update Paragraphs content of type %type_name', $type_params),
72       ),
73       'delete paragraph content ' . $type_id => array(
74         'title' => $this->t('%type_name: Delete content', $type_params),
75         'description' => $this->t('Is able to delete Paragraphs content of type %type_name', $type_params),
76       ),
77     );
78   }
79
80 }