Important

You are browsing the documentation for version 4.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Configurable Permissions

Users can manage the visibility of role permissions on View and Edit Role pages.

Model

ConfigurablePermission is model that contains all data of the Configurable Permission. It has 3 public methods to check if a permission or a capability is configurable for this ConfigurablePermission:

  • isEntityPermissionConfigurable($entityClass, $permission) - checks that permission $permission is configurable for entity class $entityClass;

  • isWorkflowPermissionConfigurable($identity, $permission) - checks that permission $permission is configurable for workflow part with identity $identity;

  • isCapabilityConfigurable($capability) - checks that capability is configurable.

Configuration

All Configurable Permissions are described in configuration file configurable_permissions.yml corresponded bundle.

It has 4 main options:

  • default (bool, by default = false) - all permissions for the Configurable Name configurable by default;

  • entities (array|bool) - the list of entity classes with permissions. If a value is boolean, it will be applied to all permissions for this entity class;

  • capabilities (array) - the list of capabilities;

  • workflows (array|bool) - the list of workflow permissions identities with permissions. If a value is boolean, it will be applied to all permissions for this identity.

An example of a simple configurable permission configuration.

 1 oro_configurable_permissions:
 2     some_name:                                                      # configurable permission name, will be used by filter
 3         default: true                                               # is all permissions for this `some_name` configurable by default
 4         entities:
 5             Oro\Bundle\CalendarBundle\Entity\Calendar:              # entity class
 6                 CREATE: false                                       # hide permission `CREATE` for entity Calendar
 7                 EDIT: true                                          # show permission `EDIT` for entity Calendar
 8         capabilities:
 9             oro_acme_some_capability: false                         # hide capability `oro_acme_some_capability` for `some_name`
10         workflows:
11             workflow1:
12                 PERFORM_TRANSIT: false                              # hide permission `PERFORM_TRANSIT` for workflow `workflow1`

Configuration Merging

All configurations merge in the boot bundles order. The application collects configurations of all configurable permissions with the same name and merges them into one configuration.

Merging uses simple rules:

  • if the node value is scalar, the value will be replaced

  • if the node value is array, this array will be complemented by the values from the second configuration

After this step, the application knows about all permissions and has only one configuration for each permission.