Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/reset fallback #321

Merged
merged 5 commits into from
Dec 8, 2016
Merged

Hotfix/reset fallback #321

merged 5 commits into from
Dec 8, 2016

Conversation

discordier
Copy link
Member

This is an attempt to solve #303 (which is duped by MetaModels/core#35).

We are now examining the parent child relationship of the data container to determine the siblings of the passed model and reset only within those.

Additionally, the method DataProviderInterface::resetFallback() has been deprecated, as it won't be possible to implement it properly without passing a config and/or making the driver stateful of which both are not good at all.

I like the approach to shift the responsibility into the reset listener much more.

Please test this implementation, I performed tests with MetaModels/core and defining render settings and input screens worked again.

This is now correctly handled in FallbackResetSubscriber and should be
handled in user land respectively for all occasions where the subscriber
is not available.
This is needed as we have no clue how to filter the values otherwise.
We now determine the reset behaviour by examining the parent child
relationship definitions.
@discordier discordier added this to the 2.0.0 milestone Dec 7, 2016
@discordier discordier self-assigned this Dec 7, 2016
@zonky2
Copy link
Contributor

zonky2 commented Dec 8, 2016

I have testet and works fine for

Rendersettings

shot301

Input mask

shot300

Grouping & sorting

shot302

but in which case we can use "isDefault" for rendersetting and input mask?

@discordier discordier merged commit 5689fe7 into hotfix/beta-39 Dec 8, 2016
discordier added a commit that referenced this pull request Dec 8, 2016
This is an attempt to solve #303 (which is duped by MetaModels/core#35).

Deprecates `DataProviderInterface::resetFallback()`.
@discordier discordier deleted the hotfix/reset-fallback branch December 8, 2016 17:02
@zonky2
Copy link
Contributor

zonky2 commented Dec 11, 2016

I found a warning with

  • DCG dev-hotfix/reset-fallback (5689fe7)
  • MM core dev-hotfix/alpha-15 (94cf9fab)

if I open the list of attributes (attribut icon) we have the follow warning

Warning: array_merge_recursive(): Argument #2 is not an array in composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\Contao\Dca\Builder\Legacy\ExtendedLegacyDcaDataDefinitionBuilder.php on line 437

#0 [internal function]: __error(2, 'array_merge_rec...', 'C:\\Contao2Go\\ht...', 437, Array)
#1 composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\Contao\Dca\Builder\Legacy\ExtendedLegacyDcaDataDefinitionBuilder.php(437): array_merge_recursive(Array, NULL)
#2 composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\Contao\Dca\Builder\Legacy\ExtendedLegacyDcaDataDefinitionBuilder.php(477): ContaoCommunityAlliance\DcGeneral\Contao\Dca\Builder\Legacy\ExtendedLegacyDcaDataDefinitionBuilder->parseParentChildConditions(Object(ContaoCommunityAlliance\DcGeneral\DataDefinition\Definition\DefaultModelRelationshipDefinition))
#3 composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\Contao\Dca\Builder\Legacy\ExtendedLegacyDcaDataDefinitionBuilder.php(68): ContaoCommunityAlliance\DcGeneral\Contao\Dca\Builder\Legacy\ExtendedLegacyDcaDataDefinitionBuilder->parseConditions(Object(ContaoCommunityAlliance\DcGeneral\DataDefinition\DefaultContainer))
#4 composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\DataDefinition\Builder\AbstractEventDrivenDataDefinitionBuilder.php(96): ContaoCommunityAlliance\DcGeneral\Contao\Dca\Builder\Legacy\ExtendedLegacyDcaDataDefinitionBuilder->build(Object(ContaoCommunityAlliance\DcGeneral\DataDefinition\DefaultContainer), Object(ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent))
#5 [internal function]: ContaoCommunityAlliance\DcGeneral\DataDefinition\Builder\AbstractEventDrivenDataDefinitionBuilder->process(Object(ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent), 'dc-general.fact...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#6 composer\vendor\symfony\event-dispatcher\EventDispatcher.php(184): call_user_func(Array, Object(ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent), 'dc-general.fact...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#7 composer\vendor\symfony\event-dispatcher\EventDispatcher.php(46): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'dc-general.fact...', Object(ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent))
#8 composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\Factory\DcGeneralFactory.php(392): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('dc-general.fact...', Object(ContaoCommunityAlliance\DcGeneral\Factory\Event\BuildDataDefinitionEvent))
#9 composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\Factory\DcGeneralFactory.php(336): ContaoCommunityAlliance\DcGeneral\Factory\DcGeneralFactory->createContainer()
#10 composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\Factory\DcGeneralFactory.php(298): ContaoCommunityAlliance\DcGeneral\Factory\DcGeneralFactory->createEnvironment()
#11 composer\vendor\contao-community-alliance\dc-general\src\ContaoCommunityAlliance\DcGeneral\DC\General.php(80): ContaoCommunityAlliance\DcGeneral\Factory\DcGeneralFactory->createDcGeneral()
#12 system\modules\core\classes\Backend.php(408): ContaoCommunityAlliance\DcGeneral\DC_General->__construct('tl_metamodel_at...', Array)
#13 system\modules\core\controllers\BackendMain.php(131): Contao\Backend->getBackendModule('metamodels')
#14 contao\main.php(20): Contao\BackendMain->run()
#15 {main}

@discordier
Copy link
Member Author

This does not happen on my side. I can list the attributes just fine.

@zonky2
Copy link
Contributor

zonky2 commented Dec 12, 2016

is fixed with #323

@zonky2
Copy link
Contributor

zonky2 commented Jan 29, 2018

this implementation MetaModels/core#1213 have a bug in https://github.com/contao-community-alliance/dc-general/blob/master/src/ContaoCommunityAlliance/DcGeneral/Contao/Subscriber/FallbackResetSubscriber.php#L90

this method should reset the parameter e.g. "isdefault" only if the new item is set as default (=1)

    private function handleFallback(AbstractModelAwareEvent $event)
    {
        $model        = $event->getModel();
        $dataProvider = $event->getEnvironment()->getDataProvider($model->getProviderName());
        $properties   = $event->getEnvironment()->getDataDefinition()->getPropertiesDefinition();

        foreach (array_keys($model->getPropertiesAsArray()) as $propertyName) {
            if (!$properties->hasProperty($propertyName)) {
                continue;
            }

            $extra = (array) $properties->getProperty($propertyName)->getExtra();
            if (array_key_exists('fallback', $extra) && (true === $extra['fallback'])) {
                // BC Layer - use old reset fallback methodology until it get's removed.
                if (null === ($config = $this->determineFilterConfig($event))) {
                    // @codingStandardsIgnoreStart
                    @trigger_error(
                        'DataProviderInterface::resetFallback is deprecated - ' .
                        'Please specify proper parent child relationship',
                        E_USER_DEPRECATED
                    );
                    // @codingStandardsIgnoreEnd

                    $dataProvider->resetFallback($propertyName);
                }

+                if (!$model->getProperty($propertyName)) {
+                    continue;
+                }

                $models = $dataProvider->fetchAll($config);

                foreach ($models as $resetModel) {
                    if ($model->getId() === $resetModel->getId()) {
                        continue;
                    }
                    $resetModel->setProperty($propertyName, null);
                    $dataProvider->save($resetModel);
                }
            }
        }
    }
``

@discordier
Copy link
Member Author

Please open a new ticket in instead of necroposting to merged pull requests.
Please reference this PR in the ticket.

zonky2 added a commit to zonky2/dc-general that referenced this pull request Feb 1, 2018
@zonky2
Copy link
Contributor

zonky2 commented Feb 1, 2018

done #402

zonky2 added a commit to zonky2/dc-general that referenced this pull request Feb 1, 2018
zonky2 added a commit to zonky2/dc-general that referenced this pull request Feb 17, 2018
baumannsven added a commit that referenced this pull request Mar 10, 2018
Bug fix release

This release has:
- Hotfix reset fallback PR #321
- Hotfix add HTML class at buttons PR #399
- Feature override/edit all PR #359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants