src/Entity/PermissionsAwareTrait.php
public function getPermissions()
    {
        if (!$this->permissions) {
            $type = property_exists($this, 'permissionsType')
                ? $this->permissionsType
                : str_replace('\\Entity\\', '/', static::class);
            $permissions = new Permissions($type);

            if (method_exists($this, 'setupPermissions')) {
                $this->setupPermissions($permissions);
            }

            $this->setPermissions($permissions);
        }

        return $this->permissions;
    }
public function getPermissions()
    {
        if (!$this->permissions) {
            $type = property_exists($this, 'permissionsType')
                ? $this->permissionsType
                : str_replace('\\Entity\\', '/', static::class);
            $permissions = new Permissions($type);

            if (method_exists($this, 'setupPermissions')) {
                $this->setupPermissions($permissions);
            }

            $this->setPermissions($permissions);
        }

        return $this->permissions;
    }
Gets the permissions entity.

@internal
If no permissions entity is set, it creates a
{@link Permissions} instance and set its type to
either the value provided with the property 'permissionsType' or
to the entity class name, where '\\Entity\\' is replaced with '/',
which leads to types such as MODULE/NAME.

Calls a method named 'setupPermissions' and passing the newly
created permissions instance if such a method exists in the using class.

@return PermissionsInterface