‪TYPO3CMS  9.5
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 
22 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
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 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:29
‪TYPO3\CMS\Beuser\ViewHelpers\SpriteIconForRecordViewHelper\render
‪string render()
Definition: SpriteIconForRecordViewHelper.php:52
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:25
‪TYPO3\CMS\Beuser\ViewHelpers
Definition: ArrayElementViewHelper.php:2
‪TYPO3\CMS\Beuser\ViewHelpers\SpriteIconForRecordViewHelper\initializeArguments
‪initializeArguments()
Definition: SpriteIconForRecordViewHelper.php:39
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:31
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:27
‪TYPO3\CMS\Beuser\ViewHelpers\SpriteIconForRecordViewHelper
Definition: SpriteIconForRecordViewHelper.php:29
‪TYPO3\CMS\Beuser\ViewHelpers\SpriteIconForRecordViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: SpriteIconForRecordViewHelper.php:65
‪TYPO3\CMS\Beuser\Domain\Model\BackendUser
Definition: BackendUser.php:22
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Beuser\ViewHelpers\SpriteIconForRecordViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: SpriteIconForRecordViewHelper.php:34
‪TYPO3\CMS\Extbase\Domain\Model\BackendUser
Definition: BackendUser.php:23