- Issue created by @shashank5563
- 🇧🇪Belgium msnassar
@shashank5563 the group_finder module is an api module. it doesn't provide a UI. The finder plugins are being called by GroupFinderContext and modules/custom code that are using it...
- 🇮🇳India shashank5563 New Delhi
<?php declare(strict_types = 1); namespace Drupal\mymodule\Plugin\GroupFinder; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\group\Entity\GroupInterface; use Drupal\group_finder\GroupFinderBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; /** * Plugin finds group from media library opener. * * @GroupFinder( * id = "group_content", * label = @Translation("Media library opener"), * description = @Translation("When in context of media library opener."), * weight = 40, * ) */ class GroupContent extends GroupFinderBase { /** * The group entity. * * @var \Drupal\group\Entity\GroupInterface */ protected $group; /** * The request stack. * * @var \Symfony\Component\HttpFoundation\RequestStack */ protected $requestStack; /** * GroupContent constructor. * * @param array $configuration * Plugin configuration. * @param string $plugin_id * Plugin id. * @param mixed $plugin_definition * Plugin definition. * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * The current route match. * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * The request stack used to retrieve the current request. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteMatchInterface $route_match, RequestStack $request_stack) { parent::__construct($configuration, $plugin_id, $plugin_definition, $route_match); $this->requestStack = $request_stack; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self { return new static( $configuration, $plugin_id, $plugin_definition, $container->get('current_route_match'), $container->get('request_stack'), ); } /** * {@inheritdoc} */ public function isApplicable(): bool { die('ddd'); return FALSE; } /** * {@inheritdoc} */ public function getGroup(): ?GroupInterface { return $this->group ?? NULL; } }
- 🇮🇳India shashank5563 New Delhi
I want to pass parent group id if group have parent. I want plugin with group content menu block like this screenshot.
- 🇧🇪Belgium msnassar
@shashank5563 The group finder context will return the first applied plugin. It depends on the weight of the plugins. The higher the weight, the later the founder is being called...
If changing the weight is not working for you, you could create your own context, then the context will be available in the "Select a group value". - Status changed to Fixed
over 1 year ago 10:29am 21 November 2023