-1

I am using TYPO3 v10 and i have built an extension.

In some parts of the FrontEnd i need to get the crdate or the tstamp. TYPO3 does not have getters and setters to use in order to retrieve them.

Before TYPO3 v10 you could do something like that:

config.tx_extbase {
    persistence {
        classes {
            TYPO3\CMS\Extbase\Domain\Model\FileMount {
               mapping {
                  tableName = sys_filemounts
                  columns {
                     title.mapOnProperty = title
                     path.mapOnProperty = path
                     base.mapOnProperty = isAbsolutePath
                  }
               }
            }
        }
    }
}

Best regards,

Aristeidis Karavas
  • 1,891
  • 10
  • 29

1 Answers1

0

The solution is rather simple. I had to build my own getters and map them. Example the crdate:

Model1.php

/**
* @var \DateTime
*/
protected $creationDate;

public function getCreationDate(): \DateTime
{
    return $this->creationDate;
}

tx_extension_domain_model_model1.php

'crdate' => [
   'exclude' => true,
   'config' => [
       'type' => 'select',
       'renderType' => 'inputDateTime',
       'eval' => 'datetime,int',
       'default' => 0,
       'range' => [
           'upper' => mktime(0, 0, 0, 1, 1, 2038),
       ],
       'behaviour' => [
           'allowLanguageSynchronization' => true,
       ],
   ],
],

your_extension/Configuration/Extbase/Persistence/Classes.php

return [
    \Vendor\ExtensionName\Domain\Model\Model1::class => [
        'tableName' => 'tx_extension_domain_model_model1',
        'properties' => [
            'creationDate' => [
                'fieldName' => 'crdate',
            ],
            // ...
        ],
    ],
];

Now the crdate can be retrieved in the FrontEnd

Big Thanks to @Mathias Brodala for pointing me to the right direction.

Best regards

Aristeidis Karavas
  • 1,891
  • 10
  • 29