From 8ff95dd3118303cc4ec30c736c11dc31b724b095 Mon Sep 17 00:00:00 2001 From: Pieter Frenssen Date: Mon, 22 Jul 2019 17:48:43 +0300 Subject: [PATCH] Adhere to coding standards. --- phpcs-ruleset.xml.dist | 7 +++- src/MembershipManager.php | 36 +++++++++---------- .../EntityReferenceSelection/OgSelection.php | 1 - src/Plugin/Field/FieldWidget/OgComplex.php | 1 - 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/phpcs-ruleset.xml.dist b/phpcs-ruleset.xml.dist index 6141b6305..0114a856e 100644 --- a/phpcs-ruleset.xml.dist +++ b/phpcs-ruleset.xml.dist @@ -13,5 +13,10 @@ *.min.css *.min.js - + + + + + + diff --git a/src/MembershipManager.php b/src/MembershipManager.php index dcc553adc..26391a067 100644 --- a/src/MembershipManager.php +++ b/src/MembershipManager.php @@ -63,8 +63,8 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, OgG * {@inheritdoc} */ public function getUserGroupIds($user_id, array $states = [OgMembershipInterface::STATE_ACTIVE]) { - if ($user_id instanceof AccountInterface) { - trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Pass the user ID instead.', E_USER_DEPRECATED); + if (!is_int($user_id)) { + trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED); $user_id = $user_id->id(); } $group_ids = []; @@ -82,8 +82,8 @@ public function getUserGroupIds($user_id, array $states = [OgMembershipInterface * {@inheritdoc} */ public function getUserGroups($user_id, array $states = [OgMembershipInterface::STATE_ACTIVE]) { - if ($user_id instanceof AccountInterface) { - trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Pass the user ID instead.', E_USER_DEPRECATED); + if (!is_int($user_id)) { + trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED); $user_id = $user_id->id(); } @@ -95,8 +95,8 @@ public function getUserGroups($user_id, array $states = [OgMembershipInterface:: * {@inheritdoc} */ public function getMemberships($user_id, array $states = [OgMembershipInterface::STATE_ACTIVE]) { - if ($user_id instanceof AccountInterface) { - trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Pass the user ID instead.', E_USER_DEPRECATED); + if (!is_int($user_id)) { + trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED); $user_id = $user_id->id(); } @@ -130,8 +130,8 @@ public function getMemberships($user_id, array $states = [OgMembershipInterface: * {@inheritdoc} */ public function getMembership(EntityInterface $group, $user_id, array $states = [OgMembershipInterface::STATE_ACTIVE]) { - if ($user_id instanceof AccountInterface) { - trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Pass the user ID instead.', E_USER_DEPRECATED); + if (!is_int($user_id)) { + trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED); $user_id = $user_id->id(); } @@ -149,8 +149,8 @@ public function getMembership(EntityInterface $group, $user_id, array $states = * {@inheritdoc} */ public function getUserGroupIdsByRoleIds($user_id, array $role_ids, array $states = [OgMembershipInterface::STATE_ACTIVE], bool $require_all_roles = TRUE): array { - if ($user_id instanceof AccountInterface) { - trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Pass the user ID instead.', E_USER_DEPRECATED); + if (!is_int($user_id)) { + trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED); $user_id = $user_id->id(); } @@ -172,8 +172,8 @@ public function getUserGroupIdsByRoleIds($user_id, array $role_ids, array $state * {@inheritdoc} */ public function getUserGroupsByRoleIds($user_id, array $role_ids, array $states = [OgMembershipInterface::STATE_ACTIVE], bool $require_all_roles = TRUE): array { - if ($user_id instanceof AccountInterface) { - trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Pass the user ID instead.', E_USER_DEPRECATED); + if (!is_int($user_id)) { + trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED); $user_id = $user_id->id(); } @@ -415,8 +415,8 @@ public function getGroupContentIds(EntityInterface $entity, array $entity_types * {@inheritdoc} */ public function isMember(EntityInterface $group, $user_id, array $states = [OgMembershipInterface::STATE_ACTIVE]) { - if ($user_id instanceof AccountInterface) { - trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Pass the user ID instead.', E_USER_DEPRECATED); + if (!is_int($user_id)) { + trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED); $user_id = $user_id->id(); } @@ -429,8 +429,8 @@ public function isMember(EntityInterface $group, $user_id, array $states = [OgMe * {@inheritdoc} */ public function isMemberPending(EntityInterface $group, $user_id) { - if ($user_id instanceof AccountInterface) { - trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Pass the user ID instead.', E_USER_DEPRECATED); + if (!is_int($user_id)) { + trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED); $user_id = $user_id->id(); } @@ -441,8 +441,8 @@ public function isMemberPending(EntityInterface $group, $user_id) { * {@inheritdoc} */ public function isMemberBlocked(EntityInterface $group, $user_id) { - if ($user_id instanceof AccountInterface) { - trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Pass the user ID instead.', E_USER_DEPRECATED); + if (!is_int($user_id)) { + trigger_error('Passing an account object is deprecated in og:8.1.0-alpha4 and is removed from og:8.1.0-beta1. Instead pass the user ID as an integer value. See https://github.com/Gizra/og/issues/542', E_USER_DEPRECATED); $user_id = $user_id->id(); } diff --git a/src/Plugin/EntityReferenceSelection/OgSelection.php b/src/Plugin/EntityReferenceSelection/OgSelection.php index 8a2159acd..8412d6a24 100644 --- a/src/Plugin/EntityReferenceSelection/OgSelection.php +++ b/src/Plugin/EntityReferenceSelection/OgSelection.php @@ -3,7 +3,6 @@ namespace Drupal\og\Plugin\EntityReferenceSelection; use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection; -use Drupal\user\Entity\User; use Drupal\og\Og; /** diff --git a/src/Plugin/Field/FieldWidget/OgComplex.php b/src/Plugin/Field/FieldWidget/OgComplex.php index d0f8b7656..4ef69d0d6 100644 --- a/src/Plugin/Field/FieldWidget/OgComplex.php +++ b/src/Plugin/Field/FieldWidget/OgComplex.php @@ -10,7 +10,6 @@ use Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget; use Drupal\Core\Form\FormStateInterface; use Drupal\og\OgAccess; -use Drupal\user\Entity\User; /** * Plugin implementation of the 'entity_reference autocomplete' widget.