TYPO3 CMS  TYPO3_7-6
AbstractController.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 {
26  protected $dataMapFactory;
27 
33  public function processRequest(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
34  {
35  try {
36  parent::processRequest($request, $response);
37  } catch (\TYPO3\CMS\Extbase\Property\Exception $exception) {
38  throw new \RuntimeException(
39  $this->getRuntimeIdentifier() . ': ' . $exception->getMessage() . ' (' . $exception->getCode() . ')'
40  );
41  }
42  }
43 
48  protected function getStructure($iterator)
49  {
50  $structure = [];
51 
52  if (!$iterator instanceof \Iterator) {
53  $iterator = [$iterator];
54  }
55 
56  foreach ($iterator as $entity) {
57  $dataMap = $this->dataMapFactory->buildDataMap(get_class($entity));
58  $tableName = $dataMap->getTableName();
59  $identifier = $tableName . ':' . $entity->getUid();
61 
62  $structureItem = [];
63  foreach ($properties as $propertyName => $propertyValue) {
64  $columnMap = $dataMap->getColumnMap($propertyName);
65  if ($columnMap !== null) {
66  $propertyName = $columnMap->getColumnName();
67  }
68  if ($propertyValue instanceof \Iterator) {
69  $structureItem[$propertyName] = $this->getStructure($propertyValue);
70  } else {
71  $structureItem[$propertyName] = $propertyValue;
72  }
73  }
74  $structure[$identifier] = $structureItem;
75  }
76 
77  return $structure;
78  }
79 
83  protected function process($value)
84  {
85  if ($this->getQueueService()->isActive()) {
86  $this->getQueueService()->addValue($this->getRuntimeIdentifier(), $value);
87  $this->forward('process', 'Queue');
88  }
89  $this->view->assign('value', $value);
90  }
91 
95  protected function getRuntimeIdentifier()
96  {
97  $arguments = [];
98  foreach ($this->request->getArguments() as $argumentName => $argumentValue) {
99  $arguments[] = $argumentName . '=' . $argumentValue;
100  }
101  return $this->request->getControllerActionName() . '(' . implode(', ', $arguments) . ')';
102  }
103 
107  protected function getPersistenceManager()
108  {
109  return $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class);
110  }
111 
115  protected function getQueueService()
116  {
117  return $this->objectManager->get(\OliverHader\IrreTutorial\Service\QueueService::class);
118  }
119 }
processRequest(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
forward($actionName, $controllerName=null, $extensionName=null, array $arguments=null)