[TYPO3-mvc] Customizing joins.

Braulio J. Solano-Rojas braulio at solsoft.biz
Sun May 8 21:40:51 CEST 2011


Hi Franz.

El 07/05/2011 02:32 a.m., Franz Koch escribió:
> Hey,
>
>> Is it possible to customize the field that is chosen to produce joins in
>> extbase? I have used other frameworks and with those one can change join
>> behavior on the fly. I see that there are join objects in the extbase
>> framework, but I can not find a way to use them.
>
> No, AFAIK the relation field is not yet customizable. I tried to
> implement that once, but didn't succeed (mostly due to lack of time back
> then).

OK.  I am on a deadline too (I would like to investigate this further 
and share it like I did it for the dispatching of actions inside tasks 
but this time I really don't have the time).

>> All I would like to do is use this code in a query:
>> $query->like('staticInfoCountry.cnShortEn', '%'.$keyword.'%').
>
> This is working, but "cnShortEn" has to be mapped in your country object.
>
>
> What I currently do is to call the repository from within my domain
> model having a relation to a static_country record and return this in
> the getCountry method.
>

I do not understand what you're meaning.  I am sorry...

I reverted my code, but when I tried to do this I had:

class Tx_TicotalTalent_Domain_Model_Talent extends 
Tx_Extbase_Domain_Model_FrontendUser {

	// ...

	/**
	 * Country.
	 *
	 * @var Tx_TicotalTalent_Domain_Model_Country
	 */
	protected $staticInfoCountry;

	// ...

	/**
	 * Returns the staticInfoCountry
	 *
	 * @return Tx_TicotalTalent_Domain_Model_Country $staticInfoCountry Country
	 */
	public function getStaticInfoCountry() {
		return $this->staticInfoCountry;
	}

	/**
	 * Sets the staticInfoCountry
	 *
	 * @param Tx_TicotalTalent_Domain_Model_Country $staticInfoCountry Country
	 * @return void
	 */
	public function setStaticInfoCountry($staticInfoCountry) {
		$this->staticInfoCountry = $staticInfoCountry;
	}

  	// ...

}

In my setup.txt I have:

plugin.tx_ticotaltalent {
	persistence {
		classes {
			Tx_Extbase_Domain_Model_FrontendUser {
				subclasses {
					Tx_TicotalTalent_Domain_Model_Talent = 
Tx_TicotalTalent_Domain_Model_Talent
				}
			}
			Tx_TicotalTalent_Domain_Model_Talent {
				mapping {
					tableName = fe_users
					recordType = Tx_TicotalTalent_Domain_Model_Talent
				}
			}
			Tx_TicotalTalent_Domain_Model_Country {
				mapping {
					tableName = static_countries
				}
			}
		}
	}
}

My Country class is:

class Tx_TicotalTalent_Domain_Model_Country extends 
Tx_Extbase_DomainObject_AbstractEntity {

	/**
	 * Short country name in spanish.
	 *
	 * @var string $cnShortEs
	 */
	protected $cnShortEs;

	/**
	 * Sets the short country name
	 *
	 * @param string $cnShortEs Short country name
	 * @return void
	 */
	public function setCnShortEs($lastName) {
		$this->cnShortEs = $cnShortEs;
	}

	/**
	 * Returns the short country name
	 *
	 * @return string $cnShortEs Short country name
	 */
	public function getCnShortEs() {
		return $this->cnShortEs;
	}
}


And inside my Tx_TicotalTalent_Domain_Repository_TalentRepository I had:

$this->query = $this->createQuery();
// ...
$this->query->like('staticInfoCountry.cnShortEs', '%'.$keyword.'%');

but this won't work because what will be expected on staticInfoCountry 
field of fe_users is a uid.

What I am doing right now is that I have a hook against 
sr_feuser_register that will fill the country field with cn_short_es 
searching by the 3 letter ISO code that value.

I am doing this for http://ticotal.cr/ which is a site in TYPO3 4.5.2 
where public will be able to search for costarican talent outside Costa 
Rica.  :-)

Anyway, thank you very much for your answer.

Bests,

B.


More information about the TYPO3-project-typo3v4mvc mailing list