Now all available FrontendUser records are returned. When you now loop over the queryResult, you will see, that the FrontendUser Objects returned do not contain any information about if the record actually is hidden or deleted.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function listAction() | |
{ | |
/** @var \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings $querySettings */ | |
$querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class); | |
$querySettings->setRespectStoragePage(false); | |
$querySettings->setIgnoreEnableFields(true); | |
$querySettings->setIncludeDeleted(true); | |
$this->frontendUserRepository->setDefaultQuerySettings($querySettings); | |
$users = $this->frontendUserRepository->findAll(); | |
$this->view->assign('users', $users); | |
} |
Note that the example above shows the assignment of the defaultQuerySettings directly in an action. Typically you define this in the initializeObject method or directly in the repository.
In order to obtain those information, you need to extend the existing FrontendUser domain model with two fields. First, you need to create an own domain model with two properties as shown below (must be located in a extension - usually your own).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Vender\Extension\Domain\Model; | |
class FrontendUser extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser | |
{ | |
/** | |
* @var bool | |
*/ | |
protected $disable; | |
/** | |
* @var bool | |
*/ | |
protected $deleted; | |
/** | |
* @return bool | |
*/ | |
public function getDisable() | |
{ | |
return $this->disable; | |
} | |
/** | |
* @param bool $disable | |
*/ | |
public function setDisable($disable) | |
{ | |
$this->disable = $disable; | |
} | |
/** | |
* @return bool | |
*/ | |
public function getDeleted() | |
{ | |
return $this->deleted; | |
} | |
/** | |
* @param bool $deleted | |
*/ | |
public function setDeleted($deleted) | |
{ | |
$this->deleted = $deleted; | |
} | |
} |
Next you need to add the new fields to the TCA by adding the file fe_users.php with the following content to the folder Configuration/TCA/Overrides.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('TYPO3_MODE') or die(); | |
$fields = array ( | |
'deleted' => array( | |
'exclude' => 1, | |
'label' => 'Deleted', | |
'config' => array( | |
'type' => 'check', | |
), | |
), | |
'disable' => array( | |
'exclude' => 1, | |
'label' => 'Disabled (hidden)', | |
'config' => array( | |
'type' => 'check', | |
), | |
) | |
); | |
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('fe_users', $fields); | |
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('fe_users', 'deleted, disable', '', ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.tx_extbase{ | |
persistence { | |
classes { | |
TYPO3\CMS\Extbase\Domain\Model\FrontendUser { | |
subclasses { | |
0 = Vendor\Extension\Domain\Model\FrontendUser | |
} | |
} | |
Vendor\Extension\Domain\Model\FrontendUser { | |
mapping { | |
tableName = fe_users | |
recordType = 0 | |
columns { | |
deleted.mapOnProperty = deleted | |
disable.mapOnProperty = disable | |
} | |
} | |
} | |
} | |
} | |
} |
After clearing all caches, ExtBase now returns all FrontendUsers containing the two new properties "deleted" and "disable"