Skip to content

Commit

Permalink
Hotfix contao-community-alliance#350 save alias or combined values if…
Browse files Browse the repository at this point in the history
… readonly and force alias
  • Loading branch information
zonky2 committed Aug 12, 2017
1 parent cddfed2 commit f192f24
Showing 1 changed file with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general.
*
* (c) 2013-2016 Contao Community Alliance.
* (c) 2013-2017 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -23,7 +23,8 @@
* @author David Molineus <david.molineus@netzmacht.de>
* @author Cliff Parnitzky <github@cliff-parnitzky.de>
* @author Sven Baumann <baumann.sv@gmail.com>
* @copyright 2013-2016 Contao Community Alliance.
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2013-2017 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -293,16 +294,27 @@ public function updateModelFromPropertyBag($model, $propertyValues)

foreach ($propertyValues as $property => $value) {
try {
if (!$properties->hasProperty($property)) {
continue;
}

$extra = $properties->getProperty($property)->getExtra();
if (!empty($extra['readonly'])) {
if (empty($extra)) {
continue;
}

$model->setProperty($property, $value);
// Don´t save value if isset property readonly.
if (empty($extra['readonly'])) {
$model->setProperty($property, $value);
}

// Set property to generate alias or combined values.
if (!empty($extra['readonly']) && !empty($extra['alwaysSave'])) {
$model->setProperty($property, '');
}

// If always save is true, we need to mark the model as changed.
if ($properties->hasProperty($property)
&& ($extra = $properties->getProperty($property)->getExtra()) && isset($extra['alwaysSave'])
) {
if (!empty($extra['alwaysSave'])) {
$model->setMeta($model::IS_CHANGED, true);
}
} catch (\Exception $exception) {
Expand Down

0 comments on commit f192f24

Please sign in to comment.