Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typo3 6.1 Extbase-选择所有fe用户_Typo3_Frontend_Extbase_Selectall - Fatal编程技术网

Typo3 6.1 Extbase-选择所有fe用户

Typo3 6.1 Extbase-选择所有fe用户,typo3,frontend,extbase,selectall,Typo3,Frontend,Extbase,Selectall,我有一个扩展,我需要获得所有前端用户。 我试过这个: /** * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $feUserRepository */ $feUserRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Domain\\Repositor

我有一个扩展,我需要获得所有前端用户。 我试过这个:

    /**
     * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $feUserRepository
     */
    $feUserRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository' );
    $allUsers = $feUserRepository->findAll();
    $user = $feUserRepository->findByUid( 1 );
findByUid(1)可以工作,但findAll()返回一个空对象。 我做错了什么

更新:

'columns' => array(
        ...

        'fe_users' => array(
            'exclude' => 0,
            'label' => 'LLL:EXT:xx_news/Resources/Private/Language/locallang_db.xlf:tx_xxnews_domain_model_news.fe_users',
            'config' => array(
                'type' => 'select',
                'foreign_table' => 'fe_users',
                'MM' => 'tx_xxnews_news_feuser_mm',
                'size' => 10,
                'autoSizeMax' => 30,
                'maxitems' => 9999,
                'multiple' => 0,
            ),
        ),
        ...
),
class tx_examples_tca {

    /**
     * @var \Vendor\XxNews\Domain\Repository\NewsRepository $newsRepository
     */
    protected $newsRepository;

    /**
     * Class constructor
     */
    public function __construct() {
        $this->newsRepository = new \Vendor\XxNews\Domain\Repository\NewsRepository;
    }

    public function readersInfo($params) {

        /**
         * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $feUserRepository
         */
        $feUserRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository' );
        $allUsers = $feUserRepository->findAll();
        $user = $feUserRepository->findByUid( 1 );

        var_dump( $allUsers ); //EMPTY
        var_dump( $user );     //OK
    }
}
是关于新闻分机的。我在tx_xxnews_domain_model_news和fe_用户之间有一个mm关系,所以我可以跟踪哪些用户访问了哪些新闻

TCA新闻频道:

'columns' => array(
        ...

        'fe_users' => array(
            'exclude' => 0,
            'label' => 'LLL:EXT:xx_news/Resources/Private/Language/locallang_db.xlf:tx_xxnews_domain_model_news.fe_users',
            'config' => array(
                'type' => 'select',
                'foreign_table' => 'fe_users',
                'MM' => 'tx_xxnews_news_feuser_mm',
                'size' => 10,
                'autoSizeMax' => 30,
                'maxitems' => 9999,
                'multiple' => 0,
            ),
        ),
        ...
),
class tx_examples_tca {

    /**
     * @var \Vendor\XxNews\Domain\Repository\NewsRepository $newsRepository
     */
    protected $newsRepository;

    /**
     * Class constructor
     */
    public function __construct() {
        $this->newsRepository = new \Vendor\XxNews\Domain\Repository\NewsRepository;
    }

    public function readersInfo($params) {

        /**
         * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $feUserRepository
         */
        $feUserRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository' );
        $allUsers = $feUserRepository->findAll();
        $user = $feUserRepository->findByUid( 1 );

        var_dump( $allUsers ); //EMPTY
        var_dump( $user );     //OK
    }
}
我必须分别显示访问新闻的用户和未访问新闻的用户,因此我还有两列显示用户定义函数的内容:

'reading_users' => array (
    'exclude' => 0,
    'label' => 'LLL:EXT:xx_news/Resources/Private/Language/locallang_db.xlf:tx_xxnews_domain_model_news.user_info',
    'config' => array (
        'type' => 'user',
        'size' => '30',
        'userFunc' => 'EXT:xx_news/Classes/TCA/class.tx_xxnews_tca.php:tx_examples_tca->readersInfo',
        'parameters' => array(
            'read' => TRUE
        )
    )
),
'not_reading_users' => array (
    'exclude' => 0,
    'label' => 'LLL:EXT:xx_news/Resources/Private/Language/locallang_db.xlf:tx_xxnews_domain_model_news.user_info',
    'config' => array (
        'type' => 'user',
        'size' => '30',
        'userFunc' => 'EXT:xx_news/Classes/TCA/class.tx_xxnews_tca.php:tx_examples_tca->readersInfo',
        'parameters' => array(
            'read' => FALSE
        )
    )
),
class.tx\u xxnews\u tca.php:

'columns' => array(
        ...

        'fe_users' => array(
            'exclude' => 0,
            'label' => 'LLL:EXT:xx_news/Resources/Private/Language/locallang_db.xlf:tx_xxnews_domain_model_news.fe_users',
            'config' => array(
                'type' => 'select',
                'foreign_table' => 'fe_users',
                'MM' => 'tx_xxnews_news_feuser_mm',
                'size' => 10,
                'autoSizeMax' => 30,
                'maxitems' => 9999,
                'multiple' => 0,
            ),
        ),
        ...
),
class tx_examples_tca {

    /**
     * @var \Vendor\XxNews\Domain\Repository\NewsRepository $newsRepository
     */
    protected $newsRepository;

    /**
     * Class constructor
     */
    public function __construct() {
        $this->newsRepository = new \Vendor\XxNews\Domain\Repository\NewsRepository;
    }

    public function readersInfo($params) {

        /**
         * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $feUserRepository
         */
        $feUserRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository' );
        $allUsers = $feUserRepository->findAll();
        $user = $feUserRepository->findByUid( 1 );

        var_dump( $allUsers ); //EMPTY
        var_dump( $user );     //OK
    }
}

谢谢。

问题是,当TYPO3引入Extbase时,前端用户的“记录类型”被集成了。(这只是一个示例,将在6.2 BTW中删除)

您必须将每个前端用户的记录类型设置为扩展的记录类型(它在扩展的ext_tables.php中定义),或者您可以删除(清除)记录类型的必要性

config.tx_extbase.persistence.classes.Vendor/MyExtension/Domain/Model/User.mapping.recordType =
编辑: 顺便说一下,您应该注入存储库,而不是使用makeInstance:

/**
 * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
 * @inject
 */
protected $feUserRepository;

问题是,当TYPO3引入Extbase时,前端用户的“记录类型”被集成了。(这只是一个示例,将在6.2 BTW中删除)

您必须将每个前端用户的记录类型设置为扩展的记录类型(它在扩展的ext_tables.php中定义),或者您可以删除(清除)记录类型的必要性

config.tx_extbase.persistence.classes.Vendor/MyExtension/Domain/Model/User.mapping.recordType =
编辑: 顺便说一下,您应该注入存储库,而不是使用makeInstance:

/**
 * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
 * @inject
 */
protected $feUserRepository;

嗨,洛伦兹。我没有扩展FrontendUser模型,因此没有定义任何记录类型。我用“tx_extbase_Domain_Model_FrontendUser”更新了字段tx_extbase_type,但findAll()仍然没有返回任何内容。我不扩展模型,我只想得到使用核心模型的fe用户列表。谢谢。它是前端还是后端扩展?是否设置了存储PID?它是与fe_用户有mm关系的新闻扩展。请检查更新。在这种情况下,注入似乎不起作用。我试图在NewsController中设置readersInfo方法,但仍然无法通过@inject访问FrontendUser存储库。是否清除了所有缓存?如果做得正确,它必须工作;您可以将存储库插入控制器。嗨,lorenz。我没有扩展FrontendUser模型,因此没有定义任何记录类型。我用“tx_extbase_Domain_Model_FrontendUser”更新了字段tx_extbase_type,但findAll()仍然没有返回任何内容。我不扩展模型,我只想得到使用核心模型的fe用户列表。谢谢。它是前端还是后端扩展?是否设置了存储PID?它是与fe_用户有mm关系的新闻扩展。请检查更新。在这种情况下,注入似乎不起作用。我试图在NewsController中设置readersInfo方法,但仍然无法通过@inject访问FrontendUser存储库。是否清除了所有缓存?如果做得正确,它必须工作;您可以将存储库插入控制器。