SpriteIconForRecordViewHelper.php 1.65 KB
Newer Older
1
<?php
2
3
namespace TYPO3\CMS\Beuser\ViewHelpers;

4
5
/**
 * This file is part of the TYPO3 CMS project.
6
 *
7
8
9
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
10
 *
11
12
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
15
 * The TYPO3 project - inspiring people to share!
 */
16

17
18
19
20
21
/**
 * Views sprite icon for a record (object)
 *
 * @author Felix Kopp <felix-source@phorax.com>
 */
22
class SpriteIconForRecordViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper {
23
24
25
26
27
28
29

	/**
	 * Displays spriteIcon for database table and object
	 *
	 * @param string $table
	 * @param object $object
	 * @return string
30
	 * @see \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $row)
31
32
33
34
35
36
37
38
	 */
	public function render($table, $object) {
		if (!is_object($object) || !method_exists($object, 'getUid')) {
			return '';
		}
		$row = array(
			'uid' => $object->getUid(),
			'startTime' => FALSE,
39
			'endTime' => FALSE
40
41
42
43
		);
		if (method_exists($object, 'getIsDisabled')) {
			$row['disable'] = $object->getIsDisabled();
		}
44
		if ($table === 'be_users' && $object instanceof \TYPO3\CMS\Beuser\Domain\Model\BackendUser) {
45
46
47
48
49
50
51
52
			$row['admin'] = $object->getIsAdministrator();
		}
		if (method_exists($object, 'getStartDateAndTime')) {
			$row['startTime'] = $object->getStartDateAndTime();
		}
		if (method_exists($object, 'getEndDateAndTime')) {
			$row['endTime'] = $object->getEndDateAndTime();
		}
53
		return \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $row);
54
55
56
	}

}