[TYPO3-mvc] relation to hidden objects

Alexander Wende a_wende at web.de
Fri Jan 6 12:28:49 CET 2017


Hi,
 
I have following problem with extbase and TYPO3 6.2. 
I have an object (video) with an relation to an other (page) which is sometimes hidden.

If the page is hidden the page property in the video object is empty. This behaviour is correct for the frontend, but in the backend I need the relation if the page is hidden.

I know that I can change the querySettings in the repository to irgnore the enable fields. But in the model, the relation is build by the property mapper and not by the repository. I think the property mapper uses the settings from the tca. 

Now I have two solutions for this problem. But both seems to smell. Comments, suggestions und improvements are highly required.

Solution 1:
extend the video model as follow.
[CODE]
	public function initializeObject(){
		$this->overridePageIfEmpty();
	}
	
	protected function overridePageIfEmpty(){
		if (!$this->page instanceof Page){
			/** @var ObjectManager $objectManager */
			$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
			$pageRepository = $objectManager->get('FOO\\Bar\Domain\\Repository\\PageRepository');
			$this->page = $pageRepository->findOneByVideo($this);
		}
	}
[/CODE]
this uses the repository if property mapper has not field the page property. So the repository settings will be used.
Problem: page is invisible for validation

Solution 2:
Add condition in the pages 'tca overrides' file.
[CODE]
if (TYPO3_MODE === 'BE') {
	$GLOBALS['TCA']['pages']['ctrl']['enablecolumns'] = array();
} 
[/CODE]

Validation works fine with that. But I think this could have unwanted side effects.

Did anybody has an better sollution for this problem?

Thanks a lot
Alex


More information about the TYPO3-project-typo3v4mvc mailing list