dataFromArray($data); } } /** * Sorts the internal nodes array * * @param int $flags Optional parameter, ignored. Added to be compatible with asort method signature in PHP 8. */ public function asort(int $flags = SORT_REGULAR): true { $this->uasort($this->nodeCompare(...)); return true; } /** * Compares a node with another one * * @see \TYPO3\CMS\Backend\Tree\TreeNode::compareTo * @internal */ public function nodeCompare(TreeNode $node, TreeNode $otherNode): int { return $node->compareTo($otherNode); } /** * Returns class state to be serialized. */ public function __serialize(): array { return $this->toArray(); } /** * Fills the current node with the given serialized information * * @throws Exception if the deserialized object type is not identical to the current one */ public function __unserialize($data): void { if ($data['serializeClassName'] !== static::class) { throw new Exception('Deserialized object type is not identical!', 1294586647); } $this->dataFromArray($data); } /** * Returns the collection in an array representation for e.g. serialization */ public function toArray(): array { $arrayRepresentation = [ 'serializeClassName' => static::class, ]; $iterator = $this->getIterator(); while ($iterator->valid()) { $arrayRepresentation[] = $iterator->current()->toArray(); $iterator->next(); } return $arrayRepresentation; } /** * Sets the data of the node collection by a given array */ public function dataFromArray(array $data): void { unset($data['serializeClassName']); foreach ($data as $index => $nodeArray) { $node = GeneralUtility::makeInstance($nodeArray['serializeClassName'], $nodeArray); $this->offsetSet($index, $node); } } }