Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
groupmedia
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
groupmedia
Merge requests
!18
Issue
#3325966
: Call to a member function getPluginId() on string in Drupal\groupmedia\Controller\GroupMediaController->addPage() (line 46)
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3325966
: Call to a member function getPluginId() on string in Drupal\groupmedia\Controller\GroupMediaController->addPage() (line 46)
issue/groupmedia-3325966:3325966-groupmedia
into
3.0.x
Overview
0
Commits
3
Pipelines
0
Changes
6
Merged
Siva Karthik Reddy Papudippu
requested to merge
issue/groupmedia-3325966:3325966-groupmedia
into
3.0.x
2 years ago
Overview
0
Commits
3
Pipelines
0
Changes
6
Expand
0
0
Merge request reports
Compare
3.0.x
version 3
879b1bd5
2 years ago
version 2
417ccd53
2 years ago
version 1
b112e14f
2 years ago
3.0.x (base)
and
latest version
latest version
879b1bd5
3 commits,
2 years ago
version 3
879b1bd5
3 commits,
2 years ago
version 2
417ccd53
2 commits,
2 years ago
version 1
b112e14f
1 commit,
2 years ago
6 files
+
38
−
159
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
src/Controller/GroupMediaController.php deleted
100644 → 0
+
0
−
97
Options
<?php
namespace
Drupal\groupmedia\Controller
;
use
Drupal\group\Entity\Controller\GroupRelationshipController
;
use
Drupal\group\Entity\GroupInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Returns responses for 'group_media' GroupRelationship routes.
*/
class
GroupMediaController
extends
GroupRelationshipController
{
/**
* The group relationship type plugin manager.
*
* @var \Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface
*/
protected
$pluginManager
;
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
$instance
=
parent
::
create
(
$container
);
$instance
->
pluginManager
=
$container
->
get
(
'group_relation_type.manager'
);
return
$instance
;
}
/**
* {@inheritdoc}
*/
public
function
addPage
(
GroupInterface
$group
,
$create_mode
=
FALSE
,
$base_plugin_id
=
NULL
)
{
$build
=
parent
::
addPage
(
$group
,
$create_mode
);
// Do not interfere with redirects.
if
(
!
is_array
(
$build
))
{
return
$build
;
}
// Overwrite the label and description for all displayed bundles.
$media_type_storage
=
$this
->
entityTypeManager
->
getStorage
(
'media_type'
);
$group_type
=
$group
->
getGroupType
();
foreach
(
$this
->
addPageBundles
(
$group
,
$create_mode
,
$base_plugin_id
)
as
$bundle_id
=>
$bundle
)
{
if
(
!
empty
(
$build
[
'#bundles'
][
$bundle_id
]))
{
$plugin
=
$group_type
->
getPlugin
(
$bundle
->
getPluginId
());
$media_type
=
$plugin
->
getRelationType
()
->
getEntityBundle
();
$media_type_label
=
$media_type_storage
->
load
(
$media_type
)
->
label
();
$t_args
=
[
'%media_type'
=>
$media_type_label
];
$description
=
$create_mode
?
$this
->
t
(
'Create a media of type %media_type in the group.'
,
$t_args
)
:
$this
->
t
(
'Add an existing media of type %media_type to the group.'
,
$t_args
);
$build
[
'#bundles'
][
$bundle_id
][
'label'
]
=
$media_type_label
;
$build
[
'#bundles'
][
$bundle_id
][
'description'
]
=
$description
;
}
}
// Display the bundles in alpha order by label.
if
(
is_array
(
$build
[
'#bundles'
]))
{
uasort
(
$build
[
'#bundles'
],
function
(
$a
,
$b
)
{
return
strnatcmp
(
$a
[
'label'
],
$b
[
'label'
]);
});
}
return
$build
;
}
/**
* {@inheritdoc}
*/
protected
function
addPageBundles
(
GroupInterface
$group
,
$create_mode
,
$base_plugin_id
)
{
$bundles
=
[];
// Retrieve all group_media 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_media:'
)
!==
0
)
{
unset
(
$plugin_ids
[
$key
]);
}
}
// Retrieve all 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_relationship_type
)
{
/** @var \Drupal\group\Entity\GroupRelationshipTypeInterface $group_relationship_type */
$bundles
[
$group_relationship_type
->
getPluginId
()]
=
$bundle
;
}
return
$bundles
;
}
}
Loading