Overview

Namespaces

  • Charcoal
    • Object
    • User
      • Acl

Classes

  • Charcoal\Object\Content
  • Charcoal\Object\ObjectRevision
  • Charcoal\Object\ObjectRoute
  • Charcoal\Object\ObjectSchedule
  • Charcoal\Object\UserData
  • Charcoal\User\AbstractUser
  • Charcoal\User\Acl\Manager
  • Charcoal\User\Acl\Permission
  • Charcoal\User\Acl\PermissionCategory
  • Charcoal\User\Acl\Role
  • Charcoal\User\Authenticator
  • Charcoal\User\Authorizer
  • Charcoal\User\AuthToken
  • Charcoal\User\AuthTokenMetadata
  • Charcoal\User\GenericUser

Interfaces

  • Charcoal\Object\ArchivableInterface
  • Charcoal\Object\CategorizableInterface
  • Charcoal\Object\CategorizableMultipleInterface
  • Charcoal\Object\CategoryInterface
  • Charcoal\Object\ContentInterface
  • Charcoal\Object\HierarchicalInterface
  • Charcoal\Object\ObjectRevisionInterface
  • Charcoal\Object\ObjectRouteInterface
  • Charcoal\Object\ObjectScheduleInterface
  • Charcoal\Object\PublishableInterface
  • Charcoal\Object\RevisionableInterface
  • Charcoal\Object\RoutableInterface
  • Charcoal\Object\UserDataInterface
  • Charcoal\User\UserInterface

Traits

  • Charcoal\Object\ArchivableTrait
  • Charcoal\Object\CategorizableMultipleTrait
  • Charcoal\Object\CategorizableTrait
  • Charcoal\Object\CategoryTrait
  • Charcoal\Object\HierarchicalTrait
  • Charcoal\Object\PublishableTrait
  • Charcoal\Object\RevisionableTrait
  • Charcoal\Object\RoutableTrait
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: namespace Charcoal\User\Acl;
 4: 
 5: use InvalidArgumentException;
 6: 
 7: // Module `charcoal-core` dependencies
 8: use Charcoal\Model\AbstractModel;
 9: 
10: // Module `charcoal-base` dependencies
11: use Charcoal\Object\CategorizableInterface;
12: use Charcoal\Object\CategorizableTrait;
13: 
14: // Module `charcoal-translation` dependencies
15: use Charcoal\Translation\TranslationString;
16: 
17: /**
18:  * A permission is a simple string, that can be read with additional data (name + category) from storage.
19:  */
20: class Permission extends AbstractModel implements CategorizableInterface
21: {
22:     use CategorizableTrait;
23: 
24:     /**
25:      * @var string $ident
26:      */
27:     private $ident;
28: 
29:     /**
30:      * @var TranslationString $name
31:      */
32:     private $name;
33: 
34:     /**
35:      * Permission can be used as a string (ident).
36:      *
37:      * @return string
38:      */
39:     public function __toString()
40:     {
41:         return (string)$this->ident;
42:     }
43: 
44:     /**
45:      * @param string $ident The permission identifier.
46:      * @throws InvalidArgumentException If the ident is not a string.
47:      * @return Permission Chainable
48:      */
49:     public function setIdent($ident)
50:     {
51:         if (!is_string($ident)) {
52:             throw new InvalidArgumentException(
53:                 'Permission ident needs to be a string'
54:             );
55:         }
56:         $this->ident = $ident;
57:         return $this;
58:     }
59: 
60:     /**
61:      * @return string
62:      */
63:     public function ident()
64:     {
65:         return $this->ident;
66:     }
67: 
68:     /**
69:      * @param mixed $name The permission name / label.
70:      * @return Permission Chainable
71:      */
72:     public function setName($name)
73:     {
74:         $this->name = new TranslationString($name);
75:         return $this;
76:     }
77: 
78:     /**
79:      * @return TranslationString
80:      */
81:     public function name()
82:     {
83:         return $this->name;
84:     }
85: }
86: 
API documentation generated by ApiGen