Skip to content

Commit

Permalink
#1098 Update to work with DCG edit/overrideAl
Browse files Browse the repository at this point in the history
  • Loading branch information
baumannsven authored and stefanheimes committed May 9, 2017
1 parent bd9e359 commit 8e61ba8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
18 changes: 14 additions & 4 deletions src/MetaModels/DcGeneral/Events/Table/Attribute/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/core.
*
* (c) 2012-2016 The MetaModels team.
* (c) 2012-2017 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -16,7 +16,7 @@
* @author Martin Treml <github@r2pi.net>
* @author Christopher Boelter <christopher@boelter.eu>
* @author Sven Baumann <baumann.sv@gmail.com>
* @copyright 2012-2016 The MetaModels team.
* @copyright 2012-2017 The MetaModels team.
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -140,7 +140,10 @@ private function getMetaModelByModelPid($model)
*/
public function modelToLabel(ModelToLabelEvent $event)
{
if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')) {
$dataDefinitionName = $event->getEnvironment()->getDataDefinition()->getName();
if (($dataDefinitionName !== 'tl_metamodel_attribute')
|| ($dataDefinitionName !== $event->getModel()->getProviderName())
) {
return;
}

Expand Down Expand Up @@ -214,7 +217,10 @@ public function modelToLabel(ModelToLabelEvent $event)
public function getOptions(GetPropertyOptionsEvent $event)
{
if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')
|| ($event->getPropertyName() !== 'type')) {
|| ($event->getPropertyName() !== 'type')
|| ($event->getEnvironment()->getInputProvider()->getParameter('act') === 'select'
&& !$event->getModel()->getId())
) {
return;
}

Expand Down Expand Up @@ -255,6 +261,10 @@ public function getOptions(GetPropertyOptionsEvent $event)
*/
protected function decodeValue(DecodePropertyValueForWidgetEvent $event)
{
if ($event->getEnvironment()->getDataDefinition()->getName() !== $event->getModel()->getProviderName()) {
return;
}

$metaModel = $this->getMetaModelByModelPid($event->getModel());

$values = Helper::decodeLangArray($event->getValue(), $metaModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/core.
*
* (c) 2012-2015 The MetaModels team.
* (c) 2012-2017 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -13,7 +13,8 @@
* @package MetaModels
* @subpackage Core
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @copyright 2012-2015 The MetaModels team.
* @author Sven Baumann <baumann.sv@gmail.com>
* @copyright 2012-2017 The MetaModels team.
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -272,15 +273,15 @@ protected function getLabelParameters(EnvironmentInterface $environment, ModelIn
*/
public function modelToLabel(ModelToLabelEvent $event)
{
if (($event->getEnvironment()->getDataDefinition()->getName()
!== 'tl_metamodel_filtersetting')
$model = $event->getModel();

if (($model->getProviderName() !== 'tl_metamodel_filtersetting')
|| in_array($event->getModel()->getProperty('type'), $this->getTypes())
) {
return;
}

$environment = $event->getEnvironment();
$model = $event->getModel();

$event
->setLabel($this->getLabelPattern($environment, $model))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/core.
*
* (c) 2012-2015 The MetaModels team.
* (c) 2012-2017 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -13,7 +13,8 @@
* @package MetaModels
* @subpackage Core
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @copyright 2012-2015 The MetaModels team.
* @author Sven Baumann <baumann.sv@gmail.com>
* @copyright 2012-2017 The MetaModels team.
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand All @@ -37,8 +38,8 @@
use ContaoCommunityAlliance\DcGeneral\DataDefinition\Palette\PropertyInterface;
use ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent;
use MetaModels\BackendIntegration\TemplateList;
use MetaModels\DcGeneral\DataDefinition\Palette\Condition\Property\RenderSettingAttributeIs as PropertyCondition;
use MetaModels\DcGeneral\DataDefinition\Palette\Condition\Palette\RenderSettingAttributeIs as PaletteCondition;
use MetaModels\DcGeneral\DataDefinition\Palette\Condition\Property\RenderSettingAttributeIs as PropertyCondition;
use MetaModels\DcGeneral\Events\BaseSubscriber;
use MetaModels\DcGeneral\Events\BreadCrumb\BreadCrumbRenderSetting;
use MetaModels\IMetaModel;
Expand Down Expand Up @@ -128,11 +129,12 @@ protected function getMetaModel($model)
*/
public function modelToLabel(ModelToLabelEvent $event)
{
if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_rendersetting')) {
$model = $event->getModel();

if (($model->getProviderName() !== 'tl_metamodel_rendersetting')) {
return;
}

$model = $event->getModel();
$attribute = $this->getMetaModel($model)->getAttributeById($model->getProperty('attr_id'));

if ($attribute) {
Expand Down

0 comments on commit 8e61ba8

Please sign in to comment.