TYPO3 CMS  TYPO3_6-2
Renderer.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $sections = array();
26 
32  public function parseValues($content, array $configuration = NULL) {
33  if (empty($content)) {
34  return;
35  }
36 
37  $values = json_decode($content, TRUE);
38 
39  if (empty($values) || !is_array($values)) {
40  return;
41  }
42 
43  $asPrefix = (!empty($configuration['as']) ? $configuration['as'] . ':' : NULL);
44  foreach ($values as $identifier => $structure) {
45  $parser = $this->createParser();
46  $parser->parse($structure);
47 
48  $section = array(
49  'structure' => $structure,
50  'structurePaths' => $parser->getPaths(),
51  'records' => $parser->getRecords(),
52  );
53 
54  $this->addSection($section, $asPrefix . $identifier);
55  }
56  }
57 
62  public function addSection(array $section, $as = NULL) {
63  if (!empty($as)) {
64  $this->sections[$as] = $section;
65  } else {
66  $this->sections[] = $section;
67  }
68  }
69 
75  public function renderSections($content, array $configuration = NULL) {
76  $content = json_encode($this->sections);
77  return $content;
78  }
79 
83  protected function createParser() {
84  return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
85  'TYPO3\\CMS\\Core\\Tests\\Functional\\Framework\\Frontend\\Parser'
86  );
87  }
88 
89 }
parseValues($content, array $configuration=NULL)
Definition: Renderer.php:32
renderSections($content, array $configuration=NULL)
Definition: Renderer.php:75