Skip to content

Commit 6ad6ed2

Browse files
committed
Merge branch 'hotfix/fix_phpcq' into 'release/2.3.0'
Fix custom sql See merge request metamodels/core!387
2 parents 045a851 + 10cce67 commit 6ad6ed2

File tree

7 files changed

+72
-17
lines changed

7 files changed

+72
-17
lines changed

src/CoreBundle/EventListener/DcGeneral/MetaModel/CreateVariantButtonListener.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* This file is part of MetaModels/core.
55
*
6-
* (c) 2012-2024 The MetaModels team.
6+
* (c) 2012-2025 The MetaModels team.
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
@@ -17,7 +17,7 @@
1717
* @author Sven Baumann <[email protected]>
1818
* @author Richard Henkenjohann <[email protected]>
1919
* @author Ingolf Steinhardt <[email protected]>
20-
* @copyright 2012-2024 The MetaModels team.
20+
* @copyright 2012-2025 The MetaModels team.
2121
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later
2222
* @filesource
2323
*/
@@ -112,6 +112,9 @@ public function createButton(GetOperationButtonEvent $event)
112112
*
113113
* @return void
114114
*
115+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
116+
* @SuppressWarnings(PHPMD.NPathComplexity)
117+
*
115118
* @throws \RuntimeException When the base model can not be found.
116119
* @throws \InvalidArgumentException When the view in the environment is incompatible.
117120
*/
@@ -138,11 +141,21 @@ public function handleCreateVariantAction(ActionEvent $event)
138141
throw new \RuntimeException('No model id passed.');
139142
}
140143

144+
$doNotCopy = [];
145+
$properties = $environment->getDataDefinition()?->getPropertiesDefinition();
146+
foreach ($properties ?? [] as $property) {
147+
$extras = $property->getExtra();
148+
if (($extras['doNotCopy'] ?? false) === true) {
149+
$doNotCopy[] = $property->getName();
150+
}
151+
}
152+
141153
$model = $dataProvider
142154
->createVariant(
143155
$dataProvider
144156
->getEmptyConfig()
145-
->setId($modelId->getId())
157+
->setId($modelId->getId()),
158+
$doNotCopy
146159
);
147160

148161
if ($model === null) {

src/CoreBundle/Resources/translations/tl_metamodel_dcasetting.de.xlf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,17 @@
440440
<target>Backend-Klasse setzen</target>
441441
</trans-unit>
442442
<trans-unit id="mandatory_for_unique_attr" resname="mandatory_for_unique_attr">
443-
<source>Unique attribues are automatically mandatory (this is not changable).</source>
443+
<source>Unique attributes are automatically mandatory (this is not changable).</source>
444444
<target>Eindeutige (unique) Attribute sind automatisch Pflichtfelder (Einstellung nicht änderbar).</target>
445445
</trans-unit>
446446
<trans-unit id="readonly_for_force_alias" resname="readonly_for_force_alias">
447-
<source>Attribues with force alias are automatically readonly (this is not changable).</source>
447+
<source>Attributes with force alias are automatically readonly (this is not changable).</source>
448448
<target>Attribute mit &quot;Neuerstellung erzwingen&quot; sind automatisch &quot;nur lesend&quot; (Einstellung nicht änderbar).</target>
449449
</trans-unit>
450+
<trans-unit id="readonly_for_always_save" resname="readonly_for_always_save">
451+
<source>Attributes with always save are automatically readonly (this is not changable).</source>
452+
<target>Attribute mit &quot;Immer speichern&quot; sind automatisch &quot;nur lesend&quot; (Einstellung nicht änderbar).</target>
453+
</trans-unit>
450454
<trans-unit id="showRecord" resname="showRecord">
451455
<source>Show the details of record %id%</source>
452456
<target>Zeige Details Datensatz ID %id%.</target>

src/CoreBundle/Resources/translations/tl_metamodel_dcasetting.fr.xlf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,13 @@
343343
<source>Set backend class.</source>
344344
</trans-unit>
345345
<trans-unit id="mandatory_for_unique_attr" resname="mandatory_for_unique_attr">
346-
<source>Unique attribues are automatically mandatory (this is not changable).</source>
346+
<source>Unique attributes are automatically mandatory (this is not changable).</source>
347347
</trans-unit>
348348
<trans-unit id="readonly_for_force_alias" resname="readonly_for_force_alias">
349-
<source>Attribues with force alias are automatically readonly (this is not changable).</source>
349+
<source>Attributes with force alias are automatically readonly (this is not changable).</source>
350+
</trans-unit>
351+
<trans-unit id="readonly_for_always_save" resname="readonly_for_always_save">
352+
<source>Attributes with always save are automatically readonly (this is not changable).</source>
350353
</trans-unit>
351354
<trans-unit id="showRecord" resname="showRecord">
352355
<source>Show the details of record %id%</source>

src/CoreBundle/Resources/translations/tl_metamodel_filtersetting.de.xlf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,22 @@
267267
<source>Show this text as long as the field is empty.</source>
268268
<target>Diesen Text anzeigen solange das Fekld leer ist.</target>
269269
</trans-unit>
270+
<trans-unit id="use_only_in_env.label" resname="use_only_in_env.label">
271+
<source>Use SQL only in environment</source>
272+
<target>SQL Verwendung einschränken</target>
273+
</trans-unit>
274+
<trans-unit id="use_only_in_env.description" resname="use_only_in_env.description">
275+
<source>If active, the SQL is only executed in the selected environment - e.g. for example only in the backend.</source>
276+
<target>Wenn aktiv, wird das SQL nur in der ausgewählten Umgebung ausgeführt - also z. B. nur im Backend.</target>
277+
</trans-unit>
278+
<trans-unit id="use_only_in_env.only_backend" resname="use_only_in_env.only_backend">
279+
<source>Only in backend</source>
280+
<target>Nur im Backend</target>
281+
</trans-unit>
282+
<trans-unit id="use_only_in_env.only_frontend" resname="use_only_in_env.only_frontend">
283+
<source>Only in frontend</source>
284+
<target>Nur im Frontend</target>
285+
</trans-unit>
270286
<trans-unit id="sorting_directions.natsort_asc" resname="sorting_directions.natsort_asc">
271287
<source>Natural sorting (ASC)</source>
272288
<target>Natürliche Sortierung (aufsteigend)</target>

src/CoreBundle/Resources/translations/tl_metamodel_filtersetting.fr.xlf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,18 @@
223223
<trans-unit id="placeholder.description" resname="placeholder.description">
224224
<source>Show this text as long as the field is empty.</source>
225225
</trans-unit>
226+
<trans-unit id="use_only_in_env.label" resname="use_only_in_env.label">
227+
<source>Use SQL only in environment</source>
228+
</trans-unit>
229+
<trans-unit id="use_only_in_env.description" resname="use_only_in_env.description">
230+
<source>If active, the SQL is only executed in the selected environment - e.g. for example only in the backend.</source>
231+
</trans-unit>
232+
<trans-unit id="use_only_in_env.only_backend" resname="use_only_in_env.only_backend">
233+
<source>Only in backend</source>
234+
</trans-unit>
235+
<trans-unit id="use_only_in_env.only_frontend" resname="use_only_in_env.only_frontend">
236+
<source>Only in frontend</source>
237+
</trans-unit>
226238
<trans-unit id="sorting_directions.natsort_asc" resname="sorting_directions.natsort_asc">
227239
<source>Natural sorting (ASC)</source>
228240
</trans-unit>

src/DcGeneral/Data/Driver.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* This file is part of MetaModels/core.
55
*
6-
* (c) 2012-2024 The MetaModels team.
6+
* (c) 2012-2025 The MetaModels team.
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
@@ -19,7 +19,7 @@
1919
* @author Sven Baumann <[email protected]>
2020
* @author Richard Henkenjohann <[email protected]>
2121
* @author Ingolf Steinhardt <[email protected]>
22-
* @copyright 2012-2024 The MetaModels team.
22+
* @copyright 2012-2025 The MetaModels team.
2323
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later
2424
* @filesource
2525
*/
@@ -748,12 +748,15 @@ public function sameModels($firstModel, $secondModel)
748748
* Fetch a variant of a single record by id.
749749
*
750750
* @param ConfigInterface $objConfig The config holding the id of the base model.
751+
* @param array $doNotCopy The array of doNotCopy.
751752
*
752753
* @return null|ModelInterface
753754
*/
754-
public function createVariant(ConfigInterface $objConfig, $doNotCopy = [])
755+
public function createVariant(ConfigInterface $objConfig, array $doNotCopy = [])
755756
{
756-
$item = $this->getMetaModel()->findById($objConfig->getId());
757+
$metaModel = $this->getMetaModel();
758+
assert($metaModel instanceof IMetaModel);
759+
$item = $metaModel->findById($objConfig->getId());
757760
assert($item instanceof IItem);
758761
$objItem = $item->varCopy();
759762

@@ -831,7 +834,7 @@ public function getFallbackLanguage($mixID)
831834
/**
832835
* Set the current working language for the whole data provider.
833836
*
834-
* @param string $language The new language, use short tag "2 chars like de, fr etc.".
837+
* @param string $language The new language, use short tag "2 chars like de, for etc.".
835838
*
836839
* @return DataProviderInterface
837840
*/

src/Filter/Setting/CustomSql.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,19 @@ public function get($strKey)
155155
*/
156156
public function prepareRules(IFilter $objFilter, $arrFilterUrl)
157157
{
158-
$scopeDeterminator = System::getContainer()?->get('cca.dc-general.scope-matcher');
159-
assert($scopeDeterminator instanceof RequestScopeDeterminator);
158+
$scopeMatcher = System::getContainer()?->get('cca.dc-general.scope-matcher');
160159

161160
$useOnlyAtEnv = $this->get('use_only_in_env') ?? false;
162161

163-
if (!$useOnlyAtEnv
162+
if (
163+
false === $useOnlyAtEnv
164164
|| (
165-
('only_backend' === $useOnlyAtEnv && $scopeDeterminator->currentScopeIsBackend())
166-
|| ('only_frontend' === $useOnlyAtEnv && $scopeDeterminator->currentScopeIsFrontend())
165+
('only_backend' === $useOnlyAtEnv && null !== $scopeMatcher && $scopeMatcher->currentScopeIsBackend())
166+
|| (
167+
'only_frontend' === $useOnlyAtEnv
168+
&& null !== $scopeMatcher
169+
&& $scopeMatcher->currentScopeIsFrontend()
170+
)
167171
)
168172
) {
169173
$this->filterParameters = $arrFilterUrl;

0 commit comments

Comments
 (0)