Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • project/group
  • issue/group-3157478
  • issue/group-3084140
  • issue/group-3159277
  • issue/group-3163334
  • issue/group-3166252
  • issue/group-3167443
  • issue/group-3169377
  • issue/group-2797793
  • issue/group-2919982
  • issue/group-3177042
  • issue/group-3177542
  • issue/group-2801603
  • issue/group-3179857
  • issue/group-3052620
  • issue/group-2872645
  • issue/group-3007472
  • issue/group-3162259
  • issue/group-3183791
  • issue/group-3150877
  • issue/group-3185179
  • issue/group-3067811
  • issue/group-3189659
  • issue/group-3190190
  • issue/group-3190306
  • issue/group-2876696
  • issue/group-3118383
  • issue/group-3026735
  • issue/group-3194750
  • issue/group-3197122
  • issue/group-2746839
  • issue/group-3163683
  • issue/group-3201941
  • issue/group-3202091
  • issue/group-3202966
  • issue/group-3202249
  • issue/group-3045373
  • issue/group-3278740
  • issue/group-3209096
  • issue/group-3207064
  • issue/group-3214009
  • issue/group-3166107
  • issue/group-3214895
  • issue/group-2916907
  • issue/group-3220758
  • issue/group-3221785
  • issue/group-3222359
  • issue/group-3222747
  • issue/group-3223957
  • issue/group-2824018
  • issue/group-3226713
  • issue/group-3227793
  • issue/group-3228454
  • issue/group-3229567
  • issue/group-3232851
  • issue/group-3137312
  • issue/group-2295249
  • issue/group-3236626
  • issue/group-3281530
  • issue/group-3202908
  • issue/group-3278778
  • issue/group-3245095
  • issue/group-2972933
  • issue/group-3074933
  • issue/group-3162511
  • issue/group-3253368
  • issue/group-2767155
  • issue/group-2877493
  • issue/group-3254038
  • issue/group-3257227
  • issue/group-3257756
  • issue/group-2717981
  • issue/group-3259178
  • issue/group-3256998
  • issue/group-3204083
  • issue/group-3082125
  • issue/group-3265962
  • issue/group-3266146
  • issue/group-3262923
  • issue/group-3276613
  • issue/group-3005047
  • issue/group-3284402
  • issue/group-3071489
  • issue/group-3061881
  • issue/group-3305051
  • issue/group-2842630
  • issue/group-3301785
  • issue/group-3310499
  • issue/group-3311119
  • issue/group-3307282
  • issue/group-3307291
  • issue/group-2933819
  • issue/group-3310605
  • issue/group-2774729
  • issue/group-3311949
  • issue/group-3313220
  • issue/group-3317459
  • issue/group-3313515
  • issue/group-3315779
  • issue/group-2817109
  • issue/group-3319274
  • issue/group-3325789
  • issue/group-3320513
  • issue/group-3328660
  • issue/group-3210808
  • issue/group-3317396
  • issue/group-3325994
  • issue/group-3322623
  • issue/group-3331923
  • issue/group-3332963
  • issue/group-3112501
  • issue/group-3324506
  • issue/group-3344283
  • issue/group-3180860
  • issue/group-3104345
  • issue/group-3332640
  • issue/group-3354135
  • issue/group-3322761
  • issue/group-3367755
  • issue/group-3406043
  • issue/group-3398778
  • issue/group-3399601
  • issue/group-3406373
  • issue/group-3371637
  • issue/group-3371641
  • issue/group-3371651
  • issue/group-3374041
  • issue/group-3378653
  • issue/group-3364226
  • issue/group-3378977
  • issue/group-3399569
  • issue/group-3336186
  • issue/group-3382559
  • issue/group-3382831
  • issue/group-3016197
  • issue/group-2878723
  • issue/group-3390016
  • issue/group-3268711
  • issue/group-3394724
  • issue/group-3379174
  • issue/group-3397015
  • issue/group-3397021
  • issue/group-3397114
  • issue/group-3399085
  • issue/group-3406840
  • issue/group-3336280
  • issue/group-3409735
  • issue/group-3411381
  • issue/group-3413722
  • issue/group-3414592
  • issue/group-3415695
  • issue/group-3416324
  • issue/group-3421138
  • issue/group-3422253
  • issue/group-3422445
  • issue/group-3423341
  • issue/group-2895988
  • issue/group-3420605
  • issue/group-3424972
  • issue/group-3132084
  • issue/group-3101314
  • issue/group-3425601
  • issue/group-3426007
  • issue/group-3426098
  • issue/group-3426239
  • issue/group-3426408
  • issue/group-3427343
  • issue/group-3397063
  • issue/group-3427547
  • issue/group-3427552
  • issue/group-3428392
  • issue/group-3419405
  • issue/group-3441929
  • issue/group-2774827
  • issue/group-3414708
  • issue/group-2815971
  • issue/group-3441076
  • issue/group-3438400
  • issue/group-3440222
  • issue/group-3409374
  • issue/group-3430826
  • issue/group-3446192
  • issue/group-3137221
  • issue/group-3448221
  • issue/group-3449620
  • issue/group-3449640
  • issue/group-3346626
  • issue/group-3451560
  • issue/group-3437029
  • issue/group-3457095
  • issue/group-3462425
  • issue/group-2929788
  • issue/group-3352235
  • issue/group-3455789
  • issue/group-3467754
  • issue/group-3469835
  • issue/group-3470663
  • issue/group-3036272
  • issue/group-3469890
  • issue/group-3475807
  • issue/group-2907838
  • issue/group-3476539
  • issue/group-3478088
  • issue/group-3475816
  • issue/group-3399452
  • issue/group-3480110
  • issue/group-2754399
  • issue/group-3278936
  • issue/group-3482975
  • issue/group-3421756
  • issue/group-3485785
  • issue/group-3482418
  • issue/group-3490229
  • issue/group-3490670
  • issue/group-3489243
  • issue/group-3493593
  • issue/group-3493597
  • issue/group-3493741
  • issue/group-3493807
  • issue/group-3494447
  • issue/group-3494780
  • issue/group-3494986
  • issue/group-3497467
  • issue/group-3499639
  • issue/group-3494298
  • issue/group-3501018
  • issue/group-3502994
  • issue/group-3504133
  • issue/group-3504805
  • issue/group-3505771
  • issue/group-3506061
  • issue/group-3506097
  • issue/group-3506163
  • issue/group-3507425
  • issue/group-3508876
  • issue/group-3509416
  • issue/group-3509657
  • issue/group-3511625
  • issue/group-3512941
  • issue/group-3511454
  • issue/group-3484817
241 results
Show changes
Showing
with 128 additions and 92 deletions
...@@ -4,6 +4,7 @@ namespace Drupal\group\Entity\Access; ...@@ -4,6 +4,7 @@ namespace Drupal\group\Entity\Access;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Entity\EntityAccessControlHandler; use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityHandlerInterface; use Drupal\Core\Entity\EntityHandlerInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
...@@ -117,6 +118,7 @@ class GroupAccessControlHandler extends EntityAccessControlHandler implements En ...@@ -117,6 +118,7 @@ class GroupAccessControlHandler extends EntityAccessControlHandler implements En
$access = $access->andIf($this->access($entity, $entity_operation, $account, TRUE)); $access = $access->andIf($this->access($entity, $entity_operation, $account, TRUE));
} }
assert($access instanceof RefinableCacheableDependencyInterface);
return $access->addCacheableDependency($cacheability); return $access->addCacheableDependency($cacheability);
} }
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
namespace Drupal\group\Entity\Access; namespace Drupal\group\Entity\Access;
use Drupal\content_moderation\ModerationInformationInterface;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\Access\AccessInterface; use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\content_moderation\ModerationInformationInterface;
use Drupal\group\Access\GroupAccessResult; use Drupal\group\Access\GroupAccessResult;
use Drupal\group\Entity\GroupInterface; use Drupal\group\Entity\GroupInterface;
use Symfony\Component\Routing\Route; use Symfony\Component\Routing\Route;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
namespace Drupal\group\Entity\Access; namespace Drupal\group\Entity\Access;
use Drupal\Core\Entity\EntityHandlerInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityAccessControlHandler; use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityHandlerInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\group\Entity\GroupRelationshipInterface; use Drupal\group\Entity\GroupRelationshipInterface;
use Drupal\group\Entity\GroupRelationshipTypeInterface; use Drupal\group\Entity\GroupRelationshipTypeInterface;
...@@ -55,7 +55,7 @@ class GroupRelationshipAccessControlHandler extends EntityAccessControlHandler i ...@@ -55,7 +55,7 @@ class GroupRelationshipAccessControlHandler extends EntityAccessControlHandler i
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) { protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
$relationship_type = $this->entityTypeManager->getStorage('group_content_type')->load($entity_bundle); $relationship_type = $this->entityTypeManager->getStorage('group_relationship_type')->load($entity_bundle);
assert($relationship_type instanceof GroupRelationshipTypeInterface); assert($relationship_type instanceof GroupRelationshipTypeInterface);
$access_control = $this->groupRelationTypeManager->getAccessControlHandler($relationship_type->getPluginId()); $access_control = $this->groupRelationTypeManager->getAccessControlHandler($relationship_type->getPluginId());
return $access_control->relationshipCreateAccess($context['group'], $account, TRUE); return $access_control->relationshipCreateAccess($context['group'], $account, TRUE);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\group\Entity\Access; namespace Drupal\group\Entity\Access;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Entity\EntityAccessControlHandler; use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
...@@ -19,10 +20,14 @@ class GroupRelationshipTypeAccessControlHandler extends EntityAccessControlHandl ...@@ -19,10 +20,14 @@ class GroupRelationshipTypeAccessControlHandler extends EntityAccessControlHandl
*/ */
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
assert($entity instanceof GroupRelationshipTypeInterface); assert($entity instanceof GroupRelationshipTypeInterface);
$access = parent::checkAccess($entity, $operation, $account);
assert($access instanceof RefinableCacheableDependencyInterface);
if ($operation == 'delete') { if ($operation == 'delete') {
return parent::checkAccess($entity, $operation, $account)->addCacheableDependency($entity); return $access->addCacheableDependency($entity);
} }
return parent::checkAccess($entity, $operation, $account);
return $access;
} }
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\group\Entity\Access; namespace Drupal\group\Entity\Access;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Entity\EntityAccessControlHandler; use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
...@@ -20,9 +21,6 @@ class GroupRoleAccessControlHandler extends EntityAccessControlHandler { ...@@ -20,9 +21,6 @@ class GroupRoleAccessControlHandler extends EntityAccessControlHandler {
*/ */
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
assert($entity instanceof GroupRoleInterface); assert($entity instanceof GroupRoleInterface);
if ($operation == 'delete') {
return parent::checkAccess($entity, $operation, $account)->addCacheableDependency($entity);
}
// Group roles have no 'view' route but may be used in views to show what // Group roles have no 'view' route but may be used in views to show what
// roles a member has. We therefore allow 'view' access so field formatters // roles a member has. We therefore allow 'view' access so field formatters
...@@ -31,7 +29,14 @@ class GroupRoleAccessControlHandler extends EntityAccessControlHandler { ...@@ -31,7 +29,14 @@ class GroupRoleAccessControlHandler extends EntityAccessControlHandler {
return AccessResult::allowed()->addCacheableDependency($entity); return AccessResult::allowed()->addCacheableDependency($entity);
} }
return parent::checkAccess($entity, $operation, $account); $access = parent::checkAccess($entity, $operation, $account);
assert($access instanceof RefinableCacheableDependencyInterface);
if ($operation == 'delete') {
return $access->addCacheableDependency($entity);
}
return $access;
} }
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\group\Entity\Access; namespace Drupal\group\Entity\Access;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Entity\EntityAccessControlHandler; use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
...@@ -20,9 +21,6 @@ class GroupTypeAccessControlHandler extends EntityAccessControlHandler { ...@@ -20,9 +21,6 @@ class GroupTypeAccessControlHandler extends EntityAccessControlHandler {
*/ */
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
assert($entity instanceof GroupTypeInterface); assert($entity instanceof GroupTypeInterface);
if ($operation == 'delete') {
return parent::checkAccess($entity, $operation, $account)->addCacheableDependency($entity);
}
// Group types have no 'view' route but may be used in views to show what // Group types have no 'view' route but may be used in views to show what
// type a group is. We therefore allow 'view' access so field formatters // type a group is. We therefore allow 'view' access so field formatters
...@@ -31,7 +29,14 @@ class GroupTypeAccessControlHandler extends EntityAccessControlHandler { ...@@ -31,7 +29,14 @@ class GroupTypeAccessControlHandler extends EntityAccessControlHandler {
return AccessResult::allowed()->addCacheableDependency($entity); return AccessResult::allowed()->addCacheableDependency($entity);
} }
return parent::checkAccess($entity, $operation, $account); $access = parent::checkAccess($entity, $operation, $account);
assert($access instanceof RefinableCacheableDependencyInterface);
if ($operation == 'delete') {
return $access->addCacheableDependency($entity);
}
return $access;
} }
} }
...@@ -80,15 +80,15 @@ abstract class QueryAccessHandlerBase implements EntityHandlerInterface, QueryAc ...@@ -80,15 +80,15 @@ abstract class QueryAccessHandlerBase implements EntityHandlerInterface, QueryAc
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getConditions($operation, AccountInterface $account = NULL) { public function getConditions($operation, ?AccountInterface $account = NULL) {
$account = $account ?: $this->currentUser; $account = $account ?: $this->currentUser;
$entity_type_id = $this->entityType->id(); $entity_type_id = $this->entityType->id();
$conditions = $this->buildConditions($operation, $account); $conditions = $this->buildConditions($operation, $account);
// Allow other modules to modify the conditions before they are used. // Allow other modules to modify the conditions before they are used.
$event = new QueryAccessEvent($conditions, $operation, $account, $entity_type_id); $event = new QueryAccessEvent($conditions, $operation, $account, $entity_type_id);
$this->eventDispatcher->dispatch("entity.query_access", $event); $this->eventDispatcher->dispatch($event, "entity.query_access");
$this->eventDispatcher->dispatch("entity.query_access.{$entity_type_id}", $event); $this->eventDispatcher->dispatch($event, "entity.query_access.{$entity_type_id}");
return $conditions; return $conditions;
} }
......
...@@ -69,6 +69,7 @@ class ConfigWrapper extends ContentEntityBase implements ConfigWrapperInterface ...@@ -69,6 +69,7 @@ class ConfigWrapper extends ContentEntityBase implements ConfigWrapperInterface
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) { public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
assert($base_field_definitions['entity_id'] instanceof BaseFieldDefinition);
$fields['entity_id'] = clone $base_field_definitions['entity_id']; $fields['entity_id'] = clone $base_field_definitions['entity_id'];
$fields['entity_id']->setSetting('target_type', $bundle); $fields['entity_id']->setSetting('target_type', $bundle);
return $fields; return $fields;
......
...@@ -6,8 +6,8 @@ use Drupal\Core\Controller\ControllerBase; ...@@ -6,8 +6,8 @@ use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityFormBuilderInterface; use Drupal\Core\Entity\EntityFormBuilderInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Render\RendererInterface; use Drupal\Core\Render\RendererInterface;
use Drupal\group\Entity\GroupTypeInterface;
use Drupal\Core\TempStore\PrivateTempStoreFactory; use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Drupal\group\Entity\GroupTypeInterface;
use Drupal\group\Entity\Storage\GroupRelationshipTypeStorageInterface; use Drupal\group\Entity\Storage\GroupRelationshipTypeStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -113,15 +113,16 @@ class GroupController extends ControllerBase { ...@@ -113,15 +113,16 @@ class GroupController extends ControllerBase {
} }
// Wizard step 2: Group membership form. // Wizard step 2: Group membership form.
else { else {
$relationship_type_storage = $this->entityTypeManager()->getStorage('group_content_type'); $relationship_type_storage = $this->entityTypeManager()->getStorage('group_relationship_type');
assert($relationship_type_storage instanceof GroupRelationshipTypeStorageInterface); assert($relationship_type_storage instanceof GroupRelationshipTypeStorageInterface);
// Create an empty group membership that does not yet have a group set. // Create an empty group membership that does not yet have a group set.
$values = [ $values = [
'type' => $relationship_type_storage->getRelationshipTypeId($group_type->id(), 'group_membership'), 'type' => $relationship_type_storage->getRelationshipTypeId($group_type->id(), 'group_membership'),
'entity_id' => $this->currentUser()->id(), 'entity_id' => $this->currentUser()->id(),
'group_roles' => $group_type->getCreatorRoleIds(),
]; ];
$entity = $this->entityTypeManager()->getStorage('group_content')->create($values); $entity = $this->entityTypeManager()->getStorage('group_relationship')->create($values);
} }
// Return the entity form with the configuration gathered above. // Return the entity form with the configuration gathered above.
......
...@@ -104,12 +104,12 @@ class GroupListBuilder extends EntityListBuilder { ...@@ -104,12 +104,12 @@ class GroupListBuilder extends EntityListBuilder {
], ],
'type' => [ 'type' => [
'data' => $this->t('Type'), 'data' => $this->t('Type'),
'specifier' =>'type', 'specifier' => 'type',
'field' => 'type', 'field' => 'type',
], ],
'status' => [ 'status' => [
'data' => $this->t('Status'), 'data' => $this->t('Status'),
'specifier' =>'status', 'specifier' => 'status',
'field' => 'status', 'field' => 'status',
], ],
'uid' => [ 'uid' => [
...@@ -158,7 +158,7 @@ class GroupListBuilder extends EntityListBuilder { ...@@ -158,7 +158,7 @@ class GroupListBuilder extends EntityListBuilder {
$query->pager($this->limit); $query->pager($this->limit);
} }
return $query->execute(); return $query->accessCheck()->execute();
} }
/** /**
......
...@@ -9,9 +9,9 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; ...@@ -9,9 +9,9 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Link; use Drupal\Core\Link;
use Drupal\Core\Render\RendererInterface; use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\group\Entity\GroupInterface; use Drupal\group\Entity\GroupInterface;
use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Drupal\group\Entity\Storage\GroupRelationshipTypeStorageInterface; use Drupal\group\Entity\Storage\GroupRelationshipTypeStorageInterface;
use Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface; use Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -121,12 +121,16 @@ class GroupRelationshipController extends ControllerBase { ...@@ -121,12 +121,16 @@ class GroupRelationshipController extends ControllerBase {
} }
// Filter out the bundles the user doesn't have access to. // Filter out the bundles the user doesn't have access to.
$access_control_handler = $this->entityTypeManager->getAccessControlHandler('group_content');
foreach ($relationship_types as $relationship_type_id => $relationship_type) { foreach ($relationship_types as $relationship_type_id => $relationship_type) {
$access = $access_control_handler->createAccess($relationship_type_id, NULL, ['group' => $group], TRUE); $access_control_handler = $this->groupRelationTypeManager->getAccessControlHandler($relationship_type->getPluginId());
$access = $create_mode
? $access_control_handler->entityCreateAccess($group, $this->currentUser(), TRUE)
: $access_control_handler->relationshipCreateAccess($group, $this->currentUser(), TRUE);
if (!$access->isAllowed()) { if (!$access->isAllowed()) {
unset($relationship_types[$relationship_type_id]); unset($relationship_types[$relationship_type_id]);
} }
$this->renderer->addCacheableDependency($build, $access); $this->renderer->addCacheableDependency($build, $access);
} }
...@@ -156,7 +160,7 @@ class GroupRelationshipController extends ControllerBase { ...@@ -156,7 +160,7 @@ class GroupRelationshipController extends ControllerBase {
} }
// Add the list cache tags for the GroupRelationshipType entity type. // Add the list cache tags for the GroupRelationshipType entity type.
$bundle_entity_type = $this->entityTypeManager->getDefinition('group_content_type'); $bundle_entity_type = $this->entityTypeManager->getDefinition('group_relationship_type');
$build['#cache']['tags'] = $bundle_entity_type->getListCacheTags(); $build['#cache']['tags'] = $bundle_entity_type->getListCacheTags();
return $build; return $build;
...@@ -180,7 +184,7 @@ class GroupRelationshipController extends ControllerBase { ...@@ -180,7 +184,7 @@ class GroupRelationshipController extends ControllerBase {
* @see ::addPage() * @see ::addPage()
*/ */
protected function addPageBundles(GroupInterface $group, $create_mode, $base_plugin_id) { protected function addPageBundles(GroupInterface $group, $create_mode, $base_plugin_id) {
$storage = $this->entityTypeManager->getStorage('group_content_type'); $storage = $this->entityTypeManager->getStorage('group_relationship_type');
assert($storage instanceof GroupRelationshipTypeStorageInterface); assert($storage instanceof GroupRelationshipTypeStorageInterface);
$relationship_types = $storage->loadByGroupType($group->getGroupType()); $relationship_types = $storage->loadByGroupType($group->getGroupType());
...@@ -188,7 +192,7 @@ class GroupRelationshipController extends ControllerBase { ...@@ -188,7 +192,7 @@ class GroupRelationshipController extends ControllerBase {
$relation = $relationship_type->getPlugin(); $relation = $relationship_type->getPlugin();
// Check the base plugin ID if a plugin filter was specified. // Check the base plugin ID if a plugin filter was specified.
if ($base_plugin_id && $relation->getBaseId() === $base_plugin_id) { if ($base_plugin_id && $relation->getBaseId() !== $base_plugin_id) {
unset($relationship_types[$relationship_type_id]); unset($relationship_types[$relationship_type_id]);
} }
// Skip the bundle if we are listing bundles that allow you to create an // Skip the bundle if we are listing bundles that allow you to create an
...@@ -237,8 +241,8 @@ class GroupRelationshipController extends ControllerBase { ...@@ -237,8 +241,8 @@ class GroupRelationshipController extends ControllerBase {
*/ */
protected function addPageFormRoute(GroupInterface $group, $create_mode) { protected function addPageFormRoute(GroupInterface $group, $create_mode) {
return $create_mode return $create_mode
? 'entity.group_content.create_form' ? 'entity.group_relationship.create_form'
: 'entity.group_content.add_form'; : 'entity.group_relationship.add_form';
} }
/** /**
...@@ -253,20 +257,20 @@ class GroupRelationshipController extends ControllerBase { ...@@ -253,20 +257,20 @@ class GroupRelationshipController extends ControllerBase {
* A group submission form. * A group submission form.
*/ */
public function addForm(GroupInterface $group, $plugin_id) { public function addForm(GroupInterface $group, $plugin_id) {
$storage = $this->entityTypeManager()->getStorage('group_content_type'); $storage = $this->entityTypeManager()->getStorage('group_relationship_type');
assert($storage instanceof GroupRelationshipTypeStorageInterface); assert($storage instanceof GroupRelationshipTypeStorageInterface);
$values = [ $values = [
'type' => $storage->getRelationshipTypeId($group->bundle(), $plugin_id), 'type' => $storage->getRelationshipTypeId($group->bundle(), $plugin_id),
'gid' => $group->id(), 'gid' => $group->id(),
]; ];
$group_relationship = $this->entityTypeManager()->getStorage('group_content')->create($values); $group_relationship = $this->entityTypeManager()->getStorage('group_relationship')->create($values);
return $this->entityFormBuilder->getForm($group_relationship, 'add'); return $this->entityFormBuilder->getForm($group_relationship, 'add');
} }
/** /**
* The _title_callback for the entity.group_content.add_form route. * The _title_callback for the entity.group_relationship.add_form route.
* *
* @param \Drupal\group\Entity\GroupInterface $group * @param \Drupal\group\Entity\GroupInterface $group
* The group to add the relationship to. * The group to add the relationship to.
...@@ -281,7 +285,7 @@ class GroupRelationshipController extends ControllerBase { ...@@ -281,7 +285,7 @@ class GroupRelationshipController extends ControllerBase {
} }
/** /**
* The _title_callback for the entity.group_content.edit_form route. * The _title_callback for the entity.group_relationship.edit_form route.
* *
* Overrides the Drupal\Core\Entity\Controller\EntityController::editTitle(). * Overrides the Drupal\Core\Entity\Controller\EntityController::editTitle().
* *
...@@ -293,14 +297,15 @@ class GroupRelationshipController extends ControllerBase { ...@@ -293,14 +297,15 @@ class GroupRelationshipController extends ControllerBase {
* @return string|null * @return string|null
* The title for the entity edit page, if an entity was found. * The title for the entity edit page, if an entity was found.
*/ */
public function editFormTitle(RouteMatchInterface $route_match, EntityInterface $_entity = NULL) { public function editFormTitle(RouteMatchInterface $route_match, ?EntityInterface $_entity = NULL) {
if ($entity = $route_match->getParameter('group_content')) { if ($entity = $route_match->getParameter('group_relationship')) {
return $this->t('Edit %label', ['%label' => $entity->label()]); return $this->t('Edit %label', ['%label' => $entity->label()]);
} }
return NULL;
} }
/** /**
* The _title_callback for the entity.group_content.collection route. * The _title_callback for the entity.group_relationship.collection route.
* *
* @param \Drupal\group\Entity\GroupInterface $group * @param \Drupal\group\Entity\GroupInterface $group
* The group to add the relationship to. * The group to add the relationship to.
...@@ -369,7 +374,7 @@ class GroupRelationshipController extends ControllerBase { ...@@ -369,7 +374,7 @@ class GroupRelationshipController extends ControllerBase {
} }
// Wizard step 2: Group relationship form. // Wizard step 2: Group relationship form.
else { else {
$relationship_type_storage = $this->entityTypeManager()->getStorage('group_content_type'); $relationship_type_storage = $this->entityTypeManager()->getStorage('group_relationship_type');
assert($relationship_type_storage instanceof GroupRelationshipTypeStorageInterface); assert($relationship_type_storage instanceof GroupRelationshipTypeStorageInterface);
// Create an empty relationship entity. // Create an empty relationship entity.
...@@ -377,7 +382,7 @@ class GroupRelationshipController extends ControllerBase { ...@@ -377,7 +382,7 @@ class GroupRelationshipController extends ControllerBase {
'type' => $relationship_type_storage->getRelationshipTypeId($group->bundle(), $plugin_id), 'type' => $relationship_type_storage->getRelationshipTypeId($group->bundle(), $plugin_id),
'gid' => $group->id(), 'gid' => $group->id(),
]; ];
$entity = $this->entityTypeManager()->getStorage('group_content')->create($values); $entity = $this->entityTypeManager()->getStorage('group_relationship')->create($values);
// Group relationship entities have an add form handler. // Group relationship entities have an add form handler.
$operation = 'add'; $operation = 'add';
...@@ -388,7 +393,7 @@ class GroupRelationshipController extends ControllerBase { ...@@ -388,7 +393,7 @@ class GroupRelationshipController extends ControllerBase {
} }
/** /**
* The _title_callback for the entity.group_content.create_form route. * The _title_callback for the entity.group_relationship.create_form route.
* *
* @param \Drupal\group\Entity\GroupInterface $group * @param \Drupal\group\Entity\GroupInterface $group
* The group to create the relationship for. * The group to create the relationship for.
......
...@@ -28,7 +28,7 @@ class GroupRelationshipListBuilder extends EntityListBuilder { ...@@ -28,7 +28,7 @@ class GroupRelationshipListBuilder extends EntityListBuilder {
/** /**
* The entity type manager. * The entity type manager.
* *
* @var \Drupal\Core\Routing\RedirectDestinationInterface * @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/ */
protected $entityTypeManager; protected $entityTypeManager;
...@@ -86,7 +86,7 @@ class GroupRelationshipListBuilder extends EntityListBuilder { ...@@ -86,7 +86,7 @@ class GroupRelationshipListBuilder extends EntityListBuilder {
$query->pager($this->limit); $query->pager($this->limit);
} }
return $query->execute(); return $query->accessCheck()->execute();
} }
/** /**
......
...@@ -9,12 +9,12 @@ use Drupal\Core\Routing\RouteMatchInterface; ...@@ -9,12 +9,12 @@ use Drupal\Core\Routing\RouteMatchInterface;
/** /**
* Returns responses for GroupRole routes. * Returns responses for GroupRole routes.
*/ */
class GroupRoleController extends EntityController { class GroupRoleController extends EntityController {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function doGetEntity(RouteMatchInterface $route_match, EntityInterface $_entity = NULL) { protected function doGetEntity(RouteMatchInterface $route_match, ?EntityInterface $_entity = NULL) {
if ($_entity) { if ($_entity) {
$entity = $_entity; $entity = $_entity;
} }
...@@ -28,6 +28,7 @@ class GroupRoleController extends EntityController { ...@@ -28,6 +28,7 @@ class GroupRoleController extends EntityController {
if (isset($entity)) { if (isset($entity)) {
return $this->entityRepository->getTranslationFromContext($entity); return $this->entityRepository->getTranslationFromContext($entity);
} }
return NULL;
} }
} }
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
namespace Drupal\group\Entity\Controller; namespace Drupal\group\Entity\Controller;
use Drupal\group\Entity\GroupRoleInterface;
use Drupal\group\Entity\GroupTypeInterface;
use Drupal\Core\Url;
use Drupal\Core\Config\Entity\DraggableListBuilder; use Drupal\Core\Config\Entity\DraggableListBuilder;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\group\Entity\GroupRoleInterface;
use Drupal\group\Entity\GroupTypeInterface;
use Drupal\group\PermissionScopeInterface; use Drupal\group\PermissionScopeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -23,7 +23,7 @@ class GroupRoleListBuilder extends DraggableListBuilder { ...@@ -23,7 +23,7 @@ class GroupRoleListBuilder extends DraggableListBuilder {
/** /**
* The group type to check for roles. * The group type to check for roles.
* *
* @var GroupTypeInterface $groupType * @var \Drupal\group\Entity\GroupTypeInterface
*/ */
protected $groupType; protected $groupType;
...@@ -70,7 +70,7 @@ class GroupRoleListBuilder extends DraggableListBuilder { ...@@ -70,7 +70,7 @@ class GroupRoleListBuilder extends DraggableListBuilder {
$query->pager($this->limit); $query->pager($this->limit);
} }
return array_values($query->execute()); return array_values($query->accessCheck()->execute());
} }
/** /**
...@@ -144,7 +144,7 @@ class GroupRoleListBuilder extends DraggableListBuilder { ...@@ -144,7 +144,7 @@ class GroupRoleListBuilder extends DraggableListBuilder {
$build += parent::render(); $build += parent::render();
$build['table']['#empty'] = $this->t('No group roles available. <a href="@link">Add group role</a>.', [ $build['table']['#empty'] = $this->t('No group roles available. <a href="@link">Add group role</a>.', [
'@link' => Url::fromRoute('entity.group_role.add_form', ['group_type' => $this->groupType->id()])->toString() '@link' => Url::fromRoute('entity.group_role.add_form', ['group_type' => $this->groupType->id()])->toString(),
]); ]);
return $build; return $build;
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
namespace Drupal\group\Entity\Controller; namespace Drupal\group\Entity\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\group\Entity\GroupTypeInterface; use Drupal\group\Entity\GroupTypeInterface;
use Drupal\group\Plugin\Group\Relation\GroupRelationTypeInterface; use Drupal\group\Plugin\Group\Relation\GroupRelationTypeInterface;
use Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface; use Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
...@@ -30,9 +31,9 @@ class GroupTypeController extends ControllerBase { ...@@ -30,9 +31,9 @@ class GroupTypeController extends ControllerBase {
protected $pluginManager; protected $pluginManager;
/** /**
* The module manager. * The module extension list.
* *
* @var \Drupal\Core\Extension\ModuleHandlerInterface * @var \Drupal\Core\Extension\ModuleExtensionList
*/ */
protected $moduleHandler; protected $moduleHandler;
...@@ -46,14 +47,18 @@ class GroupTypeController extends ControllerBase { ...@@ -46,14 +47,18 @@ class GroupTypeController extends ControllerBase {
/** /**
* Constructs a new GroupTypeController. * Constructs a new GroupTypeController.
* *
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * @param \Drupal\Core\Extension\ModuleExtensionList|\Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler. * The module extension list.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager. * The entity type manager.
* @param \Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface $plugin_manager * @param \Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface $plugin_manager
* The group relation type manager. * The group relation type manager.
*/ */
public function __construct(ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager, GroupRelationTypeManagerInterface $plugin_manager) { public function __construct(ModuleHandlerInterface|ModuleExtensionList $module_handler, EntityTypeManagerInterface $entity_type_manager, GroupRelationTypeManagerInterface $plugin_manager) {
if ($module_handler instanceof ModuleHandlerInterface) {
@trigger_error('Calling ' . __METHOD__ . '() with a $module_handler argument as \Drupal\Core\Extension\ModuleHandlerInterface instead of \Drupal\Core\Extension\ModuleExtensionList is deprecated in group:3.3.0 and will be required in group:4.0.0. See https://www.drupal.org/node/3431243', E_USER_DEPRECATED);
$module_handler = \Drupal::service('extension.list.module');
}
$this->moduleHandler = $module_handler; $this->moduleHandler = $module_handler;
$this->entityTypeManager = $entity_type_manager; $this->entityTypeManager = $entity_type_manager;
$this->pluginManager = $plugin_manager; $this->pluginManager = $plugin_manager;
...@@ -64,7 +69,7 @@ class GroupTypeController extends ControllerBase { ...@@ -64,7 +69,7 @@ class GroupTypeController extends ControllerBase {
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('module_handler'), $container->get('extension.list.module'),
$container->get('entity_type.manager'), $container->get('entity_type.manager'),
$container->get('group_relation_type.manager') $container->get('group_relation_type.manager')
); );
...@@ -97,7 +102,7 @@ class GroupTypeController extends ControllerBase { ...@@ -97,7 +102,7 @@ class GroupTypeController extends ControllerBase {
'#title' => $this->t('Information about content plugins'), '#title' => $this->t('Information about content plugins'),
]; ];
$page['information']['intro']['#markup'] = $this->t('<p>In order to be able to add entities as content to groups of this group type, a so-called content plugin needs to be installed. This plugin informs the Group module on how the entity type can be added to a group, what rules apply and whether it should control access over said entity type. When a plugin is installed, you should check out its configuration form to see what options are available to further customize the plugin behavior.</p>'); $page['information']['intro']['#markup'] = $this->t('<p>In order to be able to relate entities to groups of this group type, a so-called relation plugin needs to be installed. This plugin informs the Group module on how the entity type can be added to a group, what rules apply and whether it should control access over said entity type. When a plugin is installed, you should check out its configuration form to see what options are available to further customize the plugin behavior.</p>');
$page['information']['fields']['#markup'] = $this->t('<p>Should you choose to show the relationship entities that track which entity belongs to which group or should the module that provided the module enforce this, you can control which fields are available on that relation entity and how they are presented in the front-end.</p>'); $page['information']['fields']['#markup'] = $this->t('<p>Should you choose to show the relationship entities that track which entity belongs to which group or should the module that provided the module enforce this, you can control which fields are available on that relation entity and how they are presented in the front-end.</p>');
$page['information']['install_types'] = [ $page['information']['install_types'] = [
'#theme' => 'item_list', '#theme' => 'item_list',
...@@ -164,10 +169,10 @@ class GroupTypeController extends ControllerBase { ...@@ -164,10 +169,10 @@ class GroupTypeController extends ControllerBase {
], ],
], ],
'provider' => [ 'provider' => [
'#markup' => $this->moduleHandler->getName($group_relation_type->getProvider()) '#markup' => $this->moduleHandler->getName($group_relation_type->getProvider()),
], ],
'entity_type_id' => [ 'entity_type_id' => [
'#markup' => $this->entityTypeManager->getDefinition($group_relation_type->getEntityTypeId())->getLabel() '#markup' => $this->entityTypeManager->getDefinition($group_relation_type->getEntityTypeId())->getLabel(),
], ],
'status' => ['#markup' => $status], 'status' => ['#markup' => $status],
'install_type' => ['#markup' => $install_type], 'install_type' => ['#markup' => $install_type],
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
namespace Drupal\group\Entity\Controller; namespace Drupal\group\Entity\Controller;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder; use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Url;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
use Drupal\group\Entity\GroupTypeInterface; use Drupal\group\Entity\GroupTypeInterface;
/** /**
...@@ -83,7 +83,7 @@ class GroupTypeListBuilder extends ConfigEntityListBuilder { ...@@ -83,7 +83,7 @@ class GroupTypeListBuilder extends ConfigEntityListBuilder {
public function render() { public function render() {
$build = parent::render(); $build = parent::render();
$build['table']['#empty'] = $this->t('No group types available. <a href="@link">Add group type</a>.', [ $build['table']['#empty'] = $this->t('No group types available. <a href="@link">Add group type</a>.', [
'@link' => Url::fromRoute('entity.group_type.add_form')->toString() '@link' => Url::fromRoute('entity.group_type.add_form')->toString(),
]); ]);
return $build; return $build;
} }
......
...@@ -4,7 +4,6 @@ namespace Drupal\group\Entity\Form; ...@@ -4,7 +4,6 @@ namespace Drupal\group\Entity\Form;
use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\group\Entity\GroupInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
...@@ -14,6 +13,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -14,6 +13,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/ */
class GroupForm extends ContentEntityForm { class GroupForm extends ContentEntityForm {
/**
* The entity being used by this form.
*
* @var \Drupal\group\Entity\GroupInterface
*/
protected $entity;
/** /**
* The private store factory. * The private store factory.
* *
...@@ -36,9 +42,7 @@ class GroupForm extends ContentEntityForm { ...@@ -36,9 +42,7 @@ class GroupForm extends ContentEntityForm {
protected function actions(array $form, FormStateInterface $form_state) { protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state); $actions = parent::actions($form, $form_state);
$group = $this->getEntity(); $group_type = $this->entity->getGroupType();
assert($group instanceof GroupInterface);
$group_type = $group->getGroupType();
$replace = ['@group_type' => $group_type->label()]; $replace = ['@group_type' => $group_type->label()];
// We need to adjust the actions when using the group creator wizard. // We need to adjust the actions when using the group creator wizard.
...@@ -49,12 +53,12 @@ class GroupForm extends ContentEntityForm { ...@@ -49,12 +53,12 @@ class GroupForm extends ContentEntityForm {
// until the end of the wizard to save. // until the end of the wizard to save.
$actions['submit']['#submit'] = ['::submitForm', '::store']; $actions['submit']['#submit'] = ['::submitForm', '::store'];
// Update the label to be more user friendly by indicating that the user // Update the label to be more user-friendly by indicating that the user
// needs to go through an extra step to finish the group creation. // needs to go through an extra step to finish the group creation.
$actions['submit']['#value'] = $this->t('Create @group_type and complete your membership', $replace); $actions['submit']['#value'] = $this->t('Create @group_type and complete your membership', $replace);
// Add a cancel button to clear the private temp store. This exits the // Add a cancel button to clear the private temp store. This exits the
// wizard without saving, // wizard without saving.
$actions['cancel'] = [ $actions['cancel'] = [
'#type' => 'submit', '#type' => 'submit',
'#value' => $this->t('Cancel'), '#value' => $this->t('Cancel'),
......
...@@ -34,15 +34,16 @@ class GroupRelationshipDeleteForm extends ContentEntityConfirmFormBase { ...@@ -34,15 +34,16 @@ class GroupRelationshipDeleteForm extends ContentEntityConfirmFormBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
// phpcs:ignore
public function getCancelURL() { public function getCancelURL() {
$group_relationship = $this->getEntity(); $group_relationship = $this->getEntity();
assert($group_relationship instanceof GroupRelationshipInterface); assert($group_relationship instanceof GroupRelationshipInterface);
$group = $group_relationship->getGroup(); $group = $group_relationship->getGroup();
$route_params = [ $route_params = [
'group' => $group->id(), 'group' => $group->id(),
'group_content' => $group_relationship->id(), 'group_relationship' => $group_relationship->id(),
]; ];
return new Url('entity.group_content.canonical', $route_params); return new Url('entity.group_relationship.canonical', $route_params);
} }
/** /**
...@@ -61,7 +62,7 @@ class GroupRelationshipDeleteForm extends ContentEntityConfirmFormBase { ...@@ -61,7 +62,7 @@ class GroupRelationshipDeleteForm extends ContentEntityConfirmFormBase {
$group = $group_relationship->getGroup(); $group = $group_relationship->getGroup();
$group_relationship->delete(); $group_relationship->delete();
\Drupal::logger('group_content')->notice('@type: deleted %title.', [ \Drupal::logger('group_relationship')->notice('@type: deleted %title.', [
'@type' => $group_relationship->bundle(), '@type' => $group_relationship->bundle(),
'%title' => $group_relationship->label(), '%title' => $group_relationship->label(),
]); ]);
......
...@@ -4,7 +4,6 @@ namespace Drupal\group\Entity\Form; ...@@ -4,7 +4,6 @@ namespace Drupal\group\Entity\Form;
use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\group\Entity\GroupRelationshipInterface;
use Drupal\group\Entity\Storage\ConfigWrapperStorageInterface; use Drupal\group\Entity\Storage\ConfigWrapperStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -15,6 +14,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -15,6 +14,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/ */
class GroupRelationshipForm extends ContentEntityForm { class GroupRelationshipForm extends ContentEntityForm {
/**
* The entity being used by this form.
*
* @var \Drupal\group\Entity\GroupRelationshipInterface
*/
protected $entity;
/** /**
* The private store factory. * The private store factory.
* *
...@@ -38,9 +44,7 @@ class GroupRelationshipForm extends ContentEntityForm { ...@@ -38,9 +44,7 @@ class GroupRelationshipForm extends ContentEntityForm {
* The responsible group relation. * The responsible group relation.
*/ */
protected function getPlugin() { protected function getPlugin() {
$group_relationship = $this->getEntity(); return $this->entity->getPlugin();
assert($group_relationship instanceof GroupRelationshipInterface);
return $group_relationship->getPlugin();
} }
/** /**
...@@ -88,7 +92,7 @@ class GroupRelationshipForm extends ContentEntityForm { ...@@ -88,7 +92,7 @@ class GroupRelationshipForm extends ContentEntityForm {
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id); $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
$replace = [ $replace = [
'@entity_type' => $entity_type->getSingularLabel(), '@entity_type' => $entity_type->getSingularLabel(),
'@group' => $this->getEntity()->getGroup()->label(), '@group' => $this->entity->getGroup()->label(),
]; ];
$actions['submit']['#value'] = $this->t('Add new @entity_type to @group', $replace); $actions['submit']['#value'] = $this->t('Add new @entity_type to @group', $replace);
} }
...@@ -108,21 +112,18 @@ class GroupRelationshipForm extends ContentEntityForm { ...@@ -108,21 +112,18 @@ class GroupRelationshipForm extends ContentEntityForm {
public function save(array $form, FormStateInterface $form_state) { public function save(array $form, FormStateInterface $form_state) {
$return = parent::save($form, $form_state); $return = parent::save($form, $form_state);
$group_relationship = $this->getEntity();
assert($group_relationship instanceof GroupRelationshipInterface);
// The below redirect ensures the user will be redirected to something they // The below redirect ensures the user will be redirected to something they
// can view in the following order: The relationship, the target entity // can view in the following order: The relationship, the target entity
// itself, the group and finally the front page. This only applies if there // itself, the group and finally the front page. This only applies if there
// was no destination GET parameter set in the URL. // was no destination GET parameter set in the URL.
if ($group_relationship->access('view')) { if ($this->entity->access('view')) {
$form_state->setRedirectUrl($group_relationship->toUrl()); $form_state->setRedirectUrl($this->entity->toUrl());
} }
elseif ($group_relationship->getEntity()->access('view')) { elseif ($this->entity->getEntity()->access('view')) {
$form_state->setRedirectUrl($group_relationship->getEntity()->toUrl()); $form_state->setRedirectUrl($this->entity->getEntity()->toUrl());
} }
elseif ($group_relationship->getGroup()->access('view')) { elseif ($this->entity->getGroup()->access('view')) {
$form_state->setRedirectUrl($group_relationship->getGroup()->toUrl()); $form_state->setRedirectUrl($this->entity->getGroup()->toUrl());
} }
else { else {
$form_state->setRedirect('<front>'); $form_state->setRedirect('<front>');
......
...@@ -61,7 +61,7 @@ class GroupRelationshipTypeDeleteForm extends EntityDeleteForm { ...@@ -61,7 +61,7 @@ class GroupRelationshipTypeDeleteForm extends EntityDeleteForm {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, FormStateInterface $form_state) { public function buildForm(array $form, FormStateInterface $form_state) {
$entity_count = $this->entityTypeManager->getStorage('group_content') $entity_count = $this->entityTypeManager->getStorage('group_relationship')
->getQuery() ->getQuery()
->accessCheck(FALSE) ->accessCheck(FALSE)
->condition('type', $this->entity->id()) ->condition('type', $this->entity->id())
...@@ -71,7 +71,7 @@ class GroupRelationshipTypeDeleteForm extends EntityDeleteForm { ...@@ -71,7 +71,7 @@ class GroupRelationshipTypeDeleteForm extends EntityDeleteForm {
if (!empty($entity_count)) { if (!empty($entity_count)) {
$form['#title'] = $this->getQuestion(); $form['#title'] = $this->getQuestion();
$form['description'] = [ $form['description'] = [
'#markup' => '<p>' . $this->t('You can not uninstall this content plugin until you have removed all of the content that uses it.') . '</p>' '#markup' => '<p>' . $this->t('You can not uninstall this content plugin until you have removed all of the content that uses it.') . '</p>',
]; ];
return $form; return $form;
...@@ -90,7 +90,7 @@ class GroupRelationshipTypeDeleteForm extends EntityDeleteForm { ...@@ -90,7 +90,7 @@ class GroupRelationshipTypeDeleteForm extends EntityDeleteForm {
$group_relation_type = $relationship_type->getPlugin()->getRelationType(); $group_relation_type = $relationship_type->getPlugin()->getRelationType();
$relationship_type->delete(); $relationship_type->delete();
\Drupal::logger('group_content_type')->notice('Uninstalled %plugin from %group_type.', [ \Drupal::logger('group_relationship_type')->notice('Uninstalled %plugin from %group_type.', [
'%plugin' => $group_relation_type->getLabel(), '%plugin' => $group_relation_type->getLabel(),
'%group_type' => $group_type->label(), '%group_type' => $group_type->label(),
]); ]);
......