diff --git a/src/Ajax/SelectEntitiesCommand.php b/src/Ajax/SelectEntitiesCommand.php index fc95a04..3a64bc7 100644 --- a/src/Ajax/SelectEntitiesCommand.php +++ b/src/Ajax/SelectEntitiesCommand.php @@ -5,8 +5,7 @@ namespace Drupal\entity_browser\Ajax; use Drupal\Core\Ajax\CommandInterface; /** - * AJAX command to rerender a formatted text field without any transformation - * filters. + * AJAX command to rerender a formatted text without transformation filters. */ class SelectEntitiesCommand implements CommandInterface { @@ -33,7 +32,7 @@ class SelectEntitiesCommand implements CommandInterface { * 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) { + public function __construct($uuid, array $entities) { $this->uuid = $uuid; $this->entities = $entities; } diff --git a/src/Ajax/ValueUpdatedCommand.php b/src/Ajax/ValueUpdatedCommand.php index fa08d66..9858376 100644 --- a/src/Ajax/ValueUpdatedCommand.php +++ b/src/Ajax/ValueUpdatedCommand.php @@ -14,7 +14,7 @@ class ValueUpdatedCommand implements CommandInterface { * * @var string */ - protected $details_id; + protected $detailIds; /** * Constructor. @@ -23,7 +23,7 @@ class ValueUpdatedCommand implements CommandInterface { * The ID for the details element. */ public function __construct($details_id) { - $this->details_id = $details_id; + $this->detailIds = $details_id; } /** @@ -32,7 +32,7 @@ class ValueUpdatedCommand implements CommandInterface { public function render() { return [ 'command' => 'entity_browser_value_updated', - 'details_id' => $this->details_id, + 'details_id' => $this->detailIds, ]; } diff --git a/src/EntityBrowserInterface.php b/src/EntityBrowserInterface.php index 09a5e86..88fb083 100644 --- a/src/EntityBrowserInterface.php +++ b/src/EntityBrowserInterface.php @@ -53,7 +53,7 @@ interface EntityBrowserInterface extends ConfigEntityInterface { /** * Sets the id of the widget selector plugin. * - * @param string $display + * @param string $widget_selector * The id of the widget selector plugin. * * @return \Drupal\entity_browser\EntityBrowserInterface @@ -64,7 +64,7 @@ interface EntityBrowserInterface extends ConfigEntityInterface { /** * Sets the id of the selection display plugin. * - * @param string $display + * @param string $selection_display * The id of the selection display plugin. * * @return \Drupal\entity_browser\EntityBrowserInterface diff --git a/src/Events/AlterEntityBrowserDisplayData.php b/src/Events/AlterEntityBrowserDisplayData.php index 22141bf..befbe7e 100644 --- a/src/Events/AlterEntityBrowserDisplayData.php +++ b/src/Events/AlterEntityBrowserDisplayData.php @@ -87,7 +87,7 @@ class AlterEntityBrowserDisplayData extends EventBase { * @param array $data * Data array. */ - public function setData($data) { + public function setData(array $data) { $this->data = $data; } diff --git a/src/Events/EntitySelectionEvent.php b/src/Events/EntitySelectionEvent.php index ad1b9a2..cb61fcc 100644 --- a/src/Events/EntitySelectionEvent.php +++ b/src/Events/EntitySelectionEvent.php @@ -33,6 +33,7 @@ class EntitySelectionEvent extends EventBase { * Gets selected entities. * * @return \Drupal\Core\Entity\EntityInterface[] + * Selected entities. */ public function getEntities() { return $this->entities; diff --git a/src/Events/EventBase.php b/src/Events/EventBase.php index 9346731..bee51c1 100644 --- a/src/Events/EventBase.php +++ b/src/Events/EventBase.php @@ -42,7 +42,7 @@ class EventBase extends Event { * @return string * Entity browser ID. */ - public function getBrowserID() { + public function getBrowserId() { return $this->entityBrowserID; } @@ -52,7 +52,7 @@ class EventBase extends Event { * @return string * Entity browser instance UUID. */ - public function getBrowserInstanceUUID() { + public function getBrowserInstanceUuid() { return $this->instanceUUID; } diff --git a/src/Events/Events.php b/src/Events/Events.php index 75345ba..09c501f 100644 --- a/src/Events/Events.php +++ b/src/Events/Events.php @@ -8,7 +8,9 @@ namespace Drupal\entity_browser\Events; final class Events { /** - * The SELECED event occurs when enities are selected in currently active + * SELECTED event. + * + * The SELECTED event occurs when entities are selected in currently active * widget. * * @var string @@ -16,6 +18,8 @@ final class Events { const SELECTED = 'entity_browser.selected'; /** + * DONE event. + * * The DONE event occurs when selection process is done. While it can be emitted * by any part of the system that will usually be done by selection display plugin. * @@ -24,6 +28,8 @@ final class Events { const DONE = 'entity_browser.done'; /** + * REGISTER_JS_CALLBACKS event. + * * The REGISTER_JS_CALLBACKS collects JS callbacks that need to be notified when * we bring selected entities back to the form. Callbacks are responsible to * propagate selection further to entitiy fields, etc. @@ -33,6 +39,8 @@ final class Events { const REGISTER_JS_CALLBACKS = 'entity_browser.register_js_callbacks'; /** + * ALTER_BROWSER_DISPLAY_DATA event. + * * The ALTER_BROWSER_DISPLAY_DATA allows for entity browser display plugin data * to be tweaked. * diff --git a/src/Events/RegisterJSCallbacks.php b/src/Events/RegisterJSCallbacks.php index 9431630..1ca3970 100644 --- a/src/Events/RegisterJSCallbacks.php +++ b/src/Events/RegisterJSCallbacks.php @@ -40,7 +40,7 @@ class RegisterJSCallbacks extends EventBase { * @param array $callbacks * List of callbacks. */ - public function setCallbacks($callbacks) { + public function setCallbacks(array $callbacks) { $this->callbacks = $callbacks; } diff --git a/src/Permissions.php b/src/Permissions.php index 6cb5683..1b6dfe5 100644 --- a/src/Permissions.php +++ b/src/Permissions.php @@ -32,6 +32,7 @@ class Permissions implements ContainerInjectionInterface { * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * Entity manager service. * @param \Drupal\Core\StringTranslation\TranslationManager $translation + * Translation manager. */ public function __construct(EntityTypeManagerInterface $entity_type_manager, TranslationManager $translation) { $this->browserStorage = $entity_type_manager->getStorage('entity_browser'); diff --git a/src/Plugin/EntityBrowser/Widget/Upload.php b/src/Plugin/EntityBrowser/Widget/Upload.php index a0b7edf..8c8f75d 100644 --- a/src/Plugin/EntityBrowser/Widget/Upload.php +++ b/src/Plugin/EntityBrowser/Widget/Upload.php @@ -98,8 +98,21 @@ class Upload extends WidgetBase { */ public function getForm(array &$original_form, FormStateInterface $form_state, array $additional_widget_parameters) { $form = parent::getForm($original_form, $form_state, $additional_widget_parameters); - $field_cardinality = $form_state->get(['entity_browser', 'validators', 'cardinality', 'cardinality']); - $upload_validators = $form_state->has(['entity_browser', 'widget_context', 'upload_validators']) ? $form_state->get(['entity_browser', 'widget_context', 'upload_validators']) : []; + $field_cardinality = $form_state->get([ + 'entity_browser', + 'validators', + 'cardinality', + 'cardinality', + ]); + $upload_validators = $form_state->has([ + 'entity_browser', + 'widget_context', + 'upload_validators', + ]) ? $form_state->get([ + 'entity_browser', + 'widget_context', + 'upload_validators', + ]) : []; $form['upload'] = [ '#type' => 'managed_file', '#title' => $this->t('Choose a file'), diff --git a/src/Plugin/EntityBrowser/WidgetSelector/DropDown.php b/src/Plugin/EntityBrowser/WidgetSelector/DropDown.php index 497cbac..6da935c 100644 --- a/src/Plugin/EntityBrowser/WidgetSelector/DropDown.php +++ b/src/Plugin/EntityBrowser/WidgetSelector/DropDown.php @@ -28,7 +28,7 @@ class DropDown extends WidgetSelectorBase { $browser = $form_state->getFormObject()->getEntityBrowser(); $widget_ids = []; - foreach ($this->widget_ids as $widget_id => $widget_name) { + foreach ($this->widgetIds as $widget_id => $widget_name) { if ($browser->getWidget($widget_id)->access()->isAllowed()) { $widget_ids[$widget_id] = $widget_name; } diff --git a/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php b/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php index 0128b29..fe4b3ce 100644 --- a/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php +++ b/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php @@ -23,7 +23,7 @@ class Tabs extends WidgetSelectorBase { $element = []; /** @var \Drupal\entity_browser\EntityBrowserInterface $browser */ $browser = $form_state->getFormObject()->getEntityBrowser(); - foreach ($this->widget_ids as $id => $label) { + foreach ($this->widgetIds as $id => $label) { $name = 'tab_selector_' . $id; $element[$name] = [ '#type' => 'button', @@ -50,7 +50,7 @@ class Tabs extends WidgetSelectorBase { */ public function submit(array &$form, FormStateInterface $form_state) { if (($trigger = $form_state->getTriggeringElement()) && strpos($trigger['#name'], 'tab_selector_') === 0) { - if (!empty($this->widget_ids[$trigger['#widget_id']])) { + if (!empty($this->widgetIds[$trigger['#widget_id']])) { return $trigger['#widget_id']; } } diff --git a/src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php b/src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php index fb8f380..ec8952c 100644 --- a/src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php +++ b/src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php @@ -770,7 +770,11 @@ class EntityReferenceBrowserWidget extends WidgetBase implements ContainerFactor if (($trigger = $form_state->getTriggeringElement())) { // Can be triggered by hidden target_id element or "Remove" button. $last_parent = end($trigger['#parents']); - if (in_array($last_parent, ['target_id', 'remove_button', 'replace_button'])) { + if (in_array($last_parent, [ + 'target_id', + 'remove_button', + 'replace_button' + ])) { $is_relevant_submit = TRUE; // In case there are more instances of this widget on the same page we diff --git a/src/Plugin/Field/FieldWidget/FileBrowserWidget.php b/src/Plugin/Field/FieldWidget/FileBrowserWidget.php index e6b0019..db04408 100644 --- a/src/Plugin/Field/FieldWidget/FileBrowserWidget.php +++ b/src/Plugin/Field/FieldWidget/FileBrowserWidget.php @@ -95,10 +95,10 @@ class FileBrowserWidget extends EntityReferenceBrowserWidget { * The module handler service. * @param \Drupal\Core\Session\AccountInterface $current_user * The current user. - * @param \Drupal\Core\Messenger\MessengerInterface $messenger - * The messenger. * @param \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface $mime_type_guesser * The mime type guesser service. + * @param \Drupal\Core\Messenger\MessengerInterface $messenger + * The messenger. */ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EntityTypeManagerInterface $entity_type_manager, FieldWidgetDisplayManager $field_display_manager, ConfigFactoryInterface $config_factory, EntityDisplayRepositoryInterface $display_repository, ModuleHandlerInterface $module_handler, AccountInterface $current_user, MimeTypeGuesserInterface $mime_type_guesser, MessengerInterface $messenger) { parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings, $entity_type_manager, $field_display_manager, $module_handler, $current_user, $messenger); @@ -385,7 +385,9 @@ class FileBrowserWidget extends EntityReferenceBrowserWidget { ], '#submit' => [[get_class($this), 'removeItemSubmit']], '#name' => $field_machine_name . '_replace_' . $entity_id . '_' . md5(json_encode($field_parents)), - '#limit_validation_errors' => [array_merge($field_parents, [$field_machine_name, 'target_id'])], + '#limit_validation_errors' => [ + array_merge($field_parents, [$field_machine_name, 'target_id']) + ], '#attributes' => [ 'data-entity-id' => $entity->getEntityTypeId() . ':' . $entity->id(), 'data-row-id' => $delta, @@ -402,7 +404,9 @@ class FileBrowserWidget extends EntityReferenceBrowserWidget { ], '#submit' => [[get_class($this), 'removeItemSubmit']], '#name' => $field_machine_name . '_remove_' . $entity_id . '_' . md5(json_encode($field_parents)), - '#limit_validation_errors' => [array_merge($field_parents, [$field_machine_name, 'target_id'])], + '#limit_validation_errors' => [ + array_merge($field_parents, [$field_machine_name, 'target_id']) + ], '#attributes' => [ 'data-entity-id' => $entity->getEntityTypeId() . ':' . $entity->id(), 'data-row-id' => $delta, diff --git a/src/Plugin/views/field/SelectForm.php b/src/Plugin/views/field/SelectForm.php index 30039b9..7467762 100644 --- a/src/Plugin/views/field/SelectForm.php +++ b/src/Plugin/views/field/SelectForm.php @@ -134,7 +134,7 @@ class SelectForm extends FieldPluginBase { * @param array $render * An associative array containing the structure of the form. */ - public function viewsForm(&$render) { + public function viewsForm(array &$render) { // Only add the bulk form options and buttons if there are results. if (!empty($this->view->result)) { // Render checkboxes for all rows. diff --git a/src/Plugin/views/filter/ContextualBundle.php b/src/Plugin/views/filter/ContextualBundle.php index d59ed6a..94df4e7 100644 --- a/src/Plugin/views/filter/ContextualBundle.php +++ b/src/Plugin/views/filter/ContextualBundle.php @@ -63,6 +63,8 @@ class ContextualBundle extends Bundle { * The entity manager. * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * A request stack symfony instance. + * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $selection_storage + * Selection storage. * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $bundle_info_service * The bundle info service. */ @@ -195,7 +197,7 @@ class ContextualBundle extends Bundle { * TRUE if the input for this filter should be included in the view query. * FALSE otherwise. */ - public function acceptExposedInput($input) { + public function acceptExposedInput(array $input) { if (empty($this->options['exposed'])) { return TRUE; diff --git a/src/RouteSubscriber.php b/src/RouteSubscriber.php index 161ee51..e393297 100644 --- a/src/RouteSubscriber.php +++ b/src/RouteSubscriber.php @@ -46,7 +46,7 @@ class RouteSubscriber { public function routes() { $collection = new RouteCollection(); - foreach ($this->getBrowserIDsWithRoute() as $id) { + foreach ($this->getBrowserIdsWithRoute() as $id) { /** @var $browser \Drupal\entity_browser\EntityBrowserInterface */ $browser = $this->browserStorage->load($id); if ($route = $browser->route()) { @@ -63,7 +63,7 @@ class RouteSubscriber { * @return array * Array of browser IDs. */ - protected function getBrowserIDsWithRoute() { + protected function getBrowserIdsWithRoute() { // Get all display plugins which provides the type. $display_plugins = $this->displayManager->getDefinitions(); $ids = []; diff --git a/src/SelectionDisplayBase.php b/src/SelectionDisplayBase.php index 7591acb..6f66759 100644 --- a/src/SelectionDisplayBase.php +++ b/src/SelectionDisplayBase.php @@ -130,7 +130,7 @@ abstract class SelectionDisplayBase extends PluginBase implements SelectionDispl * {@inheritdoc} */ public function checkPreselectionSupport() { - @trigger_error('checkPreselectionSupport method is deprecated. Use supportsPreselection instead.', E_USER_DEPRECATED); + @trigger_error('checkPreselectionSupport method is deprecated in entity_browser:8.2.2 and is removed from entity_browser:9.0.0. See supportsPreselection.', E_USER_DEPRECATED); if (!$this->getPluginDefinition()['acceptPreselection']) { throw new ConfigException('Used entity browser selection display does not support preselection.'); } diff --git a/src/SelectionDisplayInterface.php b/src/SelectionDisplayInterface.php index e58ffa2..271a38d 100644 --- a/src/SelectionDisplayInterface.php +++ b/src/SelectionDisplayInterface.php @@ -65,7 +65,9 @@ interface SelectionDisplayInterface extends PluginInspectionInterface, Configura * If preselection is not allowed by entity browser selection display, then * exception will be thrown. * - * @deprecated Use ::supportsPreselection instead. + * @deprecated in entity_browser:8.2.2 and is removed from entity_browser:9.0.0. + * Use ::supportsPreselection instead. + * @see ::supportsPreselection * * @throws \Drupal\Core\Config\ConfigException */ diff --git a/src/WidgetBase.php b/src/WidgetBase.php index f5d2ea7..26b6017 100644 --- a/src/WidgetBase.php +++ b/src/WidgetBase.php @@ -311,7 +311,7 @@ abstract class WidgetBase extends PluginBase implements WidgetInterface, Contain * A list of constraint violations. If the list is empty, validation * succeeded. */ - protected function runWidgetValidators(array $entities, $validators = []) { + protected function runWidgetValidators(array $entities, array $validators = []) { $violations = new ConstraintViolationList(); foreach ($validators as $validator_id => $options) { /** @var \Drupal\entity_browser\WidgetValidationInterface $widget_validator */ @@ -334,6 +334,8 @@ abstract class WidgetBase extends PluginBase implements WidgetInterface, Contain * * @param array $entities * Array of entities. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * Drupal form_state. */ protected function selectEntities(array $entities, FormStateInterface $form_state) { $selected_entities = &$form_state->get(['entity_browser', 'selected_entities']); @@ -356,16 +358,17 @@ abstract class WidgetBase extends PluginBase implements WidgetInterface, Contain } /** - * Allow configuration overrides at runtime based on widget context passed to - * this widget from the Entity Browser element. + * Allow configuration overrides at runtime based on widget context. * - * Widgets can override this method to replace the default behavior of - * replacing configuration with widget context if array keys match. + * Allow configuration overrides at runtime based on widget context passed to + * this widget from the Entity Browser element. Widgets can override this + * method to replace the default behavior of replacing configuration + * with widget context if array keys match. * * @param array $widget_context * The widget context. */ - protected function handleWidgetContext($widget_context) { + protected function handleWidgetContext(array $widget_context) { foreach ($this->defaultConfiguration() as $key => $value) { if (isset($widget_context[$key]) && isset($this->configuration[$key])) { $this->configuration[$key] = $widget_context[$key]; diff --git a/src/WidgetSelectorBase.php b/src/WidgetSelectorBase.php index b71687d..d282045 100644 --- a/src/WidgetSelectorBase.php +++ b/src/WidgetSelectorBase.php @@ -25,7 +25,7 @@ abstract class WidgetSelectorBase extends PluginBase implements WidgetSelectorIn * * @var array */ - protected $widgets_ids; + protected $widgetIds; /** * ID of the default widget. @@ -40,7 +40,7 @@ abstract class WidgetSelectorBase extends PluginBase implements WidgetSelectorIn public function __construct($configuration, $plugin_id, $plugin_definition) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->setConfiguration($configuration); - $this->widget_ids = isset($this->configuration['widget_ids']) ? $this->configuration['widget_ids'] : []; + $this->widgetIds = isset($this->configuration['widget_ids']) ? $this->configuration['widget_ids'] : []; } /** diff --git a/tests/fixtures/update/entity_browser.update-hook-test.php b/tests/fixtures/update/entity_browser.update-hook-test.php index 215f7a5..bf30577 100644 --- a/tests/fixtures/update/entity_browser.update-hook-test.php +++ b/tests/fixtures/update/entity_browser.update-hook-test.php @@ -1,7 +1,8 @@ drupalCreateUser([ 'administer entity browsers', 'access test_entity_browser_iframe entity browser pages', diff --git a/tests/src/FunctionalJavascript/EntityBrowserJavascriptTestBase.php b/tests/src/FunctionalJavascript/EntityBrowserJavascriptTestBase.php index bece737..10fcee2 100644 --- a/tests/src/FunctionalJavascript/EntityBrowserJavascriptTestBase.php +++ b/tests/src/FunctionalJavascript/EntityBrowserJavascriptTestBase.php @@ -14,8 +14,8 @@ use Drupal\FunctionalJavascriptTests\JavascriptTestBase; * * @package Drupal\Tests\entity_browser\FunctionalJavascript * - * @deprecated in Drupal 8.6.x, will be removed before Drupal 9.0.0. - * Use \Drupal\Tests\entity_browser\FunctionalJavascript\EntityBrowserWebDriverTestBase instead + * @deprecated in drupal:8.6.x and is removed from drupal:9.0.0. + * Use \Drupal\FunctionalJavascriptTests\JavascriptTestBase * * @see \Drupal\FunctionalJavascriptTests\JavascriptTestBase for more info. */