TYPO3 9 Extbase EXT originalResource FileReference всегда равен NULL. Почему?

Я разрабатываю собственное расширение. В этом расширении можно добавлять изображения к элементу контента. В представлении Backend все работает нормально. В БД ссылка sys_file на мою таблицу базы данных через sys_file_reference тоже выглядит хорошо. Но когда я делаю {_all} в шаблоне, исходный ресурс файла равен NULL.

Может кто-нибудь сказать мне, что мне не хватает?

Вот код моего расширения: ext_tables.sql

#
# Table structure for table 'tx_redspaceproduct_domain_model_product'
#
CREATE TABLE tx_redspaceproduct_domain_model_product (

uid int(11) unsigned NOT NULL AUTO_INCREMENT,
pid int(11) unsigned DEFAULT '0' NOT NULL,

number int(5) DEFAULT '0' NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
slug varchar(255) DEFAULT '' NOT NULL,
subname varchar(255) DEFAULT '' NOT NULL,
image int(11) unsigned NOT NULL default '0',
flyer int(11) unsigned NOT NULL default '0',
featureteaser text DEFAULT '',
description text DEFAULT '',
specifications text DEFAULT '',
features text DEFAULT '',
accuracy text DEFAULT '',
category int(11) unsigned DEFAULT '0' NOT NULL,
type int(11) unsigned DEFAULT '0' NOT NULL,
sibling int(11) unsigned DEFAULT '0' NOT NULL,
related int(11) unsigned DEFAULT '0' NOT NULL,
accessory int(11) unsigned DEFAULT '0' NOT NULL,
package int(11) unsigned DEFAULT '0' NOT NULL,
download int(11) unsigned DEFAULT '0' NOT NULL,

hidden int(1) unsigned DEFAULT '0' NOT NULL,
deleted int(1) unsigned DEFAULT '0' NOT NULL,

PRIMARY KEY (uid),
FOREIGN KEY (category) REFERENCES tx_redspaceproduct_domain_model_category(uid),
FOREIGN KEY (type) REFERENCES tx_redspaceproduct_domain_model_type(uid)

);

tx_redspaceproduct_domain_model_product.php

'image' => [
        'exclude' => true,
        'label' => 'LLL:EXT:redspace_product/Resources/Private/Language/locallang_db.xlf:tx_redspaceproduct_domain_model_product.image',
        'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
            'image',
            [
                'appearance' => [
                    'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference'
                ],
                'overrideChildTca' => [
                    'types' => [
                        'foreign_types' => [
                            '0' => [
                                'showitem' => '
                                --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                                --palette--;;filePalette'
                            ],
                            \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
                                'showitem' => '
                                --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                                --palette--;;filePalette'
                            ],
                            \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
                                'showitem' => '
                                --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                                --palette--;;filePalette'
                            ],
                            \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
                                'showitem' => '
                                --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                                --palette--;;filePalette'
                            ],
                            \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
                                'showitem' => '
                                --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                                --palette--;;filePalette'
                            ],
                            \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
                                'showitem' => '
                                --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                                --palette--;;filePalette'
                            ]
                        ],
                    ],
                ],
                'maxitems' => 99
            ],
            $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
        ),
    ],

Продукт.php

<?php
namespace REDSPACE\RedspaceProduct\Domain\Model;

use \TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use \TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use \TYPO3\CMS\Extbase\Domain\Model\FileReference;

/***
 *
 * This file is part of the "Redspace Product" Extension for TYPO3 CMS.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 *  (c) 2019 Robin Probst <[email protected]>, REDSPACE AG
 *
 ***/

/**
 * Product
*/
class Product extends AbstractEntity
{

    /**
     * image
     * 
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<TYPO3\CMS\Extbase\Domain\Model\FileReference>
     * @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
     */
    protected $image = null;

    /**
     * __construct
     */
    public function __construct()
    {
        $this->initStorageObjects();
    }

    /**
     * Initializes all ObjectStorage properties
     * 
     * @return void
     */
    protected function initStorageObjects()
    {
        $this->file = new ObjectStorage();
    }

    /**
     * Returns the image
     * 
     * @return ObjectStorage<FileReference> $image
     */
    public function getImage()
    {
        return $this->image;
    }

    /**
     * Sets the image
     * 
     * @param ObjectStorage<FileReference> $image
     * @return void
     */
    public function setImage(ObjectStorage $image)
    {
        $this->image = $image;
    }
}

ProductRepository.php:

<?php
namespace REDSPACE\RedspaceProduct\Domain\Repository;

use \TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;

/***
 *
 * This file is part of the "Redspace Product" Extension for TYPO3 CMS.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 *  (c) 2019 Robin Probst <[email protected]>, REDSPACE AG
 *
 ***/

/**
 * The repository for Products
 */
class ProductRepository extends Repository
{
    protected $tableName = 'tx_redspaceproduct_domain_model_product';

    public function getProductOfCategory($category) {
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)- >getQueryBuilderForTable($this->tableName);
        $statement = $queryBuilder
            ->select('*')
            ->from($this->tableName)
            ->where($queryBuilder->expr()->like('category', $category))
            ->execute();

        $rows = $statement->fetchAll();

        return $rows;
    }

    public function getFlyerIdentifier($uid) {
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)- >getQueryBuilderForTable($this->tableName);
        $statement = $queryBuilder
            ->select('identifier')
            ->from('sys_file')
            ->leftJoin('sys_file','sys_file_reference','sys_file_reference',$queryBuilder->expr()->eq('sys_file_reference.uid_local', $queryBuilder->quoteIdentifier('sys_file.uid')))
            ->where($queryBuilder->expr()->eq('sys_file_reference.uid_foreign', $uid))
            ->andWhere($queryBuilder->expr()->eq('extension', '"pdf"'))
            ->execute();

        $rows = $statement->fetchAll();

        return $rows;
    }
}

Это вывод f:debug:
Это вывод f:debug:

Журнал устаревания: Журнал устаревания


person th3r3alpr0    schedule 08.01.2020    source источник


Ответы (1)