Skip to content

Commit

Permalink
Remove debug.
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-getopensocial committed Oct 16, 2024
1 parent afb617b commit 8e34027
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
46 changes: 40 additions & 6 deletions modules/social_features/social_group/src/CurrentGroupService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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,
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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,
Expand All @@ -39,7 +42,8 @@ public function __construct(
$current_user,
$form_builder,
$module_handler,
$account
$route_match,
$current_group_service,
);

// Override the bundle type.
Expand Down
7 changes: 0 additions & 7 deletions modules/social_features/social_post/social_post.module
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
73 changes: 0 additions & 73 deletions modules/social_features/social_post/src/Hooks/SocialPostHooks.php

This file was deleted.

Loading

0 comments on commit 8e34027

Please sign in to comment.