From 12372ed6a751e78cd5c1a8e1d9a446dd9dc2657a Mon Sep 17 00:00:00 2001 From: Janez Urevc Date: Tue, 20 Oct 2015 02:18:04 +0200 Subject: [PATCH] Issue #2512708 by slashrsm: Fix minor coding style issues. --- entity_browser.api.php | 2 +- src/Ajax/SelectEntitiesCommand.php | 14 ++++++++------ src/Events/EntitySelectionEvent.php | 2 +- src/Kernel/Extension/EntityBrowserTest.php | 2 +- src/Plugin/EntityBrowser/Display/Modal.php | 4 +--- src/Plugin/EntityBrowser/SelectionDisplay/View.php | 2 ++ src/Plugin/EntityBrowser/Widget/Upload.php | 1 + src/Plugin/EntityBrowser/Widget/View.php | 1 + 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/entity_browser.api.php b/entity_browser.api.php index 5c74a12..8231aea 100644 --- a/entity_browser.api.php +++ b/entity_browser.api.php @@ -58,7 +58,7 @@ function hook_entity_browser_widget_selector_info_alter(&$widgets) { * name. */ function hook_entity_browser_field_widget_display_info_alter(&$field_displays) { - $displays['rendered_entity']['label'] = t('Entity render system FTW'); + $field_displays['rendered_entity']['label'] = t('Entity render system FTW'); } /** diff --git a/src/Ajax/SelectEntitiesCommand.php b/src/Ajax/SelectEntitiesCommand.php index 57de241..f791b81 100644 --- a/src/Ajax/SelectEntitiesCommand.php +++ b/src/Ajax/SelectEntitiesCommand.php @@ -21,20 +21,22 @@ class SelectEntitiesCommand implements CommandInterface { * @var string */ protected $uuid; - + /** * A CSS selector string. * * @var array */ protected $entities; - /** * Constructs a \Drupal\entity_browser\Ajax\SelectEntities object. * - * @param string $selector - * A CSS selector. + * @param string $uuid + * Entity browser instance UUID. + * @param array $entities + * Entities that were selected. Each entity is represented with an array + * consisting of three values (entity ID, entity UUID and entity type). */ public function __construct($uuid, $entities) { $this->uuid = $uuid; @@ -45,10 +47,10 @@ public function __construct($uuid, $entities) { * Implements \Drupal\Core\Ajax\CommandInterface::render(). */ public function render() { - return array( + return [ 'command' => 'select_entities', 'uuid' => $this->uuid, 'entities' => $this->entities, - ); + ]; } } diff --git a/src/Events/EntitySelectionEvent.php b/src/Events/EntitySelectionEvent.php index 0a6ea23..e65328d 100644 --- a/src/Events/EntitySelectionEvent.php +++ b/src/Events/EntitySelectionEvent.php @@ -26,7 +26,7 @@ class EntitySelectionEvent extends EventBase { * Entity browser ID. * @param string $instance_uuid * Entity browser instance UUID. - * @param \Drupal\Core\Entity\EntityInterface[] $entites + * @param \Drupal\Core\Entity\EntityInterface[] $entities * Array of selected entities. */ public function __construct($entity_browser_id, $instance_uuid, array $entities) { diff --git a/src/Kernel/Extension/EntityBrowserTest.php b/src/Kernel/Extension/EntityBrowserTest.php index 4440464..462ca7d 100644 --- a/src/Kernel/Extension/EntityBrowserTest.php +++ b/src/Kernel/Extension/EntityBrowserTest.php @@ -283,7 +283,7 @@ public function testDefaultWidget() { /** @var $entity \Drupal\entity_browser\EntityBrowserInterface */ $entity = $this->controller->load('test'); - /** @var \Drupal\entity_browser\Form\EntityBrowserFormInterface $form_object */ + /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */ $form_object = $this->container->get('entity.manager')->getFormObject($entity->getEntityTypeId(), 'entity_browser'); $form_object->setEntity($entity); $form_state = new FormState(); diff --git a/src/Plugin/EntityBrowser/Display/Modal.php b/src/Plugin/EntityBrowser/Display/Modal.php index b18f29e..92f4545 100644 --- a/src/Plugin/EntityBrowser/Display/Modal.php +++ b/src/Plugin/EntityBrowser/Display/Modal.php @@ -78,8 +78,6 @@ class Modal extends DisplayBase implements DisplayRouterInterface, DisplayAjaxIn * The currently active route match object. * @param \Drupal\Component\Uuid\UuidInterface * UUID generator interface. - * @param \Symfony\Component\HttpFoundation\Request $request - * Current request. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, RouteMatchInterface $current_route_match, UuidInterface $uuid, CurrentPathStack $current_path) { parent::__construct($configuration, $plugin_id, $plugin_definition, $event_dispatcher); @@ -220,7 +218,7 @@ public function widgetAjaxCallback(array &$form, FormStateInterface $form_state) * @return array */ public function getAjaxCommands(FormStateInterface $form_state) { - $entities = array_map(function (EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()];}, $form_state->get(['entity_browser', 'selected_entities'])); + $entities = array_map(function(EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()];}, $form_state->get(['entity_browser', 'selected_entities'])); $commands = array(); $commands[] = new SelectEntitiesCommand($this->uuid, $entities); $commands[] = new CloseDialogCommand(); diff --git a/src/Plugin/EntityBrowser/SelectionDisplay/View.php b/src/Plugin/EntityBrowser/SelectionDisplay/View.php index 74e91f9..74a9990 100644 --- a/src/Plugin/EntityBrowser/SelectionDisplay/View.php +++ b/src/Plugin/EntityBrowser/SelectionDisplay/View.php @@ -35,6 +35,8 @@ public function defaultConfiguration() { * {@inheritdoc} */ public function getForm(array &$original_form, FormStateInterface $form_state) { + $form = []; + // TODO - do we need better error handling for view and view_display (in case // either of those is nonexistent or display not of correct type)? $storage = &$form_state->getStorage(); diff --git a/src/Plugin/EntityBrowser/Widget/Upload.php b/src/Plugin/EntityBrowser/Widget/Upload.php index e1cf999..e34ae9e 100644 --- a/src/Plugin/EntityBrowser/Widget/Upload.php +++ b/src/Plugin/EntityBrowser/Widget/Upload.php @@ -34,6 +34,7 @@ public function defaultConfiguration() { * {@inheritdoc} */ public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) { + $form = []; $form['upload'] = [ '#type' => 'managed_file', '#title' => t('Choose a file'), diff --git a/src/Plugin/EntityBrowser/Widget/View.php b/src/Plugin/EntityBrowser/Widget/View.php index 4e9b185..38ca71d 100644 --- a/src/Plugin/EntityBrowser/Widget/View.php +++ b/src/Plugin/EntityBrowser/Widget/View.php @@ -37,6 +37,7 @@ public function defaultConfiguration() { * {@inheritdoc} */ public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) { + $form = []; // TODO - do we need better error handling for view and view_display (in case // either of those is nonexistent or display not of correct type)? /** @var \Drupal\views\ViewExecutable $view */