[TYPO3-english] Re: how to: getting usernames from database based on uid
Calgacus map Brude
calgach at gmail.com
Fri Nov 8 22:33:19 CET 2013
Got the answer on stackoverflow,
added thos ts to my ext setup
config.tx_extbase.persistence.classes.Tx_Extbase_Domain_Model_FrontendUser.mapping.recordType >
this is the code (it goes in my CouponController) that worked (plus the typoscript mentioned):
/**
* @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;
}
public function showAction(Tx_Coupons_Domain_Model_Coupon $coupon) {
$userRepository = $this->objectManager->get("Tx_Extbase_Domain_Repository_FrontendUserRepository");
$newObject = $userRepository->findByUid($coupon->getCreator());
$this->view->assign('coupon', $coupon);
$this->view->assign('creatorname', $newObject->getUsername() );
}
More information about the TYPO3-english
mailing list