TYPO3 CMS  TYPO3_6-2
Parser.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $paths = array();
26 
30  protected $records = array();
31 
35  public function getPaths() {
36  return $this->paths;
37  }
38 
42  public function getRecords() {
43  return $this->records;
44  }
45 
50  public function parse(array $structure, array $path = array()) {
51  $this->process($structure);
52  }
53 
58  protected function process(array $iterator, array $path = array()) {
59  foreach ($iterator as $identifier => $properties) {
60  $this->addRecord($identifier, $properties);
61  $this->addPath($identifier, $path);
62  foreach ($properties as $propertyName => $propertyValue) {
63  if (!is_array($propertyValue)) {
64  continue;
65  }
66  $nestedPath = array_merge($path, array($identifier, $propertyName));
67  $this->process($propertyValue, $nestedPath);
68  }
69  }
70  }
71 
76  protected function addRecord($identifier, array $properties) {
77  if (isset($this->records[$identifier])) {
78  return;
79  }
80 
81  foreach ($properties as $propertyName => $propertyValue) {
82  if (is_array($propertyValue)) {
83  unset($properties[$propertyName]);
84  }
85  }
86 
87  $this->records[$identifier] = $properties;
88  }
89 
94  protected function addPath($identifier, array $path) {
95  if (!isset($this->paths[$identifier])) {
96  $this->paths[$identifier] = array();
97  }
98 
99  $this->paths[$identifier][] = $path;
100  }
101 
102 }
process(array $iterator, array $path=array())
Definition: Parser.php:58
parse(array $structure, array $path=array())
Definition: Parser.php:50