diff --git a/modules/custom/social_magic_login/src/Controller/MagicLoginController.php b/modules/custom/social_magic_login/src/Controller/MagicLoginController.php index 66a44b4fb11..56781569894 100644 --- a/modules/custom/social_magic_login/src/Controller/MagicLoginController.php +++ b/modules/custom/social_magic_login/src/Controller/MagicLoginController.php @@ -5,7 +5,6 @@ use Drupal\Component\Utility\Crypt; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Link; use Drupal\Core\Url; diff --git a/modules/social_features/social_content_block/src/ContentTranslationDefaultsConfigOverride.php b/modules/social_features/social_content_block/src/ContentTranslationDefaultsConfigOverride.php index 37a6c3f5c15..1dabd4fb30a 100644 --- a/modules/social_features/social_content_block/src/ContentTranslationDefaultsConfigOverride.php +++ b/modules/social_features/social_content_block/src/ContentTranslationDefaultsConfigOverride.php @@ -5,7 +5,6 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; /** diff --git a/modules/social_features/social_core/src/ContentTranslationDefaultsConfigOverride.php b/modules/social_features/social_core/src/ContentTranslationDefaultsConfigOverride.php index c6a9649252c..e321d6c4126 100644 --- a/modules/social_features/social_core/src/ContentTranslationDefaultsConfigOverride.php +++ b/modules/social_features/social_core/src/ContentTranslationDefaultsConfigOverride.php @@ -5,7 +5,6 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; /** diff --git a/modules/social_features/social_event/modules/social_event_managers/src/EventSubscriber/RouteSubscriber.php b/modules/social_features/social_event/modules/social_event_managers/src/EventSubscriber/RouteSubscriber.php index c75ae686b9d..fc6652cf06e 100644 --- a/modules/social_features/social_event/modules/social_event_managers/src/EventSubscriber/RouteSubscriber.php +++ b/modules/social_features/social_event/modules/social_event_managers/src/EventSubscriber/RouteSubscriber.php @@ -2,7 +2,6 @@ namespace Drupal\social_event_managers\EventSubscriber; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\Route; diff --git a/modules/social_features/social_featured_content/src/ContentTranslationDefaultsConfigOverride.php b/modules/social_features/social_featured_content/src/ContentTranslationDefaultsConfigOverride.php index b3381765c98..0d560babafd 100644 --- a/modules/social_features/social_featured_content/src/ContentTranslationDefaultsConfigOverride.php +++ b/modules/social_features/social_featured_content/src/ContentTranslationDefaultsConfigOverride.php @@ -5,7 +5,6 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; /** diff --git a/modules/social_features/social_featured_items/src/ContentTranslationDefaultsConfigOverride.php b/modules/social_features/social_featured_items/src/ContentTranslationDefaultsConfigOverride.php index 7bba918b563..914f866a312 100644 --- a/modules/social_features/social_featured_items/src/ContentTranslationDefaultsConfigOverride.php +++ b/modules/social_features/social_featured_items/src/ContentTranslationDefaultsConfigOverride.php @@ -5,7 +5,6 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; /** diff --git a/modules/social_features/social_follow_taxonomy/modules/social_follow_landing_page/src/ContentTranslationDefaultsConfigOverride.php b/modules/social_features/social_follow_taxonomy/modules/social_follow_landing_page/src/ContentTranslationDefaultsConfigOverride.php index 487e050403f..ee418d173ac 100644 --- a/modules/social_features/social_follow_taxonomy/modules/social_follow_landing_page/src/ContentTranslationDefaultsConfigOverride.php +++ b/modules/social_features/social_follow_taxonomy/modules/social_follow_landing_page/src/ContentTranslationDefaultsConfigOverride.php @@ -5,7 +5,6 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; /** diff --git a/modules/social_features/social_group/src/CurrentGroupService.php b/modules/social_features/social_group/src/CurrentGroupService.php index c97d7538a25..45110570478 100644 --- a/modules/social_features/social_group/src/CurrentGroupService.php +++ b/modules/social_features/social_group/src/CurrentGroupService.php @@ -6,20 +6,52 @@ use Drupal\Core\Plugin\Context\ContextProviderInterface; use Drupal\group\Entity\GroupInterface; +/** + * Centralized ways to get the current group. + * + * @package Drupal\social_group. + */ class CurrentGroupService { + /** + * The entity type manager. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ private EntityTypeManagerInterface $entityTypeManager; - private ContextProviderInterface $groupRouteContext; + /** + * The group route context. + * + * @var \Drupal\Core\Plugin\Context\ContextProviderInterface + */ + private ContextProviderInterface $groupRouteContext; + /** + * Constructor. + * + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. + * @param \Drupal\Core\Plugin\Context\ContextProviderInterface $group_route_context + * The group route context. + */ public function __construct( - EntityTypeManagerInterface $entity_type_manager, - ContextProviderInterface $group_route_context, - ) { + EntityTypeManagerInterface $entity_type_manager, + ContextProviderInterface $group_route_context, + ) { $this->entityTypeManager = $entity_type_manager; $this->groupRouteContext = $group_route_context; } + /** + * Get group from runtime contexts. + * + * @return \Drupal\group\Entity\GroupInterface|null + * The current group or NULL. + * + * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException + * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException + */ public function fromRunTimeContexts(): ?GroupInterface { $runtime_context = $this->groupRouteContext->getRuntimeContexts([]); if (isset($runtime_context['group']) === FALSE) { @@ -32,11 +64,13 @@ public function fromRunTimeContexts(): ?GroupInterface { } if (is_int($group) === TRUE) { - /** @var GroupInterface $loadedGroup */ - $loadedGroup = $this->entityTypeManager->getStorage('group')->load($group); + /** @var \Drupal\group\Entity\GroupInterface $loadedGroup */ + $loadedGroup = $this->entityTypeManager + ->getStorage('group')->load($group); return $loadedGroup; } return NULL; } + } diff --git a/modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php b/modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php index 0b81a6b23b6..c6a0f7c68cc 100755 --- a/modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php +++ b/modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\FieldableEntityInterface; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; diff --git a/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoBlock.php b/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoBlock.php index 8fa39f9a56f..304fb475cf7 100644 --- a/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoBlock.php +++ b/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoBlock.php @@ -5,7 +5,9 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBuilderInterface; +use Drupal\Core\Routing\CurrentRouteMatch; use Drupal\Core\Session\AccountProxyInterface; +use Drupal\social_group\CurrentGroupService; use Drupal\social_post\Plugin\Block\PostBlock; /** @@ -23,12 +25,14 @@ class PostPhotoBlock extends PostBlock { */ public function __construct( array $configuration, - $plugin_id, - $plugin_definition, + $plugin_id, + $plugin_definition, EntityTypeManagerInterface $entity_type_manager, AccountProxyInterface $current_user, FormBuilderInterface $form_builder, - ModuleHandlerInterface $module_handler + ModuleHandlerInterface $module_handler, + CurrentRouteMatch $route_match, + CurrentGroupService $current_group_service, ) { parent::__construct( $configuration, @@ -37,7 +41,9 @@ public function __construct( $entity_type_manager, $current_user, $form_builder, - $module_handler + $module_handler, + $route_match, + $current_group_service, ); // Override the bundle type. diff --git a/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoGroupBlock.php b/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoGroupBlock.php index 2c3402897a4..d6b7e02bc94 100644 --- a/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoGroupBlock.php +++ b/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoGroupBlock.php @@ -5,7 +5,6 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBuilderInterface; -use Drupal\Core\Plugin\Context\ContextProviderInterface; use Drupal\Core\Routing\CurrentRouteMatch; use Drupal\Core\Session\AccountProxyInterface; use Drupal\social_group\CurrentGroupService; @@ -32,8 +31,8 @@ public function __construct( AccountProxyInterface $current_user, FormBuilderInterface $form_builder, ModuleHandlerInterface $module_handler, - CurrentGroupService $current_group_service, CurrentRouteMatch $route_match, + CurrentGroupService $current_group_service, ) { parent::__construct( $configuration, diff --git a/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoProfileBlock.php b/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoProfileBlock.php index 67796d80042..2b65bf6b483 100644 --- a/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoProfileBlock.php +++ b/modules/social_features/social_post/modules/social_post_photo/src/Plugin/Block/PostPhotoProfileBlock.php @@ -5,7 +5,9 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBuilderInterface; +use Drupal\Core\Routing\CurrentRouteMatch; use Drupal\Core\Session\AccountProxyInterface; +use Drupal\social_group\CurrentGroupService; use Drupal\social_post\Plugin\Block\PostProfileBlock; /** @@ -23,13 +25,14 @@ class PostPhotoProfileBlock extends PostProfileBlock { */ public function __construct( array $configuration, - $plugin_id, - $plugin_definition, + $plugin_id, + $plugin_definition, EntityTypeManagerInterface $entity_type_manager, AccountProxyInterface $current_user, FormBuilderInterface $form_builder, ModuleHandlerInterface $module_handler, - $account + CurrentRouteMatch $route_match, + CurrentGroupService $current_group_service, ) { parent::__construct( $configuration, @@ -39,7 +42,8 @@ public function __construct( $current_user, $form_builder, $module_handler, - $account + $route_match, + $current_group_service, ); // Override the bundle type. diff --git a/modules/social_features/social_post/social_post.module b/modules/social_features/social_post/social_post.module index 3822ed9ae80..293b3ae7484 100644 --- a/modules/social_features/social_post/social_post.module +++ b/modules/social_features/social_post/social_post.module @@ -305,10 +305,3 @@ function social_post_user_predelete($account) { ->delete($entities); } } - -/** - * Implements hook_entity_access(). - */ -function social_post_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) { - $t =1 ; -} diff --git a/modules/social_features/social_post/src/Hooks/SocialPostFormHooks.php b/modules/social_features/social_post/src/Hooks/SocialPostFormHooks.php index 8a88a8c59ba..59d99604c6e 100644 --- a/modules/social_features/social_post/src/Hooks/SocialPostFormHooks.php +++ b/modules/social_features/social_post/src/Hooks/SocialPostFormHooks.php @@ -2,20 +2,42 @@ namespace Drupal\social_post\Hooks; +use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\hux\Attribute\Alter; -use Drupal\social_group\CurrentGroupService; use Drupal\social_post\Service\SocialPostHelperInterface; - +/** + * Replace hook: social_post_form_post_form_alter. + * + * @package Drupal\social_post\Hooks + */ final class SocialPostFormHooks { + /** + * The social post helper service. + * + * @var \Drupal\social_post\Service\SocialPostHelperInterface + */ private SocialPostHelperInterface $socialPostHelper; + + /** + * The account proxy. + * + * @var \Drupal\Core\Session\AccountProxyInterface + */ private AccountProxyInterface $currentUser; + /** + * Constructor. + * + * @param \Drupal\social_post\Service\SocialPostHelperInterface $social_post_helper + * The social post helper. + * @param \Drupal\Core\Session\AccountProxyInterface $current_user + * The account proxy. + */ public function __construct( SocialPostHelperInterface $social_post_helper, AccountProxyInterface $current_user, @@ -31,14 +53,18 @@ public function __construct( * definition of the hook. * * @param array $form - * @param FormStateInterface $form_state - * - * @return array + * The drupal form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The form state. */ #[Alter('form_post_form')] public function formPostFormAlter(array &$form, FormStateInterface $form_state): void { $content = $this->socialPostHelper->buildCurrentUserImage(); + if ($form_state->getFormObject() instanceof ContentEntityForm === FALSE) { + return; + } + if ($form_state->getFormObject()->getEntity()->isNew() && $content !== NULL) { $form['current_user_image'] = $content; @@ -75,9 +101,12 @@ public function formPostFormAlter(array &$form, FormStateInterface $form_state): * Set form title and placeholder value. * * @param array $form - * @param TranslatableMarkup $displayedValue + * The drupal form. + * @param \Drupal\Core\StringTranslation\TranslatableMarkup $displayedValue + * The translatable markup value to display. * * @return array + * The updated form title and placeholder. */ private function setFormTitleAndPlaceholder(array $form, TranslatableMarkup $displayedValue): array { $form['field_post']['widget'][0]['#title'] = $displayedValue; diff --git a/modules/social_features/social_post/src/Hooks/SocialPostHooks.php b/modules/social_features/social_post/src/Hooks/SocialPostHooks.php deleted file mode 100644 index ac48f4bb2b9..00000000000 --- a/modules/social_features/social_post/src/Hooks/SocialPostHooks.php +++ /dev/null @@ -1,73 +0,0 @@ -entityType = 'post'; @@ -67,26 +51,11 @@ public function __construct( // Check if current user is the same as the profile. // In this case use the default form display. + $account = $this->routeMatch->getParameter('user'); $uid = $this->currentUser->id(); if (isset($account) && ($account === $uid || (is_object($account) && $uid === $account->id()))) { $this->formDisplay = 'default'; } } - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('entity_type.manager'), - $container->get('current_user'), - $container->get('form_builder'), - $container->get('module_handler'), - $container->get('current_route_match')->getParameter('user') - ); - } - } diff --git a/modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php b/modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php index a9fe184c0a4..afe0a90f8ad 100644 --- a/modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php +++ b/modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php @@ -8,7 +8,6 @@ use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; diff --git a/modules/social_features/social_user/src/Plugin/AdvancedQueue/JobType/UserMailQueueJob.php b/modules/social_features/social_user/src/Plugin/AdvancedQueue/JobType/UserMailQueueJob.php index 9c2540d7f23..ea1823877e6 100644 --- a/modules/social_features/social_user/src/Plugin/AdvancedQueue/JobType/UserMailQueueJob.php +++ b/modules/social_features/social_user/src/Plugin/AdvancedQueue/JobType/UserMailQueueJob.php @@ -8,7 +8,6 @@ use Drupal\Component\Utility\EmailValidatorInterface; use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Link; diff --git a/modules/social_features/social_user/src/Plugin/QueueWorker/UserMailQueueProcessor.php b/modules/social_features/social_user/src/Plugin/QueueWorker/UserMailQueueProcessor.php index f14294ece8b..28ed5ab991b 100644 --- a/modules/social_features/social_user/src/Plugin/QueueWorker/UserMailQueueProcessor.php +++ b/modules/social_features/social_user/src/Plugin/QueueWorker/UserMailQueueProcessor.php @@ -6,7 +6,6 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Link; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 55dfde5e872..5f0538ea379 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -9795,11 +9795,6 @@ parameters: count: 1 path: modules/social_features/social_post/social_post.install - - - message: "#^Call to an undefined method Drupal\\\\Core\\\\Form\\\\FormInterface\\:\\:getEntity\\(\\)\\.$#" - count: 1 - path: modules/social_features/social_post/social_post.module - - message: "#^Function _social_post_comment_post_comment_form_submit\\(\\) has no return type specified\\.$#" count: 1 @@ -9830,21 +9825,6 @@ parameters: count: 1 path: modules/social_features/social_post/social_post.module - - - message: "#^Function social_post_form_post_form_alter\\(\\) has no return type specified\\.$#" - count: 1 - path: modules/social_features/social_post/social_post.module - - - - message: "#^Function social_post_form_post_form_alter\\(\\) has parameter \\$form with no type specified\\.$#" - count: 1 - path: modules/social_features/social_post/social_post.module - - - - message: "#^Function social_post_form_post_form_alter\\(\\) has parameter \\$form_id with no type specified\\.$#" - count: 1 - path: modules/social_features/social_post/social_post.module - - message: "#^Function social_post_preprocess_activity\\(\\) has no return type specified\\.$#" count: 1 @@ -9910,11 +9890,6 @@ parameters: count: 1 path: modules/social_features/social_post/social_post.module - - - message: "#^Not allowed to call private function _social_group_get_current_group from module social_post\\.$#" - count: 1 - path: modules/social_features/social_post/social_post.module - - message: "#^Cannot call method fetchAll\\(\\) on Drupal\\\\Core\\\\Database\\\\StatementInterface\\|null\\.$#" count: 1