Skip to content
Snippets Groups Projects
TsrefController.php 1.56 KiB
Newer Older
damjan's avatar
damjan committed
<?php
damjan's avatar
damjan committed
namespace SGalinski\TypoScriptReferenceFrontend\Controller;

/*                                                                        *
 * This script belongs to the TYPO3 Flow package "SGalinski.TypoScriptReferenceFrontend".*
 *                                                                        *
 *                                                                        */

use SGalinski\TypoScriptReferenceFrontend\Service\TsrefRestService;
damjan's avatar
damjan committed
use TYPO3\Flow\Annotations as Flow;

class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
damjan's avatar
damjan committed
	/**
	 * @var TsrefRestService
	 */
	protected $tsrefRestService;

	/**
	 * The constructor is used for dependency injection.
	 *
	 * @param TsrefRestService $service
	 */
	public function __construct(TsrefRestService $service) {
		$this->tsrefRestService = $service;
	}

	/**
	 * The action which fetches the data for typoScript reference page, and displays the page.
	 * @param int $typeId
	 * @return void
damjan's avatar
damjan committed
	 */
	public function indexAction($typeId = NULL) {
			$selectedType = $this->tsrefRestService->getAttributeById($typeId);
			$properties = $this->tsrefRestService->getPropertiesByParentId($typeId);
			$this->view->assign('properties', $properties);
			$this->view->assign('selectedType', $selectedType);

			if (isset($selectedType->parent_id)) {
				$superType = $this->tsrefRestService->getAttributeById($selectedType->parent_id);
				$this->view->assign('superType', $superType);
			}
		$types = $this->tsrefRestService->getTypes();
		$this->view->assign('types', $types);
damjan's avatar
damjan committed
	}
}