TYPO3 CMS  TYPO3_7-6
ResponseSection.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $identifier;
26 
30  protected $structure;
31 
35  protected $structurePaths;
36 
40  protected $records;
41 
45  protected $queries;
46 
51  public function __construct($identifier, array $data)
52  {
53  $this->identifier = (string)$identifier;
54  $this->structure = $data['structure'];
55  $this->structurePaths = $data['structurePaths'];
56  $this->records = $data['records'];
57 
58  if (!empty($data['queries'])) {
59  $this->queries = $data['queries'];
60  }
61  }
62 
66  public function getIdentifier()
67  {
68  return $this->identifier;
69  }
70 
74  public function getStructure()
75  {
76  return $this->structure;
77  }
78 
82  public function getStructurePaths()
83  {
84  return $this->structurePaths;
85  }
86 
90  public function getRecords()
91  {
92  return $this->records;
93  }
94 
98  public function getQueries()
99  {
100  return $this->queries;
101  }
102 
108  public function findStructures($recordIdentifier, $fieldName = '')
109  {
110  $structures = [];
111 
112  if (empty($this->structurePaths[$recordIdentifier])) {
113  return $structures;
114  }
115 
116  foreach ($this->structurePaths[$recordIdentifier] as $steps) {
118  $steps[] = $recordIdentifier;
119 
120  if (!empty($fieldName)) {
121  $steps[] = $fieldName;
122  }
123 
124  foreach ($steps as $step) {
125  if (!isset($structure[$step])) {
126  $structure = null;
127  break;
128  }
129  $structure = $structure[$step];
130  }
131 
132  if (!empty($structure)) {
133  $structures[implode('/', $steps)] = $structure;
134  }
135  }
136 
137  return $structures;
138  }
139 }