Skip to content
Snippets Groups Projects
Commit 09114a0d authored by Sahil Goyal's avatar Sahil Goyal Committed by Nikolay Lobachev
Browse files

Issue #3342229 by LOBsTerr: Fix the issues reported by phpcs

parent 52461115
No related branches found
No related tags found
No related merge requests found
......@@ -182,7 +182,7 @@ function groupmedia_group_insert(GroupInterface $group) {
/**
* Implements hook_form_FORM_ID_alter().
*/
function groupmedia_form_views_exposed_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
function groupmedia_form_views_exposed_form_alter(&$form, FormStateInterface $form_state) {
$view = $form_state->getStorage()['view'] ?? NULL;
if (!empty($view) && $view->id() == 'group_media') {
$group_id = $view->args[0] ?? NULL;
......
......@@ -19,7 +19,7 @@ services:
# Specific group relation handlers.
group.relation_handler.operation_provider.group_media:
class: 'Drupal\groupmedia\Plugin\Group\RelationHandler\GroupMediaOperationProvider'
arguments: [ '@group.relation_handler.operation_provider', '@current_user', '@string_translation' ]
arguments: [ '@group.relation_handler.operation_provider', '@current_user', '@string_translation', '@entity_type.manager']
shared: false
group.relation_handler.permission_provider.group_media:
......
......@@ -3,10 +3,10 @@
namespace Drupal\groupmedia_vbo\Plugin\Action;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\groupmedia\AttachMediaToGroup;
use Drupal\media\MediaInterface;
use Drupal\views_bulk_operations\Action\ViewsBulkOperationsActionBase;
......
......@@ -3,10 +3,10 @@
namespace Drupal\groupmedia_vbo\Plugin\Action;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\groupmedia\AttachMediaToGroup;
use Drupal\media\MediaInterface;
use Drupal\views_bulk_operations\Action\ViewsBulkOperationsActionBase;
......
......@@ -8,8 +8,8 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\group\Entity\GroupRelationshipInterface;
use Drupal\group\Entity\GroupInterface;
use Drupal\group\Entity\GroupRelationshipInterface;
use Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface;
use Drupal\media\MediaInterface;
......@@ -57,13 +57,6 @@ class AttachMediaToGroup {
*/
protected $logger;
/**
* List of plugins by group type.
*
* @var array
*/
protected $pluginsByGroupType = [];
/**
* Media item group counts.
*
......
......@@ -4,9 +4,9 @@ namespace Drupal\groupmedia\Plugin\Action;
use Drupal\Core\Action\ConfigurableActionBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\groupmedia\AttachMediaToGroup;
use Drupal\media\MediaInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......
......@@ -4,9 +4,9 @@ namespace Drupal\groupmedia\Plugin\Action;
use Drupal\Core\Action\ConfigurableActionBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\groupmedia\AttachMediaToGroup;
use Drupal\media\MediaInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......
......@@ -2,8 +2,8 @@
namespace Drupal\groupmedia\Plugin\Group\Relation;
use Drupal\group\Plugin\Group\Relation\GroupRelationBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\group\Plugin\Group\Relation\GroupRelationBase;
/**
* Provides a relation enabler for media.
......
......@@ -2,10 +2,10 @@
namespace Drupal\groupmedia\Plugin\Group\Relation;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\group\Plugin\Group\Relation\GroupRelationTypeInterface;
use Drupal\media\Entity\MediaType;
use Drupal\Component\Plugin\Derivative\DeriverBase;
/**
* Class Group Media Deriver.
......
......@@ -2,13 +2,13 @@
namespace Drupal\groupmedia\Plugin\Group\RelationHandler;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\Core\Url;
use Drupal\group\Entity\GroupInterface;
use Drupal\group\Plugin\Group\RelationHandler\OperationProviderInterface;
use Drupal\group\Plugin\Group\RelationHandler\OperationProviderTrait;
use Drupal\media\Entity\MediaType;
/**
* Provides operations for the group_media relation plugin.
......@@ -17,6 +17,27 @@ class GroupMediaOperationProvider implements OperationProviderInterface {
use OperationProviderTrait;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* String translation manager.
*
* @var \Drupal\Core\StringTranslation\TranslationInterface
*/
protected $stringTranslation;
/**
* Media type storage.
*
* @var \Drupal\Core\Entity\Sql\SqlEntityStorageInterface
*/
protected $mediaTypeStorage;
/**
* Constructs a new GroupMembershipRequestOperationProvider.
*
......@@ -26,11 +47,19 @@ class GroupMediaOperationProvider implements OperationProviderInterface {
* The current user.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
*/
public function __construct(OperationProviderInterface $parent, AccountProxyInterface $current_user, TranslationInterface $string_translation) {
public function __construct(
OperationProviderInterface $parent,
AccountProxyInterface $current_user,
TranslationInterface $string_translation,
EntityTypeManagerInterface $entity_type_manager
) {
$this->parent = $parent;
$this->currentUser = $current_user;
$this->stringTranslation = $string_translation;
$this->mediaTypeStorage = $entity_type_manager->getStorage('media_type');
}
/**
......@@ -38,10 +67,10 @@ class GroupMediaOperationProvider implements OperationProviderInterface {
*/
public function getGroupOperations(GroupInterface $group) {
$operations = $this->parent->getGroupOperations($group);
$media_bundle_id = $this->groupRelationType->getEntityBundle();
$media_type = MediaType::load($media_bundle_id);
if ($group->hasPermission("create {$this->pluginId} entity", $this->currentUser)) {
$media_bundle_id = $this->groupRelationType->getEntityBundle();
$media_type = $this->mediaTypeStorage->load($media_bundle_id);
$operations["groupmedia-create-{$media_bundle_id}"] = [
'title' => $this->t('Create @type', ['@type' => $media_type->label()]),
'url' => new Url('entity.group_content.create_form', [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment