/** * Returns an instance of pager for a given configuration builder and a pager configuration * * @param Tx_PtExtlist_Domain_Configuration_Pager_PagerConfig $pagerConfiguration * @return Tx_PtExtlist_Domain_Model_Pager_PagerInterface */ public function getInstance(Tx_PtExtlist_Domain_Configuration_Pager_PagerConfig $pagerConfiguration) { $pagerClassName = $pagerConfiguration->getPagerClassName(); $pager = $this->objectManager->get($pagerClassName, $pagerConfiguration); Tx_PtExtbase_Assertions_Assert::isTrue(is_a($pager, 'Tx_PtExtlist_Domain_Model_Pager_PagerInterface'), array('message' => 'Given pager class does not implement pager interface! 1279541488')); return $pager; }
/** * Build and return the renderer * * @param Tx_PtExtlist_Domain_Configuration_Renderer_RendererConfig $rendererConfiguration * @return Tx_PtExtlist_Domain_Renderer_ConfigurableRendererInterface */ public function getRenderer(Tx_PtExtlist_Domain_Configuration_Renderer_RendererConfig $rendererConfiguration) { $rendererClassName = $rendererConfiguration->getRendererClassName(); Tx_PtExtbase_Assertions_Assert::classExists($rendererClassName, array('message' => 'Configured renderer class ' . $rendererClassName . ' does not exist! 1286986512')); $renderer = $this->objectManager->get($rendererClassName); /* @var $renderer Tx_PtExtlist_Domain_Renderer_ConfigurableRendererInterface */ Tx_PtExtbase_Assertions_Assert::isTrue(is_a($renderer, 'Tx_PtExtlist_Domain_Renderer_ConfigurableRendererInterface'), array('message' => 'Configured renderer class ' . $rendererClassName . ' does not implement Tx_PtExtlist_Domain_Renderer_RendererInterface 1286986513')); $renderer->_injectConfiguration($rendererConfiguration); $renderer->initRenderer(); return $renderer; }
/** * Set and validate the config values * * @return void */ protected function initByTsConfig() { $this->dateIteratorStart = (int) Tx_PtExtlist_Utility_RenderValue::stdWrapIfPlainArray($this->filterConfig->getSettings('dateIteratorStart')); Tx_PtExtbase_Assertions_Assert::isPositiveInteger($this->dateIteratorStart, false, array('message' => 'The Value dateIteratorStart is not given. 1314608757')); $this->dateIteratorEnd = (int) Tx_PtExtlist_Utility_RenderValue::stdWrapIfPlainArray($this->filterConfig->getSettings('dateIteratorEnd')); Tx_PtExtbase_Assertions_Assert::isPositiveInteger($this->dateIteratorEnd, false, array('message' => 'The Value dateIteratorEnd is not given. 1314608758')); $this->dateIteratorFormat = $this->filterConfig->getSettings('dateIteratorFormat'); Tx_PtExtbase_Assertions_Assert::isNotEmptyString($this->dateIteratorFormat, array('message' => 'The Value dateIteratorFormat is not given. 1314608759')); $this->dateIteratorIncrement = strtolower(trim($this->filterConfig->getSettings('dateIteratorIncrement'))); Tx_PtExtbase_Assertions_Assert::isNotEmptyString($this->dateIteratorIncrement, array('message' => 'The Value dateIteratorIncrement is not given. 1314608760')); Tx_PtExtbase_Assertions_Assert::isTrue(in_array($this->dateIteratorIncrement, array('s', 'i', 'h', 'd', 'm', 'y')), array('message' => "The parameter dateIteratorIncrement has to be out of 's', 'i', 'h', 'd', 'm', 'y'")); Tx_PtExtbase_Assertions_Assert::isTrue($this->dateIteratorStart < $this->dateIteratorEnd, array('message' => 'The Value dateIteratorStart (' . $this->dateIteratorStart . ') is higher than dateIteratorEnd (' . $this->dateIteratorEnd . ')')); }
/** * Determine the dataProvider to use for filter options * * TODO: Test me! * @param Tx_PtExtlist_Domain_Configuration_Filters_FilterConfig $filterConfig * @return string dataProviderClass */ protected function determineDataProviderClass(Tx_PtExtlist_Domain_Configuration_Filters_FilterConfig $filterConfig) { if ($filterConfig->getSettings('dataProviderClassName')) { $dataProviderClassName = $filterConfig->getSettings('dataProviderClassName'); } else { if ($filterConfig->getSettings('options')) { $dataProviderClassName = 'Tx_PtExtlist_Domain_Model_Filter_DataProvider_ExplicitData'; } else { $dataProviderClassName = 'Tx_PtExtlist_Domain_Model_Filter_DataProvider_GroupData'; } } Tx_PtExtbase_Assertions_Assert::isTrue(class_exists($dataProviderClassName), array('message' => 'The defined DataProviderClass "' . $dataProviderClassName . '" does not exist! 1283535558')); return $dataProviderClassName; }
/** * Returns an instance of a data mapper for a given data mapper class name. * * @param Tx_PtExtlist_Domain_Configuration_ConfigurationBuilder $configurationBuilder * @return mixed */ public function createDataMapper(Tx_PtExtlist_Domain_Configuration_ConfigurationBuilder $configurationBuilder) { $dataBackendConfiguration = $configurationBuilder->buildDataBackendConfiguration(); $dataMapperClassName = $dataBackendConfiguration->getDataMapperClass(); $dataMapper = $this->objectManager->get($dataMapperClassName, $configurationBuilder); /** @var Tx_PtExtlist_Domain_DataBackend_Mapper_AbstractMapper $dataMapper */ $mapperConfiguration = $configurationBuilder->buildFieldsConfiguration(); // Check whether mapper implements interface Tx_PtExtbase_Assertions_Assert::isTrue($dataMapper instanceof Tx_PtExtlist_Domain_DataBackend_Mapper_MapperInterface, array('message' => 'Data mapper must implement data mapper interface! 1280415471')); $dataMapper->_injectConfigurationBuilder($configurationBuilder); $dataMapper->_injectMapperConfiguration($mapperConfiguration); $dataMapper->init(); return $dataMapper; }
/** * Initialize additional class properties */ public function initConfiguration() { parent::initConfiguration(); //echo 's'; $this->templatePath = $this->exportConfiguration->getSettings('templatePath'); Tx_PtExtbase_Assertions_Assert::isNotEmptyString($this->templatePath, array('message' => 'No template path given for fluid export! 1284621481')); $this->setTemplatePathAndFilename(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->templatePath)); $this->paperSize = strtolower($this->exportConfiguration->getSettings('paperSize')); Tx_PtExtbase_Assertions_Assert::isNotEmptyString($this->paperSize, array('message' => 'No PaperSize given for the PDF output! 1322585559')); $this->paperOrientation = $this->exportConfiguration->getSettings('paperOrientation'); Tx_PtExtbase_Assertions_Assert::isInArray($this->paperOrientation, array('portrait', 'landscape'), array('message' => 'The Orientation must either be portrait or landscape! 1322585560')); $this->cssFilePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->exportConfiguration->getSettings('cssFilePath')); Tx_PtExtbase_Assertions_Assert::isTrue(file_exists($this->cssFilePath), array('message' => 'The CSS File with the filename ' . $this->cssFilePath . ' can not be found. 1322587627')); $this->dompdfSourcePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->exportConfiguration->getSettings('dompdfSourcePath')); Tx_PtExtbase_Assertions_Assert::isTrue(is_dir($this->dompdfSourcePath), array('message' => 'DomPdf source in path ' . $this->dompdfSourcePath . ' was not found. 1322753515')); $this->dompdfSourcePath = substr($this->dompdfSourcePath, -1, 1) == '/' ? $this->dompdfSourcePath : $this->dompdfSourcePath . '/'; }
/** * Translates a query an manipulates given query object * * TODO check, if there is already a constraint added to extbase query and use AND constraint then * TODO use AND to connect more than one constraint * * @param Tx_PtExtlist_Domain_QueryObject_Criteria $criteria Criteria to be translated * @param \TYPO3\CMS\Extbase\Persistence\Generic\Query $extbaseQuery Query to add criteria to * @param \TYPO3\CMS\Extbase\Persistence\Repository $extbaseRepository Associated repository * * @return \TYPO3\CMS\Extbase\Persistence\Generic\Query * * @throws \Exception */ public static function translateCriteria(Tx_PtExtlist_Domain_QueryObject_Criteria $criteria, \TYPO3\CMS\Extbase\Persistence\Generic\Query $extbaseQuery, \TYPO3\CMS\Extbase\Persistence\Repository $extbaseRepository) { Tx_PtExtbase_Assertions_Assert::isTrue(is_a($criteria, 'Tx_PtExtlist_Domain_QueryObject_SimpleCriteria'), array('message' => 'Criteria is not a simple criteria! 1281724991')); /* @var $criteria Tx_PtExtlist_Domain_QueryObject_SimpleCriteria */ $propertyName = self::getPropertyNameByCriteria($criteria); switch ($criteria->getOperator()) { case '.': self::addConstraint($extbaseQuery, $extbaseQuery->contains($propertyName, $criteria->getValue())); break; case '=': self::addConstraint($extbaseQuery, $extbaseQuery->equals($propertyName, $criteria->getValue())); break; case '<': self::addConstraint($extbaseQuery, $extbaseQuery->lessThan($propertyName, $criteria->getValue())); break; case '>': self::addConstraint($extbaseQuery, $extbaseQuery->greaterThan($propertyName, $criteria->getValue())); break; case '<=': self::addConstraint($extbaseQuery, $extbaseQuery->lessThanOrEqual($propertyName, $criteria->getValue())); break; case '>=': self::addConstraint($extbaseQuery, $extbaseQuery->greaterThanOrEqual($propertyName, $criteria->getValue())); break; case 'LIKE': self::addConstraint($extbaseQuery, $extbaseQuery->like($propertyName, $criteria->getValue())); break; case 'IN': self::addConstraint($extbaseQuery, $extbaseQuery->in($propertyName, $criteria->getValue())); break; default: throw new Exception('No translation implemented for ' . $criteria->getOperator() . ' operator! 1281727494'); break; } return $extbaseQuery; }
/** * Creates filter object for given filter class name * * @param string $filterClassName * @return Tx_PtExtlist_Domain_Model_Filter_FilterInterface */ private function createFilterObject($filterClassName) { Tx_PtExtbase_Assertions_Assert::isNotEmptyString($filterClassName, array('message' => 'No filter class name given, check TS configuration! 1277889459')); Tx_PtExtbase_Assertions_Assert::isTrue(class_exists($filterClassName), array('message' => 'Given filter class ' . $filterClassName . ' does not exist or is not loaded! 1277889460')); $filter = $this->objectManager->get($filterClassName); /* @var $filter Tx_PtExtlist_Domain_Model_Filter_FilterInterface */ Tx_PtExtbase_Assertions_Assert::isTrue(is_a($filter, 'Tx_PtExtlist_Domain_Model_Filter_FilterInterface'), array('message' => 'Given filter class does not implement filter interface! 1277889461')); $filter->_injectGpVarsAdapter($this->getPostVarsAdapterFactory->getInstance()); return $filter; }
protected function init() { $this->setRequiredValue('fileName', 'No fileName given for export file! 1284563488'); $this->setRequiredValue('fileExtension', 'No file extension given for export file! 1284620580'); $this->setRequiredValue('viewClassName', 'No viewClassName given for export file ' . $this->fileName . '1284563489'); Tx_PtExtbase_Assertions_Assert::isTrue(class_exists($this->viewClassName), array('message' => 'The class name "' . $this->viewClassName . '" for export view does not exist! 1284563683')); $this->setBooleanIfExistsAndNotNothing('addDateToFilename'); $this->setValueIfExistsAndNotNothing('dateFormat'); $this->setValueIfExistsAndNotNothing('contentType'); if (array_key_exists('downloadtype', $this->settings)) { $this->downloadType = $this->settings['downloadtype'] == 'D' ? self::FORCE_DOWNLOAD : self::OPEN_IN_BROWSER; } }
/** * Use the objects getter to get the value * * @param Tx_PtExtbase_State_IdentifiableInterface $object * @param string $property * @return mixed value */ protected function getObjectValue(Tx_PtExtbase_State_IdentifiableInterface $object, $property) { $getterMethod = 'get' . ucfirst($property); Tx_PtExtbase_Assertions_Assert::isTrue(method_exists($object, $getterMethod), array('message' => 'The Object' . get_class($object) . ' has no getter method "' . $getterMethod . '" ! 1280929630')); return $object->{$getterMethod}(); }
/** * Check existance of given class and set the property * @param string $queryInterpreterClassName */ protected function checkAndSetQueryInterpreterClass($queryInterpreterClassName) { Tx_PtExtbase_Assertions_Assert::isNotEmptyString($queryInterpreterClassName, array('message' => 'queryInterpreterClass must not be empty! 1281178538')); Tx_PtExtbase_Assertions_Assert::isTrue(class_exists($queryInterpreterClassName), array('message' => ' QueryInterpreter class ' . $queryInterpreterClassName . ' does not exist! 1281178539')); $this->queryInterpreterClass = $queryInterpreterClassName; }
/** * (non-PHPdoc) * @see Tx_PtExtbase_Configuration_AbstractConfiguration::init() */ protected function init() { $this->setBooleanIfExistsAndNotNothing('enabled'); $this->setRequiredValue('rendererClassName', 'No class name given for renderer. 1280408323'); Tx_PtExtbase_Assertions_Assert::isTrue(class_exists($this->rendererClassName), array('message' => 'Given renderer class ' . $this->rendererClassName . ' does not exist or is not loaded! 1279541306')); }
private function buildDataBackendForConfigurationBuilder(Tx_PtExtlist_Domain_Configuration_ConfigurationBuilder $configurationBuilder) { $dataBackendConfiguration = $configurationBuilder->buildDataBackendConfiguration(); /* @var $dataBackendClassName string */ $dataBackendClassName = $dataBackendConfiguration->getDataBackendClass(); $dataBackend = $this->objectManager->get($dataBackendClassName, $configurationBuilder); /* @var $dataBackend Tx_PtExtlist_Domain_DataBackend_AbstractDataBackend */ // The reference has to be set here because otherwise every filter will create the databackend again -> recursion! $this->instancesContainer->set($dataBackend); // Check whether backend class implements backend interface Tx_PtExtbase_Assertions_Assert::isTrue($dataBackend instanceof Tx_PtExtlist_Domain_DataBackend_DataBackendInterface, array('message' => 'Data Backend class ' . $dataBackendClassName . ' does not implement Tx_PtExtlist_Domain_DataBackend_DataBackendInterface 1280400022')); $dataBackend->_injectBackendConfiguration($configurationBuilder->buildDataBackendConfiguration()); $dataBackend->_injectFieldConfigurationCollection($configurationBuilder->buildFieldsConfiguration()); $dataBackend->_injectDataMapper($this->getDataMapper($configurationBuilder)); $dataBackend->_injectDataSource($this->getDataSource($dataBackendClassName, $configurationBuilder)); $dataBackend->_injectPagerCollection($this->getPagerCollection($configurationBuilder)); $dataBackend->_injectSorter($this->getSorter($configurationBuilder)); $dataBackend->_injectFilterboxCollection($this->getfilterboxCollection($configurationBuilder)); if ($this->getQueryInterpreter($configurationBuilder) != NULL) { $dataBackend->_injectQueryInterpreter($this->getQueryInterpreter($configurationBuilder)); } $dataBackend->init(); }
/** * Injects a query interpreter * * This method is overwritten to make sure that correct type for interpreter is injected * * TODO this method is not really required ATM, as all methods in query interpreter are static ATM * * @param Tx_PtExtlist_Domain_DataBackend_ExtBaseDataBackend_ExtBaseInterpreter_ExtBaseInterpreter $queryInterpreter */ public function _injectQueryInterpreter($queryInterpreter) { Tx_PtExtbase_Assertions_Assert::isTrue($queryInterpreter instanceof Tx_PtExtlist_Domain_DataBackend_ExtBaseDataBackend_ExtBaseInterpreter_ExtBaseInterpreter); parent::_injectQueryInterpreter($queryInterpreter); }
private function initTypoScriptSettings() { $this->fluidTemplatePath = $this->exportConfiguration->getSettings('templatePath'); Tx_PtExtbase_Assertions_Assert::isNotEmptyString($this->fluidTemplatePath, array('message' => 'No template path given for fluid export! 1284621481')); $this->setTemplatePathAndFilename(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->fluidTemplatePath)); // TODO take a look at http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf_0.10.0_rc2-doc.html for further information on parameters! // --page-size <Size> Set paper size to: A4, Letter, etc. (default A4) $this->size = strtolower($this->exportConfiguration->getSettings('paperSize')); Tx_PtExtbase_Assertions_Assert::isNotEmptyString($this->size, array('message' => 'No PaperSize given for the PDF output! 1322585559')); // TODO take a look at http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf_0.10.0_rc2-doc.html for further informatoin on parameters // --orientation <orientation> Set orientation to Landscape or Portrait (default Portrait) $this->orient = $this->exportConfiguration->getSettings('paperOrientation'); Tx_PtExtbase_Assertions_Assert::isInArray($this->orient, array('portrait', 'landscape'), array('message' => 'The Orientation must either be portrait or landscape! 1322585560')); $this->cssFilePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->exportConfiguration->getSettings('cssFilePath')); Tx_PtExtbase_Assertions_Assert::isTrue(file_exists($this->cssFilePath), array('message' => 'The CSS File with the filename ' . $this->cssFilePath . ' can not be found. 1322587627')); $this->additionalWkhtmlParams = $this->exportConfiguration->getSettings('additionalWkhtmlParams'); $this->wkhtmlHeaderHtml = $this->exportConfiguration->getSettings('wkhtmlHeaderHtml'); $this->wkhtmlFooterHtml = $this->exportConfiguration->getSettings('wkhtmlFooterHtml'); }