Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to extend powermail data models in version 12? #996

Open
kitzberger opened this issue Mar 18, 2024 · 1 comment
Open

How to extend powermail data models in version 12? #996

kitzberger opened this issue Mar 18, 2024 · 1 comment
Labels

Comments

@kitzberger
Copy link
Contributor

kitzberger commented Mar 18, 2024

I'm trying to figure out how to properly extend the data models in TYPO3 12 and EXT:powermail 12.

Since TYPO3\CMS\Extbase\Container\Container is gone with TYPO3 12 the respective section of this extensions documentation isn't working anymore: https://github.com/in2code-de/powermail/blob/master/Documentation/ForDevelopers/AddNewFieldProperties.md

Neither is the example in EXT:powermailextended. The latest PR (einpraegsam/powermailextended#9) has never been merged and isn't not compatible with version 12 anyway.

Here's what I found out so far.

Configuration/Extbase/Persistence/Classes.php should look like this:

<?php
declare(strict_types=1);
return [
    \Me\MyExtension\Domain\Model\Page::class => [
        'tableName' => 'tx_powermail_domain_model_page',
    ],
    \Me\MyExtension\Domain\Model\Field::class => [
        'tableName' => 'tx_powermail_domain_model_field',
    ],
];

ext_localconf.php like this:

<?php
defined('TYPO3') || die('Access denied.');
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\In2code\Powermail\Domain\Model\Page::class] = [
    'className' => \Me\MyExtension\Domain\Model\Page::class,
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\In2code\Powermail\Domain\Model\Field::class] = [
    'className' => \Me\MyExtension\Domain\Model\Field::class,
];

Caution: in case of overwriting both Page and Field the relationship between them both needs to be tweaked too, to prevent some weird endless loop:

<?php
namespace Me\MyExtension\Domain\Model;
class Page extends \In2code\Powermail\Domain\Model\Page
{
    /**
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Me\MyExtension\Domain\Model\Field>
     */
    protected $fields = null;
}

I'd really appreciate some feedback of other developers on this matter and together find a solid solution.

@olegkarun
Copy link

olegkarun commented May 13, 2024

@kitzberger

For me Configuration/Extbase/Persistence/Classes.php

`<?php
declare(strict_types = 1);

return [

\In2code\Powermail\Domain\Model\Form::class => [
    'subclasses' => [           
        'formClass' => \Vendor\My\Domain\Model\Form::class,
    ]        
],

\In2code\Powermail\Domain\Model\Page::class => [
    'subclasses' => [           
        'pageClass' => \Vendor\My\Domain\Model\Page::class,
    ]        
],

\In2code\Powermail\Domain\Model\Field::class => [
    'subclasses' => [           
        'fieldClass' => \Vendor\My\Domain\Model\Field::class,
    ]        
],

\Vendor\My\Domain\Model\Form::class => [
    'tableName' => 'tx_powermail_domain_model_form'
],

\Vendor\My\Domain\Model\Page::class => [
    'tableName' => 'tx_powermail_domain_model_page'
],

\Vendor\My\Domain\Model\Field::class => [
    'tableName' => 'tx_powermail_domain_model_field'
]

]`

I see it in vendor/typo3/cms-extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php
image

But I have no lunch my model also I have no variables in my Fluid. Also try setup dependencies with composer.json and ext_emconf.php

For News this approach works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants