Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
Sort Class Reference
Inheritance diagram for Sort:
SortInterface

Public Member Functions

 sort (array $array)
 

Data Fields

const DIRECTIVE = 'after'
 
const NEXT_KEY = 'next'
 

Detailed Description

Class Sort

Definition at line 11 of file Sort.php.

Member Function Documentation

◆ sort()

sort ( array  $array)

Sorting an array by directive [ 'name-1' => ['after' => 'xxx', 'data' => [...]] 'name-2' => ['after' => 'xxx', 'data' => [...]] ]

Parameters
array$array
Returns
array

Implements SortInterface.

Definition at line 36 of file Sort.php.

37  {
38  $this->result = [];
39  $this->array = $array;
40 
41  $nodes = [];
42  $structure = [];
43  foreach ($this->array as $name => $item) {
44  $nodes[$name] = isset($nodes[$name]) ? $nodes[$name] : [self::NEXT_KEY => null];
45  if (isset($item[self::DIRECTIVE])) {
46  $nodes[$item[self::DIRECTIVE]][self::NEXT_KEY][$name] = &$nodes[$name];
47  continue;
48  }
49  $structure[$name] = &$nodes[$name];
50  }
51 
52  $this->fillResult($structure);
53 
54  return $this->result;
55  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

Field Documentation

◆ DIRECTIVE

const DIRECTIVE = 'after'

Name of directive

Definition at line 16 of file Sort.php.

◆ NEXT_KEY

const NEXT_KEY = 'next'

Key of name items

Definition at line 21 of file Sort.php.


The documentation for this class was generated from the following file: