[BUGFIX] Supply returnURL to EXT:beuser usergroups
[Packages/TYPO3.CMS.git] / typo3 / sysext / beuser / Classes / ViewHelpers / SpriteIconForRecordViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Beuser\ViewHelpers;
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
17 use TYPO3\CMS\Core\Imaging\Icon;
18 use TYPO3\CMS\Core\Imaging\IconFactory;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Extbase\Domain\Model\BackendUser;
21 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
22 use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
23 use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper;
24
25 /**
26 * Views sprite icon for a record (object)
27 * @internal
28 */
29 class SpriteIconForRecordViewHelper extends AbstractBackendViewHelper implements CompilableInterface
30 {
31 /**
32 * Displays spriteIcon for database table and object
33 *
34 * @param string $table
35 * @param object $object
36 * @return string
37 * @see IconFactory::getIconForRecord()
38 */
39 public function render($table, $object)
40 {
41 return static::renderStatic(
42 array(
43 'table' => $table,
44 'object' => $object
45 ),
46 $this->buildRenderChildrenClosure(),
47 $this->renderingContext
48 );
49 }
50
51 /**
52 * @param array $arguments
53 * @param callable $renderChildrenClosure
54 * @param RenderingContextInterface $renderingContext
55 *
56 * @return string
57 * @throws Exception
58 */
59 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
60 {
61 $object = $arguments['object'];
62 $table = $arguments['table'];
63
64 if (!is_object($object) || !method_exists($object, 'getUid')) {
65 return '';
66 }
67 $row = array(
68 'uid' => $object->getUid(),
69 'startTime' => false,
70 'endTime' => false
71 );
72 if (method_exists($object, 'getIsDisabled')) {
73 $row['disable'] = $object->getIsDisabled();
74 }
75 if (method_exists($object, 'getHidden')) {
76 $row['hidden'] = $object->getHidden();
77 }
78 if ($table === 'be_users' && $object instanceof BackendUser) {
79 $row['admin'] = $object->getIsAdministrator();
80 }
81 if (method_exists($object, 'getStartDateAndTime')) {
82 $row['startTime'] = $object->getStartDateAndTime();
83 }
84 if (method_exists($object, 'getEndDateAndTime')) {
85 $row['endTime'] = $object->getEndDateAndTime();
86 }
87 /** @var IconFactory $iconFactory */
88 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
89 return $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render();
90 }
91 }