[TYPO3-mvc] Extending Tx_Extbase_Domain_Model_FrontendUser

Johannes C. Schulz - EnzephaloN IT-Solutions info at enzephalon.de
Wed Jan 4 15:08:31 CET 2012


Hello

After mapping the additional fields from fe_users correctly, I'm in new
trouble with the object-object-relation...
I will try to "paint" my model:
Accreditation.php
class Tx_PsoaAccredit_Domain_Model_Accreditation  extends
Tx_Extbase_DomainObject_AbstractEntity   {
	/**
	* magazindetails
	*
	* @var
Tx_Extbase_Persistence_ObjectStorage<Tx_PsoaAccredit_Domain_Model_Feuser>
$user
	*/
	protected $user;
	/**
	* the single persons
	*
	* @var
Tx_Extbase_Persistence_ObjectStorage<Tx_PsoaAccredit_Domain_Model_Person>
$persons
	*/
	protected $persons;Tx_PsoaAccredit_Domain_Model_Feuser
	[...some more properties...]
	/**
	* The constructor of this Accreditation
	*
	* @return void
	*/
	public function __construct(){
		$this->initStorageObjects();
	}
	/**
	* Initializes all Tx_Extbase_Persistence_ObjectStorage properties.
	*
	* @return void
	*/
	protected function initStorageObjects(){
		$this->persons = new Tx_Extbase_Persistence_ObjectStorage();
		$this->user = new Tx_Extbase_Persistence_ObjectStorage();
	}
	[...getter and setter...]
}
Feuser.php
class Tx_PsoaAccredit_Domain_Model_Feuser extends
Tx_Extbase_Domain_Model_FrontendUser {
	[...additional fields and their getter and setter...]
}

With the "normal" properties and "persons" all works fine, but "user" is
empty if I put a debug on {accreditation}.

What I've forgotten to do? The "persons"-relation comes from the
kickstarter, the "user"-relation I wrote by hand, maybe something is
missing, somewhere?

Best regards
Johannes

-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
[mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von
Johannes C. Schulz - EnzephaloN IT-Solutions
Gesendet: Mittwoch, 4. Januar 2012 09:23
An: 'TYPO3 v4 MVC project'
Betreff: Re: [TYPO3-mvc] Extending Tx_Extbase_Domain_Model_FrontendUser

Hello Mark
Thanks a lot - this was the first step, because the error went away.
Something strange, because in the past it works without setting the
"mapOnProperty" with other extensions I wrote...
I deleted all of the "standard" fe_users-fields from my model (instead of
password, cause I will generate it here). 
It is right to begin the model with:
"class Tx_PsoaAccredit_Domain_Model_Feuser extends
Tx_Extbase_Domain_Model_FrontendUser {" ?
Because now no object-value is shown.
My feusers is a child-object of an "accreditation"-model, accessed in fluid
like {accreditation.user.company}.
Tx_PsoaAccredit_Domain_Model_Accreditation.user ->
Tx_PsoaAccredit_Domain_Model_Feuser
Best regards
Johannes

-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
[mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von
Mark Kuiphuis
Gesendet: Mittwoch, 4. Januar 2012 08:54
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: Re: [TYPO3-mvc] Extending Tx_Extbase_Domain_Model_FrontendUser

On 4/01/12 5:16 PM, Johannes C. Schulz - EnzephaloN IT-Solutions wrote:
> Hello
>
> I have some trouble with extending Tx_Extbase_Domain_Model_FrontendUser.
> At first I added new fields to fe_users table. After that I made a new 
> Model called Tx_PsoaAccredit_Domain_Model_Feuser and wrote down all 
> fields from fe_users I need plus my additional fields. To map them, I 
> added to the setup.txt the following lines:
> config.tx_extbase.persistence.classes{
>               Tx_Psoaaccredit_Domain_Model_Feuser{
>                      mapping{
>                             tableName = fe_users
>                      }
>               }
> }
>
> Taken from here: http://typo3.sfroemken.de/index.php?id=81
>
> I also included the setup to the page. I can see this mapping in the 
> Object-Browser. Also I tried to map by 
> "plugin.tx_psoaaccredit.persistence.classes" but this also doesn't work.
>
> But now I get an extbase-error: #1247602160: Table 
> 'psoa.tx_psoaaccredit_domain_model_feuser' doesn't exist: SELECT
> tx_psoaaccredit_domain_model_feuser.* FROM 
> tx_psoaaccredit_domain_model_feuser WHERE 
> tx_psoaaccredit_domain_model_feuser.uid IN ('7') LIMIT 1
>
> What I have to do, to make this connection/extension working?
>
> Best regards
> Johannes
>

Hi Johannes,

I've done something similar in the past and didn't redeclare all fields of
the FeUser model.

You only need to declare the additional fields in your model as your model
is already extending the class Tx_Extbase_Domain_Model_FrontendUser

class Tx_YourExt_Domain_Model_Feuser extends
Tx_Extbase_Domain_Model_FrontendUser {
	// only your additional fields go here...
}

Then I used the following Typoscript to map the additional fields to a
database field.

config.tx_extbase.persistence.classes {
	Tx_PsoaAccredit_Domain_Model_Feuser {
		mapping {
			tableName = fe_users
			recordType = Tx_PsoaAccredit_Domain_Model_Feuser
			columns {
				tx_psoaaccredit_mobile.mapOnProperty =
mobile
				tx_psoaaccredit_showEmail.mapOnProperty =
showEmail
				tx_psoaaccredit_showTelephone.mapOnProperty
= showTelephone
				tx_psoaaccredit_showMobile.mapOnProperty =
showMobile
				tx_psoaaccredit_inviteToken.mapOnProperty =
inviteToken

				//fieldnameinfeusertable.mapOnProperty =
variableInModel
			}
		}
	}
}

It looks like you have a created a new table for your members instead of
extending the existing table fe_users with your additional fields....

Cheers, Mark
_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc




More information about the TYPO3-project-typo3v4mvc mailing list