Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
group_term
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
group_term
Merge requests
!8
Issue
#3345399
: Implement hook_help()
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3345399
: Implement hook_help()
issue/group_term-3345399:feature-hook_help
into
4.0.x
Overview
0
Commits
9
Pipelines
0
Changes
9
Open
Dinesh Reddy Bhumi Reddy
requested to merge
issue/group_term-3345399:feature-hook_help
into
4.0.x
2 years ago
Overview
0
Commits
9
Pipelines
0
Changes
9
Expand
0
0
Merge request reports
Compare
4.0.x
version 1
0d2e56d3
2 years ago
4.0.x (base)
and
latest version
latest version
77e959b6
9 commits,
2 years ago
version 1
0d2e56d3
4 commits,
2 years ago
9 files
+
495
−
8
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
9
Search (e.g. *.vue) (Ctrl+P)
src/Controller/GroupTermController.php
0 → 100644
+
117
−
0
Options
<?php
namespace
Drupal\group_term\Controller
;
use
Drupal\Core\Entity\EntityFormBuilderInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Render\RendererInterface
;
use
Drupal\group\Entity\Controller\GroupContentController
;
use
Drupal\group\Entity\GroupInterface
;
use
Drupal\group\Plugin\GroupContentEnablerManagerInterface
;
use
Drupal\Core\TempStore\PrivateTempStoreFactory
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Returns responses for 'group_term' GroupContent routes.
*/
class
GroupTermController
extends
GroupContentController
{
/**
* The group content plugin manager.
*
* @var \Drupal\group\Plugin\GroupContentEnablerManagerInterface
*/
protected
$pluginManager
;
/**
* Constructs a new GroupNodeController.
*
* @param \Drupal\group\Plugin\GroupContentEnablerManagerInterface $plugin_manager
* The group content plugin manager.
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
* The private store factory.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Entity\EntityFormBuilderInterface $entity_form_builder
* The entity form builder.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer.
*/
public
function
__construct
(
GroupContentEnablerManagerInterface
$plugin_manager
,
PrivateTempStoreFactory
$temp_store_factory
,
EntityTypeManagerInterface
$entity_type_manager
,
EntityFormBuilderInterface
$entity_form_builder
,
RendererInterface
$renderer
)
{
parent
::
__construct
(
$temp_store_factory
,
$entity_type_manager
,
$entity_form_builder
,
$renderer
);
$this
->
pluginManager
=
$plugin_manager
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'plugin.manager.group_content_enabler'
),
$container
->
get
(
'tempstore.private'
),
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'entity.form_builder'
),
$container
->
get
(
'renderer'
)
);
}
/**
* {@inheritdoc}
*/
public
function
addPage
(
GroupInterface
$group
,
$create_mode
=
FALSE
)
{
$build
=
parent
::
addPage
(
$group
,
$create_mode
);
// Do not interfere with redirects.
if
(
!
is_array
(
$build
))
{
return
$build
;
}
// Overwrite the label and description for all of the displayed bundles.
$storage_handler
=
$this
->
entityTypeManager
->
getStorage
(
'taxonomy_vocabulary'
);
foreach
(
$this
->
addPageBundles
(
$group
,
$create_mode
)
as
$plugin_id
=>
$bundle_name
)
{
if
(
!
empty
(
$build
[
'#bundles'
][
$bundle_name
]))
{
$plugin
=
$group
->
getGroupType
()
->
getContentPlugin
(
$plugin_id
);
$bundle_label
=
$storage_handler
->
load
(
$plugin
->
getEntityBundle
())
->
label
();
$t_args
=
[
'%vocabulary'
=>
$bundle_label
];
$description
=
$create_mode
?
$this
->
t
(
'Add a new term of type %vocabulary to the group.'
,
$t_args
)
:
$this
->
t
(
'Add an existing term of type %vocabulary to the group.'
,
$t_args
);
$build
[
'#bundles'
][
$bundle_name
][
'label'
]
=
$bundle_label
;
$build
[
'#bundles'
][
$bundle_name
][
'description'
]
=
$description
;
}
}
return
$build
;
}
/**
* {@inheritdoc}
*/
protected
function
addPageBundles
(
GroupInterface
$group
,
$create_mode
)
{
$bundles
=
[];
// Retrieve all group_node plugins for the group's type.
$plugin_ids
=
$this
->
pluginManager
->
getInstalledIds
(
$group
->
getGroupType
());
foreach
(
$plugin_ids
as
$key
=>
$plugin_id
)
{
if
(
strpos
(
$plugin_id
,
'group_term:'
)
!==
0
)
{
unset
(
$plugin_ids
[
$key
]);
}
}
// Retrieve all of the responsible group content types, keyed by plugin ID.
$storage
=
$this
->
entityTypeManager
->
getStorage
(
'group_content_type'
);
$properties
=
[
'group_type'
=>
$group
->
bundle
(),
'content_plugin'
=>
$plugin_ids
,
];
foreach
(
$storage
->
loadByProperties
(
$properties
)
as
$bundle
=>
$group_content_type
)
{
/** @var \Drupal\group\Entity\GroupContentTypeInterface $group_content_type */
$bundles
[
$group_content_type
->
getContentPluginId
()]
=
$bundle
;
}
return
$bundles
;
}
}
Loading