TYPO3 CMS  TYPO3_8-7
SpriteIconForRecordViewHelper.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 
23 
29 {
35  protected $escapeOutput = false;
36 
40  public function initializeArguments()
41  {
42  parent::initializeArguments();
43  $this->registerArgument('table', 'string', '', true);
44  $this->registerArgument('object', 'object', '', true);
45  }
46 
53  public function render()
54  {
55  return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
56  }
57 
66  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
67  {
68  $object = $arguments['object'];
69  $table = $arguments['table'];
70 
71  if (!is_object($object) || !method_exists($object, 'getUid')) {
72  return '';
73  }
74  $row = [
75  'uid' => $object->getUid(),
76  'startTime' => false,
77  'endTime' => false
78  ];
79  if (method_exists($object, 'getIsDisabled')) {
80  $row['disable'] = $object->getIsDisabled();
81  }
82  if (method_exists($object, 'getHidden')) {
83  $row['hidden'] = $object->getHidden();
84  }
85  if ($table === 'be_users' && $object instanceof BackendUser) {
86  $row['admin'] = $object->getIsAdministrator();
87  }
88  if (method_exists($object, 'getStartDateAndTime')) {
89  $row['startTime'] = $object->getStartDateAndTime();
90  }
91  if (method_exists($object, 'getEndDateAndTime')) {
92  $row['endTime'] = $object->getEndDateAndTime();
93  }
95  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
96  return $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render();
97  }
98 }
static makeInstance($className,... $constructorArguments)