gpt4 book ai didi

repository - EXTBASE:如何获取隐藏记录

转载 作者:行者123 更新时间:2023-12-04 21:58:06 27 4
gpt4 key购买 nike

如何在前端获取隐藏记录?想要获取隐藏记录,然后将隐藏更改为 0。

最佳答案

您可以在存储库中为单一方法进行此设置:

namespace Vendor\ExtensionName\Domain\Repository;

use TYPO3\CMS\Extbase\Persistence\Repository;

/**
* Some Repository
*/
class SomeRepository extends Repository
{
/**
* Find a record by uid even if it is hidden or deleted
*
* @param int $uid
* @return object
*/
public function findHiddenByUid($uid)
{
$query = $this->createQuery();

// Here you enable the hidden and deleted Records
$query->getQuerySettings()
->setIgnoreEnableFields(true)
->setIncludeDeleted(true);

// Your query
$query->matching($query->equals('uid', $uid));
return $query->execute()->getFirst();
}
}

或者对于整个存储库。这包括您从 TYPO3\CMS\Extbase\Persistence\Repository 继承的方法。 :

namespace Vendor\ExtensionName\Domain\Repository;

use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;

/**
* Some Repository
*/
class SomeRepository extends Repository
{
/**
* Always return hidden and deleted records from this Repository
*/
public function initializeObject()
{
// Load the querySettings
$querySettings = $this->objectManager->get(Typo3QuerySettings::class);

// Ignore hidden and deleted records
$querySettings
->setIgnoreEnableFields(true)
->setIncludeDeleted(true);

// Set your settings as default for the entire Repository
$this->setDefaultQuerySettings($querySettings);
}
}

关于repository - EXTBASE:如何获取隐藏记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19164129/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com