Почему TYPO3 вызывает неправильную таблицу ссылок на файлы - PullRequest
0 голосов
/ 18 июня 2020

У меня есть модель таблицы продуктов с этим кодом для получения ссылок на изображения:

/**
 * Returns the images
 *
 * @return \TYPO3\CMS\Core\Resource\FileReference $images
 */
public function getImages() {
    $fileRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class);
    $this->images = $fileRepository->findByRelation('tx_myext_domain_model_products', 'images', $this->uid);
    return $this->images;
}

Но это вызывает ошибку:

ERROR => 'Table 'database.tx_core_resource_filereference' doesn't exist'

Не знаю, почему это используется имя таблицы. sys_file_reference - имя реальной таблицы в базе данных.

1 Ответ

0 голосов
/ 28 июня 2020

Если это находится в домене, как вы предложили, то все, что вам нужно, это:

... / Classes / Domain / Model / Product. php

...

  /**
   * images
   *
   * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
   */
  protected $images = null;


  /**
   * Returns the images
   *
   * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference images
   */
  public function getImages()
  {
      return $this->images;
  }

  /**
   * Sets the images
   *
   * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $images
   * @return void
   */
  public function setImages(\TYPO3\CMS\Extbase\Domain\Model\FileReference $images)
  {
      $this->images = $images;
  }

...

Тогда TCA для продуктов потребует конфигурации для образов ... например:

... / Configuration / TCA / tx_yourext_domain_model_product. php

...


        'images' => [
          'label' => 'FAL Image',
          'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
            'images',
            [
              'appearance' => [
                'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference'
              ],
              // custom configuration for displaying fields in the overlay/reference table
              // to use the image overlay palette instead of the basic overlay palette
              'overrideChildTca' => [
                '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'
                  ],
                ],
              ],
            ],
            $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
          ),
        ],

...

...