diff --git a/entity_hierarchy.drush.inc b/entity_hierarchy.drush.inc index 824987aee50dcccb9bb18fa235a24a6fa6dc38bb..a7b54f8542790ee5b4e68ac5aa07c634e074792e 100644 --- a/entity_hierarchy.drush.inc +++ b/entity_hierarchy.drush.inc @@ -9,19 +9,19 @@ * Implements hook_drush_command(). */ function entity_hierarchy_drush_command() { - $items = array(); + $items = []; - $items['entity-hierarchy-rebuild-tree'] = array( + $items['entity-hierarchy-rebuild-tree'] = [ 'description' => 'Rebuild tree.', - 'arguments' => array( + 'arguments' => [ 'field_name' => dt('Field machine name'), 'entity_type_id' => dt('Entity type id'), - ), - 'options' => array(), - 'examples' => array( + ], + 'options' => [], + 'examples' => [ 'drush entity-hierarchy-rebuild-tree field_parents node' => 'Rebuild tree for node field named field_parents.', - ), - ); + ], + ]; return $items; } diff --git a/modules/entity_hierarchy_breadcrumb/src/HierarchyBasedBreadcrumbBuilder.php b/modules/entity_hierarchy_breadcrumb/src/HierarchyBasedBreadcrumbBuilder.php index d358e6c6eca08a5ca33c9c380e52690ed18597b3..296d406c65ce4129fad70feef28e4764a5ab75d4 100644 --- a/modules/entity_hierarchy_breadcrumb/src/HierarchyBasedBreadcrumbBuilder.php +++ b/modules/entity_hierarchy_breadcrumb/src/HierarchyBasedBreadcrumbBuilder.php @@ -102,7 +102,7 @@ class HierarchyBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface { */ public function build(RouteMatchInterface $route_match) { $breadcrumb = new Breadcrumb(); - /** @var ContentEntityInterface $route_entity */ + /** @var \Drupal\Core\Entity\ContentEntityInterface $route_entity */ $route_entity = $this->getEntityFromRouteMatch($route_match); $breadcrumb->addCacheableDependency($route_match->getRouteObject()); diff --git a/modules/entity_hierarchy_workbench_access/src/Plugin/Validation/Constraint/ValidEntityHierarchySection.php b/modules/entity_hierarchy_workbench_access/src/Plugin/Validation/Constraint/ValidEntityHierarchySection.php index a6ecc224581d680c33339d56920625e543454013..e2acb8d5d6aad2cd89ff8840280611312483940c 100644 --- a/modules/entity_hierarchy_workbench_access/src/Plugin/Validation/Constraint/ValidEntityHierarchySection.php +++ b/modules/entity_hierarchy_workbench_access/src/Plugin/Validation/Constraint/ValidEntityHierarchySection.php @@ -12,7 +12,6 @@ use Symfony\Component\Validator\ExecutionContextInterface; * @Constraint( * id = "ValidHierarchySection", * label = @Translation("Valid hierarchy selection", context = "Validation"), - * type = "entity:comment" * ) */ class ValidEntityHierarchySection extends Constraint implements ConstraintValidatorInterface { diff --git a/src/Plugin/EntityReferenceSelection/EntityHierarchy.php b/src/Plugin/EntityReferenceSelection/EntityHierarchy.php index d8f560f9297af06926b07ea53f8c094476f916c4..ac2f2bc0c0637445457b4567eaff85f24e897504 100644 --- a/src/Plugin/EntityReferenceSelection/EntityHierarchy.php +++ b/src/Plugin/EntityReferenceSelection/EntityHierarchy.php @@ -110,10 +110,10 @@ class EntityHierarchy extends DefaultSelection { $result = $query->execute(); if (empty($result)) { - return array(); + return []; } - $options = array(); + $options = []; $entities = $this->entityManager->getStorage($target_type)->loadMultiple($result); // We assume target and definition are one and the same, as there is no diff --git a/src/Plugin/Field/FieldFormatter/EntityReferenceHierarchyLabelFormatter.php b/src/Plugin/Field/FieldFormatter/EntityReferenceHierarchyLabelFormatter.php index 0e6ee8d365fe701d49fcec28fd2dd955700e6610..510aeb6fd82911f72b10dd3029ea931c9cbeac6a 100644 --- a/src/Plugin/Field/FieldFormatter/EntityReferenceHierarchyLabelFormatter.php +++ b/src/Plugin/Field/FieldFormatter/EntityReferenceHierarchyLabelFormatter.php @@ -25,7 +25,7 @@ class EntityReferenceHierarchyLabelFormatter extends EntityReferenceLabelFormatt */ public function settingsForm(array $form, FormStateInterface $form_state) { $elements = parent::settingsForm($form, $form_state); - $elements['weight_output'] = array( + $elements['weight_output'] = [ '#type' => 'radios', '#options' => [ 'suffix' => t('After title'), @@ -34,7 +34,7 @@ class EntityReferenceHierarchyLabelFormatter extends EntityReferenceLabelFormatt '#title' => t('Output weigh'), '#default_value' => $this->getSetting('weight_output'), '#required' => TRUE, - ); + ]; return $elements; } @@ -54,7 +54,7 @@ class EntityReferenceHierarchyLabelFormatter extends EntityReferenceLabelFormatt $action = t('suffix after title'); break; } - $summary[] = t('Show weight as @action', array('@action' => $action)); + $summary[] = t('Show weight as @action', ['@action' => $action]); return $summary; } diff --git a/src/Plugin/Field/FieldType/EntityReferenceHierarchy.php b/src/Plugin/Field/FieldType/EntityReferenceHierarchy.php index 8f3facf8995b1cd2bbb8df1200f1be1a71e93c60..0598bbea8b4dc6c61eff4f97a8b310ed5a1c978e 100644 --- a/src/Plugin/Field/FieldType/EntityReferenceHierarchy.php +++ b/src/Plugin/Field/FieldType/EntityReferenceHierarchy.php @@ -54,10 +54,10 @@ class EntityReferenceHierarchy extends EntityReferenceItem { */ public static function schema(FieldStorageDefinitionInterface $field_definition) { $schema = parent::schema($field_definition); - $schema['columns']['weight'] = array( + $schema['columns']['weight'] = [ 'type' => 'int', 'unsigned' => FALSE, - ); + ]; return $schema; } @@ -65,11 +65,11 @@ class EntityReferenceHierarchy extends EntityReferenceItem { * {@inheritdoc} */ public static function defaultFieldSettings() { - return array( + return [ 'weight_label' => t('Weight'), 'weight_min' => self::HIERARCHY_MIN_CHILD_WEIGHT, 'weight_max' => self::HIERARCHY_MAX_CHILD_WEIGHT, - ) + parent::defaultFieldSettings(); + ] + parent::defaultFieldSettings(); } /** @@ -106,7 +106,7 @@ class EntityReferenceHierarchy extends EntityReferenceItem { // list of field-types with options for each destination entity type. // Too much work, we'll just make people fill that out later. // Also, keeps the field type dropdown from getting too cluttered. - return array(); + return []; } /** diff --git a/src/Plugin/Field/FieldWidget/EntityReferenceHierarchySelect.php b/src/Plugin/Field/FieldWidget/EntityReferenceHierarchySelect.php index 8eed6627d33a9aa45a354a5f7dd8d907024bace9..c095b10595d6131552b28e975bf799073bd8d635 100644 --- a/src/Plugin/Field/FieldWidget/EntityReferenceHierarchySelect.php +++ b/src/Plugin/Field/FieldWidget/EntityReferenceHierarchySelect.php @@ -26,24 +26,24 @@ class EntityReferenceHierarchySelect extends OptionsWidgetBase { */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element = parent::formElement($items, $delta, $element, $form, $form_state); - $element += array( + $element += [ '#type' => 'select', '#options' => $this->getOptions($items->getEntity()), '#default_value' => isset($items[$delta]->target_id) ? $items[$delta]->target_id : '', - ); + ]; - $widget = array( + $widget = [ '#attributes' => ['class' => ['form--inline', 'clearfix']], '#theme_wrappers' => ['container'], - ); + ]; $widget['target_id'] = $element; - $widget['weight'] = array( + $widget['weight'] = [ '#type' => 'number', '#size' => '4', '#default_value' => isset($items[$delta]) ? $items[$delta]->weight : 1, '#weight' => 10, - ); + ]; kint($widget); if ($this->fieldDefinition->getFieldStorageDefinition()->isMultiple()) { @@ -92,7 +92,7 @@ class EntityReferenceHierarchySelect extends OptionsWidgetBase { public static function validateElement(array $element, FormStateInterface $form_state) { if ($element['#value'] == '_none') { if ($element['#required'] && $element['#value'] == '_none') { - $form_state->setError($element, t('@name field is required.', array('@name' => $element['#title']))); + $form_state->setError($element, t('@name field is required.', ['@name' => $element['#title']])); } else { $form_state->setValueForElement($element, NULL); diff --git a/src/Plugin/views/argument/HierarchyIsChildOfEntity.php b/src/Plugin/views/argument/HierarchyIsChildOfEntity.php index e85a4bfb5944ec919c6de87302ef175fecaea8d5..b1ab80ef0bc9cd13864b3bf31c818e9181f13c2f 100644 --- a/src/Plugin/views/argument/HierarchyIsChildOfEntity.php +++ b/src/Plugin/views/argument/HierarchyIsChildOfEntity.php @@ -64,6 +64,8 @@ class HierarchyIsChildOfEntity extends ArgumentPluginBase { * Entity type manager. * @param \Drupal\entity_hierarchy\Storage\NestedSetNodeKeyFactory $nodeKeyFactory * Node key factory. + * @param \Drupal\Core\Database\Connection $database + * Database connection. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, NestedSetStorageFactory $nestedSetStorageFactory, EntityTypeManagerInterface $entityTypeManager, NestedSetNodeKeyFactory $nodeKeyFactory, Connection $database) { parent::__construct($configuration, $plugin_id, $plugin_definition); @@ -167,7 +169,7 @@ class HierarchyIsChildOfEntity extends ArgumentPluginBase { $options = parent::defineOptions(); // Allow filtering depth as well. - $options['depth'] = array('default' => 0); + $options['depth'] = ['default' => 0]; return $options; } diff --git a/tests/src/Functional/HideWeightFieldFunctionalTest.php b/tests/src/Functional/HideWeightFieldFunctionalTest.php index c90852d4a21ff01ee65348efd10cbe328ba234d6..a636abc68bc95552e6c96751fc218b6e570ab15f 100644 --- a/tests/src/Functional/HideWeightFieldFunctionalTest.php +++ b/tests/src/Functional/HideWeightFieldFunctionalTest.php @@ -39,10 +39,10 @@ class HideWeightFieldFunctionalTest extends BrowserTestBase { $this->setupEntityHierarchyField(static::ENTITY_TYPE, static::ENTITY_TYPE, static::FIELD_NAME); $this->additionalSetup(); $this->getEntityFormDisplay(self::ENTITY_TYPE, self::ENTITY_TYPE, 'default') - ->setComponent(self::FIELD_NAME, array( + ->setComponent(self::FIELD_NAME, [ 'type' => 'entity_reference_hierarchy_autocomplete', 'weight' => 20, - )) + ]) ->save(); }