简体   繁体   English

TYPO3 v10 如何在 FrontEnd 中获取对象的 crdate 或 tstamp

[英]TYPO3 v10 How do i get an object's crdate or the tstamp in FrontEnd

I am using TYPO3 v10 and i have built an extension.我正在使用 TYPO3 v10 并且我已经构建了一个扩展。

In some parts of the FrontEnd i need to get the crdate or the tstamp.在前端的某些部分,我需要获取 crdate 或 tstamp。 TYPO3 does not have getters and setters to use in order to retrieve them. TYPO3 没有用于检索它们的 getter 和 setter。

Before TYPO3 v10 you could do something like that:在 TYPO3 v10 之前,您可以执行以下操作:

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,此致,

The solution is rather simple.解决方案相当简单。 I had to build my own getters and map them.我必须建立自己的吸气剂和 map 它们。 Example the crdate :例如crdate

Model1.php型号1.php

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

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

tx_extension_domain_model_model1.php 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 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现在可以在 FrontEnd 中检索crdate

Big Thanks to @Mathias Brodala for pointing me to the right direction.非常感谢@Mathias Brodala 为我指明了正确的方向。

Best regards此致

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM