Commit 49d14834 authored by mxh's avatar mxh
Browse files

Issue #3269048 by mxh: Group integration

parent a5160ad8
Loading
Loading
Loading
Loading
+991 −0

File added.

Preview size limit exceeded, changes collapsed.

+3 −0
Original line number Diff line number Diff line
access group_field_bundle overview:
  title: 'Access group field bundle overview'
  description: 'Access the overview of all group field bundles, regardless of their bundle configuration'
+8 −0
Original line number Diff line number Diff line
name: 'Group Field bundle'
description: 'Enables Group functionality for Field bundles'
package: 'Group'
type: 'module'
core_version_requirement: ^9 || ^10
dependencies:
  - 'field_bundle:field_bundle'
  - 'group:group'
+11 −0
Original line number Diff line number Diff line
group_content.group_field_bundle_relate_page:
  route_name: 'entity.group_content.group_field_bundle_relate_page'
  title: 'Add existing field bundle'
  appears_on:
    - 'view.group_field_bundles.page_1'

group_content.group_field_bundle_add_page:
  route_name: 'entity.group_content.group_field_bundle_add_page'
  title: 'Add new field bundle'
  appears_on:
    - 'view.group_field_bundles.page_1'
+40 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Enables Group functionality for the Field bundles.
 */

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function group_field_bundle_field_bundle_config_insert() {
  \Drupal::service('plugin.manager.group_content_enabler')->clearCachedDefinitions();
}

/**
 * Implements hook_entity_operation().
 */
function group_field_bundle_entity_operation(EntityInterface $entity) {
  $operations = [];

  if ($entity->getEntityTypeId() == 'group' && \Drupal::moduleHandler()->moduleExists('views')) {
    /** @var \Drupal\group\Entity\GroupInterface $entity */
    if ($entity->hasPermission('access group_field_bundle overview', \Drupal::currentUser())) {
      /** @var \Symfony\Component\Routing\RouterInterface $router */
      $router = \Drupal::service('router.no_access_checks');
      if ($router->getRouteCollection()->get('view.group_field_bundle.page_1') !== NULL) {
        $operations['field_bundles'] = [
          'title' => t('Field bundles'),
          'weight' => 40,
          'url' => Url::fromRoute('view.group_field_bundle.page_1', ['group' => $entity->id()]),
        ];
      }
    }
  }

  return $operations;
}
Loading