Megafry
Megafry

Reputation: 84

TYPO3 V10 - EXT:news custom type and persistence mapping

i'm trying to upgrade a extension for TYPO3 10.4 which add a custom type to tx_news (Doc).

I did the migration based on this example: Breaking: #87623

Classes/Controller/NewsController.php

return [
  \Xyz\Extendnews\Domain\Model\Team::class => [
    'tableName' => 'tx_news_domain_model_news',
    'recordType' => 3,
],

But wenn I debug the entry in the Fluid-Template the default model is still used.

Did I miss something or does someone have a working example.

Thanks for any help.


Update: I want to create a new type, explained in Georg Ringer´s manual

I have created a small extension, everything works fine with TYPO3 9.5, but not with TYPO3 10.4. DEMO EXT

With TYPO3 10.4 the prototype is not MxnTeam\Domain\Model\Team


Update 29.06.2020:

tobenschmidt from the TYPO3 Slack channel ( post ) help me out.

return [
 \Mexan\MxnTeam\Domain\Model\Team::class => [
     'tableName' => 'tx_news_domain_model_news',
     'recordType' => \Mexan\MxnTeam\Domain\Model\Team::class,
 ],
 \Mexan\MxnTeam\Domain\Model\Client::class => [
     'tableName' => 'tx_news_domain_model_news',
     'recordType' => \Mexan\MxnTeam\Domain\Model\Client::class,
 ],
 \GeorgRinger\News\Domain\Model\News::class => [
     'tableName' => 'tx_news_domain_model_news',
     //'recordType' => 0,
     'subclasses' => [
         \Mexan\MxnTeam\Domain\Model\Team::class,
         \Mexan\MxnTeam\Domain\Model\Client::class,
     ]
 ],
];

This works fine, even with 2 custom types. but unfortunately the default news are no longer loaded but if I add recordType => 0, then only normal news and my custom types are visible, but not the type 1 and 2 (Internal and external)

I updated the extension: mxn_team

is there a way to prevent this?

Upvotes: 1

Views: 1986

Answers (2)

rfritzzz
rfritzzz

Reputation: 31

This works for me...

Implement your news type as described in https://docs.typo3.org/p/georgringer/news/8.5/en-us/DeveloperManual/ExtendNews/AddCustomType/Index.html

but instead of the described TypoScript add following file to your extension:

ext_name/Configuration/Extbase/Persistence/Classes.php

<?php

return [
    \GeorgRinger\News\Domain\Model\News::class => [
        'subclasses' => [
            3 => \Vendor\ExtName\Domain\Model\MyCustomNewsType::class
        ]
    ],
    Vendor\ExtName\Domain\Model\MyCustomNewsType::class => [
        'tableName' => 'tx_news_domain_model_news',
        'recordType' => 3,
    ],
];

The way using TypoScript (config.tx_extbase.persistence.classes) was removed in TYPO3 v10

Upvotes: 3

G-Agnes
G-Agnes

Reputation: 101

You write "Classes/Controller/NewsController.php" but you have to create a file here

extendnews/Configuration/Extbase/Persistence/Classes.php

and put your code in there. After that, do not forget to clear all cache. Complete file "Classes.php" should look like

<?php
declare(strict_types = 1);

return [
  \Xyz\Extendnews\Domain\Model\Team::class => [
    'tableName' => 'tx_news_domain_model_news',
    'recordType' => \Xyz\Extendnews\Domain\Model\Team::class,
],

To use the new model follow Georg Ringer´s manual manual on typo3.org

And a working example here

Upvotes: 0

Related Questions