‪TYPO3CMS  10.4
SpriteIconForRecordViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
23 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
24 
30 {
36  protected ‪$escapeOutput = false;
37 
41  public function ‪initializeArguments()
42  {
43  parent::initializeArguments();
44  $this->registerArgument('table', 'string', '', true);
45  $this->registerArgument('object', 'object', '', true);
46  }
47 
54  public function ‪render()
55  {
56  return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
57  }
58 
67  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
68  {
69  $object = $arguments['object'];
70  $table = $arguments['table'];
71 
72  if (!is_object($object) || !method_exists($object, 'getUid')) {
73  return '';
74  }
75  $row = [
76  'uid' => $object->getUid(),
77  'startTime' => false,
78  'endTime' => false
79  ];
80  if (method_exists($object, 'getIsDisabled')) {
81  $row['disable'] = $object->getIsDisabled();
82  }
83  if (method_exists($object, 'getHidden')) {
84  $row['hidden'] = $object->getHidden();
85  }
86  if ($table === 'be_users' && $object instanceof ‪BackendUser) {
87  $row['admin'] = $object->getIsAdministrator();
88  }
89  if (method_exists($object, 'getStartDateAndTime')) {
90  $row['startTime'] = $object->getStartDateAndTime();
91  }
92  if (method_exists($object, 'getEndDateAndTime')) {
93  $row['endTime'] = $object->getEndDateAndTime();
94  }
96  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
97  return $iconFactory->getIconForRecord($table, $row, ‪Icon::SIZE_SMALL)->render();
98  }
99 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Beuser\ViewHelpers\SpriteIconForRecordViewHelper\render
‪string render()
Definition: SpriteIconForRecordViewHelper.php:53
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Beuser\ViewHelpers
Definition: ArrayElementViewHelper.php:16
‪TYPO3\CMS\Beuser\ViewHelpers\SpriteIconForRecordViewHelper\initializeArguments
‪initializeArguments()
Definition: SpriteIconForRecordViewHelper.php:40
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:28
‪TYPO3\CMS\Beuser\ViewHelpers\SpriteIconForRecordViewHelper
Definition: SpriteIconForRecordViewHelper.php:30
‪TYPO3\CMS\Beuser\ViewHelpers\SpriteIconForRecordViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: SpriteIconForRecordViewHelper.php:66
‪TYPO3\CMS\Beuser\Domain\Model\BackendUser
Definition: BackendUser.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Beuser\ViewHelpers\SpriteIconForRecordViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: SpriteIconForRecordViewHelper.php:35
‪TYPO3\CMS\Extbase\Domain\Model\BackendUser
Definition: BackendUser.php:25