[TYPO3-mvc] How to access a repository from a flexform?

Michael Knoll mimi at kaktusteam.de
Mon Jan 31 23:26:53 CET 2011


Hi Richard,

before Extbase 1.3.0 you had to run the ExtBase Dispatcher to resolve / 
load dependencies like those you need for the repository to work. 
Nowadays, you have the bootstrap that does this job. Perhaps you can 
take a look at this (it is the old way!):

class user_Tx_Yag_Utility_Flexform_ExtbaseDataProvider {
	

	/**
	 * Album repository
	 *
	 * @var Tx_Yag_Domain_Repository_AlbumRepository
	 */
	protected $albumRepository;
	
	
	
	/**
	 * Get a list of albums
	 *
	 * @param array $config
	 * @return array $config
	 */
	public function getAlbumList(array $config) {
		
		$dispatcher = t3lib_div::makeInstance('Tx_Extbase_Dispatcher');

		$albumList = array();
		if(!is_array($config['items'])) $config['items'] = array();
		
		$this->albumRepository = 
t3lib_div::makeInstance('Tx_Yag_Domain_Repository_AlbumRepository');
		
		$query = $this->albumRepository->createQuery();
		$query->getQuerySettings()->setRespectStoragePage(FALSE);
		$albumCollection = $query->execute();
		
		foreach($albumCollection as $album) {
			$albumList[] = array($album->getName(),$album->getUid());
		}
		
		$config['items'] = array_merge($config['items'], $albumList);
		
		return $config;
	}
}



The Dispatcher still exists, but is obsolete, so take a look at the 
bootstrap class!


Greetings

Michael




Am 31.01.11 17:53, schrieb Richard Bausek:
> Hi list,
>
> for a frontend plugin configuration in a flexform I need to fill an
> "select" TCEForm field with data from my domain model based on the other
> settings from the flexform.
>
> To prevent code duplication and to have consistency between my frontend
> and backend output, I want to use my existing domain model repository to
> pull the domain objects into the flexform.
>
> I tried to create an userfunction with "itemsProcFunc" where I create an
> instance of my repository. But that doesn't seem to work as not all
> classes are loaded.
>
> Is it possible to use a repository outside of an frontend plugin or
> backend module? Are there any examples available or is there a
> recommended way of doing this?
>
> I'm using extbase and fluid 1.3.0alpha2 (can't change that ATM).
>
> Any help or clues is welcome!
>
> Thanks in advance,
> Richard



More information about the TYPO3-project-typo3v4mvc mailing list