TYPO3 CMS  TYPO3_8-7
AvatarViewHelper.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 
28 {
30 
36  protected $escapeOutput = false;
37 
41  public function initializeArguments()
42  {
43  parent::initializeArguments();
44  $this->registerArgument('backendUser', 'int', 'uid of the backend user', false, 0);
45  $this->registerArgument('size', 'int', 'width and height of the image', false, 32);
46  $this->registerArgument('showIcon', 'bool', 'show the record icon as well', false, false);
47  }
48 
57  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
58  {
59  if ($arguments['backendUser'] > 0) {
60  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
61  $queryBuilder->getRestrictions()->removeAll();
62  $backendUser = $queryBuilder
63  ->select('*')
64  ->from('be_users')
65  ->where(
66  $queryBuilder->expr()->eq(
67  'uid',
68  $queryBuilder->createNamedParameter($arguments['backendUser'], \PDO::PARAM_INT)
69  )
70  )
71  ->execute()
72  ->fetch();
73  } else {
74  $backendUser = $GLOBALS['BE_USER']->user;
75  }
76  if ($backendUser === false) {
77  // no BE user can be retrieved from DB, probably deleted
78  return '';
79  }
80  $avatar = GeneralUtility::makeInstance(Avatar::class);
81  return $avatar->render($backendUser, $arguments['size'], $arguments['showIcon']);
82  }
83 }
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']