我想从Tx_Extbase_Domain_Repository_FrontendUserRepository运行一个简单的查询。除了findByUid(),我找不到任何工作,甚至没有findAll()。Tx_Extbase_Domain_Repository_FrontendUserRepository-> findAll()not in typo3 4.5.30?
在我的控制器我有这样的代码,这似乎工作:
/**
* @var Tx_Extbase_Domain_Repository_FrontendUserRepository
*/
protected $userRepository;
/**
* Inject the user repository
* @param Tx_Extbase_Domain_Repository_FrontendUserRepository $userRepository
* @return void */
public function injectFrontendUserRepository(Tx_Extbase_Domain_Repository_FrontendUserRepository $userRepository) {
$this->userRepository = $userRepository;
}
/**
* action create
*
* @param Tx_BpsCoupons_Domain_Model_Coupon $newCoupon
* @return void
*/
public function createAction(Tx_BpsCoupons_Domain_Model_Coupon $newCoupon) {
...... some code .....
$user = $this->userRepository->findByUid(($GLOBALS['TSFE']->fe_user->user[uid]));
$newCoupon->setCreator($user);
...... some code .....
}
但在其他功能我想不是UID而是由fe_users列名为vipnumber(int列)来查找用户,以便我试图
/**
* check to see if there is already a user with this vip number in the database
* @param string $vip
* @return bool
*/
public function isVipValid($vip) {
echo "<br/>" . __FUNCTION__ . __LINE__ . "<br/>";
echo "<br/>".$vip."<br/>";
//$ret = $this->userRepository->findByUid(15); //this works!! but
$query = $this->userRepository->createQuery();
$query->matching($query->equals('vip',$vip));
$ret = $query->execute(); //no luck
.................
而且也没有这个
$ret = $this->userRepository->findAll();
怎么能一个工作,但不是TH其他人?在我的设置中,我已经把 config.tx_extbase.persistence.classes.Tx_Extbase_Domain_Model_FrontendUser.mapping.recordType> 这似乎是必要的fiondByUid工作,我是不是阻止另一个工作?
我使用TYPO3 v 4.5.30与extbase 1.3
感谢
嗨丹尼尔,感谢您的答复。我的扩展程序不会向fe_users添加列,但会使用由另一个扩展添加的列。我如何将它添加到TCA或我的模型?有什么地方需要添加关于recordtype或storagepid的地方吗? –
为什么不使用$ query = $ this-> userRepository-> createQuery();在自己的仓库之外?这是一个公开的方法。 –
那么,如果是由另一部分添加该列,那么最有可能的TCA是照顾关闭(你可以随时查询您的后端。配置 - > TCA-> fe_users->列。您的字段必须apear那里。至于模型我编辑我的答案 – Daniel