如何在 TYPO3 和 extbase 中使用 crdate 和 cruser_id 等标准字段? [英] How to use standard fields like crdate and cruser_id with TYPO3 and extbase?

查看:23
本文介绍了如何在 TYPO3 和 extbase 中使用 crdate 和 cruser_id 等标准字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有域模型篮子和文章.如果我拨打以下电话,我会收到篮子里的文章.

I have the domain models Basket and Article. If I call the following I receive the articles in the basket.

$articlesInBasket = $basket->getArticles();

如何使用 TYPO3 标准属性,如 crdate 和 cruser_id.使用这样的东西会很好:

How can I use the TYPO3 standard attributes like crdate and cruser_id. It would be nice to use something like this:

$basket->getCrUser();
$basket->getCrDate();

推荐答案

首先,表字段被命名为crdatecruser 所以getter应该被命名为getCrdate 并获取 getCruser

First, the table fields are named as crdate, and cruser so getters should be named getCrdate and get getCruser

接下来在您的模型中,您需要添加一个字段和一个 getter:

Next in your model you need to add a field and a getter:

/** @var int */
protected $crdate;

/**
* Returns the crdate
*
* @return int
*/
public function getCrdate() {
    return $this->crdate;
}

(对 cruser 字段执行相同操作)

(do the same with cruser field)

最后在您的 setup.txt 中,您很可能需要为这些字段添加映射:

And finally in you setup.txt most probably you'll need to add a mappings for these fields:

config.tx_extbase.persistence.classes {
    Tx_Someext_Domain_Model_Somemodel {
        mapping {
            columns.crdate.mapOnProperty = crdate
            columns.cruser.mapOnProperty = cruser    
        }
    }
}

当然,不要忘记在设置中使用专有名称,并在代码更改后清除缓存

Of course, don't forget to use proper names in the settings, and clear the cache after changes in the code

这篇关于如何在 TYPO3 和 extbase 中使用 crdate 和 cruser_id 等标准字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆