You are here

public static function HierarchyChildrenForm::reorder in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 src/Form/HierarchyChildrenForm.php \Drupal\entity_hierarchy\Form\HierarchyChildrenForm::reorder()

Reorder batch callback.

Parameters

string $fieldName: Field name.

\Drupal\Core\Entity\ContentEntityInterface $childEntity: Child entity being updated.

int $weight: New weight.

File

src/Form/HierarchyChildrenForm.php, line 299

Class

HierarchyChildrenForm
Defines a form for re-ordering children.

Namespace

Drupal\entity_hierarchy\Form

Code

public static function reorder($fieldName, ContentEntityInterface $childEntity, $weight) {
  $childEntity->{$fieldName}->weight = $weight;
  $childEntity
    ->save();
}