duanbing6955 2018-05-25 10:24
浏览 67

Typo3:扩展tt_content,Repo返回空的QueryResultInterface

I extended the tt_content table with an relationship to the tags of the news extension. (So I can Tag all tt_content elements.)

The methods like findAll and findByUid always return an empty QueryResultInterface.

I created the extension with extensionbuilder. I defined the Storage in the extensions right and ignore the storage on own methods.

ext_typoscript_setup.txt:

config.tx_extbase {
  persistence {
    classes {

      EXAMP\ExampContentTagging\Domain\Model\ContentTagRelation {
        mapping {
          tableName = tt_content
          recordType = Tx_ExampContentTagging_ContentTagRelation
        }
      }

    }
  }
}

ContentTagRelationRepository.php:

<?php
namespace EXAMP\ExampContentTagging\Domain\Repository;

/**
 * The repository for ContentTagRelations
 */
class ContentTagRelationRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
    /**
     * @var array
     */
    protected $defaultOrderings = array(
        'sorting' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
    );



    /**
     * Find tt_content by a given pid
     *
     * @param array $includeIdList list of id s
     * @param array $excludeIdList list of id s
     * @return QueryInterface
     */
    public function findByTagIdList(array $includeIdList, array $excludeIdList = [])
    {
        $query = $this->createQuery();

        $query->getQuerySettings()->setRespectStoragePage(false);
        $query->getQuerySettings()->setRespectSysLanguage(false);

        return $query->execute();
}

TCA/Overrides/tt_content.php:

defined('TYPO3_MODE') || die();

if (!isset($GLOBALS['TCA']['tt_content']['ctrl']['type'])) {
    if (file_exists($GLOBALS['TCA']['tt_content']['ctrl']['dynamicConfigFile'])) {
        require_once($GLOBALS['TCA']['tt_content']['ctrl']['dynamicConfigFile']);
    }
    // no type field defined, so we define it here. This will only happen the first time the extension is installed!!
    $GLOBALS['TCA']['tt_content']['ctrl']['type'] = 'tx_extbase_type';
    $tempColumnstx_exampcontenttagging_tt_content = [];
    $tempColumnstx_exampcontenttagging_tt_content[$GLOBALS['TCA']['tt_content']['ctrl']['type']] = [
        'exclude' => true,
        'label'   => 'LLL:EXT:examp_content_tagging/Resources/Private/Language/locallang_db.xlf:tx_exampcontenttagging.tx_extbase_type',
        'config' => [
            'type' => 'select',
            'renderType' => 'selectSingle',
            'items' => [
                ['ContentTagRelation','Tx_exampContentTagging_ContentTagRelation']
            ],
            'default' => 'Tx_exampContentTagging_ContentTagRelation',
            'size' => 1,
            'maxitems' => 1,
        ]
    ];
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $tempColumnstx_exampcontenttagging_tt_content);
}


\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
    'tt_content',
    'tx_news_domain_model_tag'
);


$tmp_examp_content_tagging_columns = [

    'tx_news_domain_model_tag' => [
        'exclude' => true,
        'label' => 'LLL:EXT:examp_content_tagging/Resources/Private/Language/locallang_db.xlf:tx_exampcontenttagging_domain_model_contenttagrelation.tx_news_domain_model_tag',
        'config' => [
            'type' => 'select',
            'renderType' => 'selectMultipleSideBySide',
            'foreign_table' => 'tx_news_domain_model_tag',
            'MM' => 'tx_exampcontenttagging_contenttagrelation_tag_mm',
            'size' => 10,
            'autoSizeMax' => 30,
            'maxitems' => 9999,
            'multiple' => 0,
            'wizards' => [
                '_PADDING' => 1,
                '_VERTICAL' => 1,
                'edit' => [
                    'module' => [
                        'name' => 'wizard_edit',
                    ],
                    'type' => 'popup',
                    'title' => 'Edit', // todo define label: LLL:EXT:.../Resources/Private/Language/locallang_tca.xlf:wizard.edit
                    'icon' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_edit.gif',
                    'popup_onlyOpenIfSelected' => 1,
                    'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',
                ],
                'add' => [
                    'module' => [
                        'name' => 'wizard_add',
                    ],
                    'type' => 'script',
                    'title' => 'Create new', // todo define label: LLL:EXT:.../Resources/Private/Language/locallang_tca.xlf:wizard.add
                    'icon' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_add.gif',
                    'params' => [
                        'table' => 'tx_news_domain_model_tag',
                        'pid' => '###CURRENT_PID###',
                        'setValue' => 'prepend'
                    ],
                ],
            ],
        ],
    ],
];

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content',$tmp_examp_content_tagging_columns);

/* inherit and extend the show items from the parent class */

if (isset($GLOBALS['TCA']['tt_content']['types']['1']['showitem'])) {
    $GLOBALS['TCA']['tt_content']['types']['Tx_exampContentTagging_ContentTagRelation']['showitem'] = $GLOBALS['TCA']['tt_content']['types']['1']['showitem'];
} elseif(is_array($GLOBALS['TCA']['tt_content']['types'])) {
    // use first entry in types array
    $tt_content_type_definition = reset($GLOBALS['TCA']['tt_content']['types']);
    $GLOBALS['TCA']['tt_content']['types']['Tx_exampContentTagging_ContentTagRelation']['showitem'] = $tt_content_type_definition['showitem'];
} else {
    $GLOBALS['TCA']['tt_content']['types']['Tx_exampContentTagging_ContentTagRelation']['showitem'] = '';
}
$GLOBALS['TCA']['tt_content']['types']['Tx_exampContentTagging_ContentTagRelation']['showitem'] .= ',--div--;LLL:EXT:examp_content_tagging/Resources/Private/Language/locallang_db.xlf:tx_exampcontenttagging_domain_model_contenttagrelation,';
$GLOBALS['TCA']['tt_content']['types']['Tx_exampContentTagging_ContentTagRelation']['showitem'] .= 'tx_news_domain_model_tag';

$GLOBALS['TCA']['tt_content']['columns'][$GLOBALS['TCA']['tt_content']['ctrl']['type']]['config']['items'][] = ['LLL:EXT:examp_content_tagging/Resources/Private/Language/locallang_db.xlf:tt_content.tx_extbase_type.Tx_exampContentTagging_ContentTagRelation','Tx_exampContentTagging_ContentTagRelation'];

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr(
    '',
    'EXT:/Resources/Private/Language/locallang_csh_.xlf'
);

Mostly to this problem, the solution is to check if the right storage is set. But I did this and still have the problem. So I think tt_content is the problem. But the only thing I could find to this was:

"tt_content is special."

Which dosen't help. (Offtopic: This Typo3 Documentation makes me mad every time I've to look into it.)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 本题的答案是不是有问题
    • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
    • ¥15 C++使用Gunplot
    • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
    • ¥15 Arcgis相交分析无法绘制一个或多个图形