contao-community-alliance / meta-palettes

Dynamic configured palettes for contao.
6 stars 8 forks source link

Fix model call #44

Closed zonky2 closed 2 years ago

zonky2 commented 3 years ago

Fix model call

Wenn "hofff_consent_bridge_consent_tool" installiert ist und bei MM Attribute Select mit Popup-Widget ausgewählt ist, kommt eine Fehlermeldung:

Symfony\Component\ErrorHandler\Error\UndefinedMethodError:
Attempted to call an undefined method named "getCurrentModel" of class "ContaoCommunityAlliance\DcGeneral\DefaultEnvironment".

  at vendor/contao-community-alliance/meta-palettes/src/Listener/SubSelectPalettesListener.php:163
  at ContaoCommunityAlliance\MetaPalettes\Listener\SubSelectPalettesListener->getValue(object(DcCompat), 'tl_page', 'hofff_consent_bridge_consent_tool')
     (vendor/contao-community-alliance/meta-palettes/src/Listener/SubSelectPalettesListener.php:88)
  at ContaoCommunityAlliance\MetaPalettes\Listener\SubSelectPalettesListener->onLoad(object(DcCompat))
     (vendor/contao-community-alliance/dc-general/src/Contao/Callback/Callbacks.php:75)
  at ContaoCommunityAlliance\DcGeneral\Contao\Callback\Callbacks::callArgs(array(object(SubSelectPalettesListener), 'onLoad'), array(object(DcCompat)))
     (vendor/contao-community-alliance/dc-general/src/Contao/Callback/AbstractCallbackListener.php:117)
  at ContaoCommunityAlliance\DcGeneral\Contao\Callback\AbstractCallbackListener->__invoke(object(CreateDcGeneralEvent), 'dc-general.factory.create-dc-general', object(TraceableEventDispatcher))

habe mir das mit @baumannsven angesehen... das kann wohl weg - getCurrentModel() haben wir nicht gefunden

        // try getting getCurrentModel value, provided by DC_General which is not neccessarily installed
        // therefore no instanceof check, do NOT(!) try to load via post if DC_General is in use, as it
        // has already updated the current model.
        if (method_exists($dataContainer, 'getEnvironment')) {
            $objModel = $dataContainer->getEnvironment()->getCurrentModel();
            return $this->getValueFromDcGeneralModel($objModel, $strSelector);
        }

        if (method_exists($dataContainer, 'getCurrentModel')) {
            $objModel = $dataContainer->getCurrentModel();
            return $this->getValueFromDcGeneralModel($objModel, $strSelector);
        }
zonky2 commented 2 years ago

@dmolineus was ist mit dem PR?

dmolineus commented 2 years ago

Why is the DcCompat used for tl_page at all? That's not the default behaviour of Contao.