Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
access_unpublished
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
access_unpublished
Merge requests
!16
Extended
#3280964
to support Group 2.x.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Extended
#3280964
to support Group 2.x.
issue/access_unpublished-3405874:3405874-support-group-2.x
into
8.x-1.x
Overview
0
Commits
4
Pipelines
0
Changes
7
Open
Dalibor Matura
requested to merge
issue/access_unpublished-3405874:3405874-support-group-2.x
into
8.x-1.x
1 year ago
Overview
0
Commits
4
Pipelines
0
Changes
7
Expand
Closes
#3405874
0
0
Merge request reports
Compare
8.x-1.x
version 3
cbb42ec3
2 months ago
version 2
03b0b233
1 year ago
version 1
7aa40a4f
1 year ago
8.x-1.x (HEAD)
and
latest version
latest version
46385e5e
4 commits,
2 months ago
version 3
cbb42ec3
3 commits,
2 months ago
version 2
03b0b233
2 commits,
1 year ago
version 1
7aa40a4f
1 commit,
1 year ago
7 files
+
291
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
modules/access_unpublished_group/src/Access/AccessUnpublishedGroupPermissions.php
0 → 100644
+
86
−
0
Options
<?php
namespace
Drupal\access_unpublished_group\Access
;
use
Drupal\group\Plugin\Group\Relation\GroupRelationInterface
;
use
Drupal\Core\DependencyInjection\ContainerInjectionInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\Core\Routing\RouteMatchInterface
;
use
Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface
;
/**
* Provides dynamic permissions for groups of different types.
*/
class
AccessUnpublishedGroupPermissions
implements
ContainerInjectionInterface
{
/**
* The route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected
$routeMatch
;
/**
* The group content enabler plugin manager.
*
* @var \Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface
*/
protected
$groupRelationTypeManager
;
/**
* Constructs the AccessUnpublishedGroupPermissions object.
*/
public
function
__construct
(
RouteMatchInterface
$route_match
,
GroupRelationTypeManagerInterface
$group_relation_type_manager
)
{
$this
->
routeMatch
=
$route_match
;
$this
->
groupRelationTypeManager
=
$group_relation_type_manager
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'current_route_match'
),
$container
->
get
(
'group_relation_type.manager'
)
);
}
/**
* Returns an array of group permissions.
*
* @return array
* The group permissions.
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public
function
groupPermissions
()
{
$perms
=
[];
if
(
is_null
(
$this
->
groupRelationTypeManager
))
{
return
[];
}
if
(
$group_type
=
$this
->
routeMatch
->
getParameter
(
'group_type'
))
{
$plugins
=
$this
->
groupRelationTypeManager
->
getInstalled
(
$group_type
);
foreach
(
$plugins
as
$plugin
)
{
$perms
+=
$this
->
buildPermissions
(
$plugin
);
}
}
return
$perms
;
}
/**
* Returns list of group permissions for a given group content enabler plugin.
*
* @param \Drupal\group\Plugin\Group\Relation\GroupRelationInterface $plugin
* The group content enabler plugin.
*
* @return array
* An associative array of permission names and descriptions.
*/
protected
function
buildPermissions
(
GroupRelationInterface
$plugin
)
{
$permissions
=
[];
$permissions
[
'access_unpublished_group_'
.
$plugin
->
getPluginId
()]
=
[
'title'
=>
'Access unpublished '
.
$plugin
->
getPluginDefinition
()
->
get
(
'label'
)
??
''
,
];
return
$permissions
;
}
}
Loading