php - TYPO3: Add custom set functions in extension controller -
i'm creating extension visitors sign page.
when signing up, should create fe user in backend disabled (and manually enabled admin). i'll need set disable
field 1
when creating fe user.
this function inside controller:
/** * action create * * @param \vendor\fereg\domain\model\dummy $newdummy * @return void */ public function createaction(\vendor\fereg\domain\model\dummy $newdummy) { // vars $title = $newdummy->gettitle(); $atitle = $newdummy->getatitle(); $fname = $newdummy->getfname(); $lname = $newdummy->getlname(); $street = $newdummy->getstreet(); $city = $newdummy->getcity(); $post = $newdummy->getpost(); $phone = $newdummy->getphone(); $fax = $newdummy->getfax(); $email = $newdummy->getemail(); $org = $newdummy->getorg(); $cat = $newdummy->getcat(); $field = $newdummy->getfield(); $uname = $newdummy->getuname(); $ppass = $newdummy->getppass(); $cpass = $newdummy->getcpass(); $fulltitle = ($atitle ? $title." ".$atitle : $title); $frontenduser = new frontenduser(); $frontenduser->setusername($uname); $frontenduser->setpassword($ppass); $frontenduser->setfirstname($fname); $frontenduser->setlastname($lname); $frontenduser->setaddress($street); $frontenduser->settelephone($phone); $frontenduser->setfax($fax); $frontenduser->setemail($email); $frontenduser->settitle($fulltitle); $frontenduser->setzip($post); $frontenduser->setcity($city); $frontenduser->setcompany($org); $this->frontenduserrepository->add($frontenduser); // $this->dummyrepository->add($newdummy); // $this->addflashmessage($title, '', \typo3\cms\core\messaging\abstractmessage::error); $this->redirect('new'); }
to make work i'm loading $frontenduserrepository
.
need $frontenduser->setdisable(1)
.
environment: typo3 7.6.8 / php 5.6.24 / mysqlnd 5.0.11
disabling user not default enabled on standard user object. i've tackled issue myself creating model extending frontenduser typo3 , adding property disable.
class frontenduser extends \typo3\cms\extbase\domain\model\frontenduser { /** * @var boolean */ protected $disable; /** * gets disable * * @return boolean */ public function getdisable() { return (bool)$this->disable; } /** * sets disable * * @param boolean $disable * @return void */ public function setdisable($disable) { $this->disable = (bool)$disable; } }
you might need bit of typoscript map proper property
config.tx_extbase { persistence{ classes { vendorname\extensionname\domain\model\frontenduser { mapping { tablename = fe_users columns { disable.maponproperty = disable } } } } } }
you'll need frontenduserrepository well
/** * frontend user repository */ class frontenduserrepository extends \typo3\cms\extbase\domain\repository\frontenduserrepository { }
after can use newly created frontenduser model model frontenduser, inject it, , happily use
$usermodel->setdisable(1); // , $usermodel->getdisable();
(all namespaces written, not necessary obviously, done ease of reading)
Comments
Post a Comment