/** * {@inheritdoc} */ public function getProperty($strPropertyName) { switch ($strPropertyName) { case 'version': return $this->getVersion(); case 'active': return $this->isCurrent(); case 'tstamp': return $this->getDateTime(); case 'username': return $this->getAuthorName(); } return parent::getProperty($strPropertyName); }
/** * @param ActionEvent $event * * @throws \Exception * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function handleActionForSelectri(ActionEvent $event) { if (!\Input::get('striAction') || !\Input::get('striID') || \Input::get('striID') === '' && \Input::get('striAction') != 'levels') { return; } $environment = $event->getEnvironment(); $dataDefinition = $environment->getDataDefinition(); $inputProvider = $environment->getInputProvider(); $providerInformation = $dataDefinition->getDataProviderDefinition()->getInformation($dataDefinition->getName()); $dataProviderClass = $providerInformation->getClassName(); /** @var EntityDataProvider $dataProvider */ $dataProvider = new $dataProviderClass(); $dataProvider->setBaseConfig(array('source' => $dataDefinition->getName())); $repository = $dataProvider->getEntityRepository(); $messageContent = null; if ($inputProvider->hasParameter('id')) { $modelId = ModelId::fromSerialized(\Input::get('id')); $messageContent = $repository->find($modelId->getId()); } if (!$messageContent) { $contentModel = $dataProvider->getEmptyModel(); foreach (array_keys($contentModel->getPropertiesAsArray()) as $property) { if (!$inputProvider->hasValue($property)) { continue; } $contentModel->setProperty($property, $inputProvider->getValue($property)); } $messageContent = $contentModel->getEntity(); } $model = new EntityModel($messageContent); $selectriProperty = null; foreach ($dataDefinition->getPalettesDefinition()->getPalettes() as $palette) { foreach ($palette->getLegends() as $legend) { foreach ($legend->getProperties() as $legendProperty) { $property = $dataDefinition->getPropertiesDefinition()->getProperty($legendProperty->getName()); if (!in_array($property->getWidgetType(), array('selectri', 'avisotaSelectriWithItems')) || $legendProperty->getName() != \Input::get('striID')) { continue; } $model->getEntity()->setType($palette->getName()); $selectriProperty = $property; } } } if (!$selectriProperty) { return; } $widgetManager = new ContaoWidgetManager($environment, $model); $widgetManager->renderWidget($selectriProperty->getName()); }