php - TYPO3 v10 如何在 FrontEnd 中获取对象的 crdate 或 tstamp
问题描述
我正在使用 TYPO3 v10,并且我已经构建了一个扩展。
在前端的某些部分,我需要获取 crdate 或 tstamp。TYPO3 没有用于检索它们的 getter 和 setter。
在 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
}
}
}
}
}
}
此致,
解决方案
解决方案相当简单。我必须构建自己的吸气剂并映射它们。例如crdate:
模型1.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',
],
// ...
],
],
];
现在可以在 FrontEnd 中检索crdate
非常感谢@Mathias Brodala 为我指明了正确的方向。
此致
推荐阅读
- python - 仅使用新信息将字典读取到文件覆盖
- z3 - 精益是否增强了证明可测量性?
- c# - 从列表中提取所有数据
- 在 C# 中使用 HTML Agility Pack 标记
- google-cloud-platform - 如何在 GCP 中监控 VM 服务?
- javascript - 我的 svg 贝塞尔曲线的波浪效果这可能吗?
- python - 分区在这个函数中有什么作用?
- java - 一次替换哈希图中的所有相同值
- javascript - 如何在 ReactJS 中使用单个代码库从父应用程序创建子应用程序
- firebase - Firestore 侦听器数据使用情况
- amazon-web-services - 将 Docker 映像上传到 AWS ECR