src/Contao/View/Contao2BackendView/ButtonRenderer.php
private function isTogglerInActiveState($command, $model)
    {
        $dataProvider = $this->environment->getDataProvider($model->getProviderName());
        $propModel    = $model;

        if ($command instanceof TranslatedToggleCommandInterface
            && $dataProvider instanceof MultiLanguageDataProviderInterface
        ) {
            $language = $dataProvider->getCurrentLanguage();
            $dataProvider->setCurrentLanguage($command->getLanguage());
            $propModel = $dataProvider->fetch(
                $dataProvider
                    ->getEmptyConfig()
                    ->setId($model->getId())
                    ->setFields([$command->getToggleProperty()])
            );
            $dataProvider->setCurrentLanguage($language);
        }

        if ($command->isInverse()) {
            return !$propModel->getProperty($command->getToggleProperty());
        }

        return (bool) $propModel->getProperty($command->getToggleProperty());
    }
private function isTogglerInActiveState($command, $model)
    {
        $dataProvider = $this->environment->getDataProvider($model->getProviderName());
        $propModel    = $model;

        if ($command instanceof TranslatedToggleCommandInterface
            && $dataProvider instanceof MultiLanguageDataProviderInterface
        ) {
            $language = $dataProvider->getCurrentLanguage();
            $dataProvider->setCurrentLanguage($command->getLanguage());
            $propModel = $dataProvider->fetch(
                $dataProvider
                    ->getEmptyConfig()
                    ->setId($model->getId())
                    ->setFields([$command->getToggleProperty()])
            );
            $dataProvider->setCurrentLanguage($language);
        }

        if ($command->isInverse()) {
            return !$propModel->getProperty($command->getToggleProperty());
        }

        return (bool) $propModel->getProperty($command->getToggleProperty());
    }
private function isTogglerInActiveState ( $ command , $ model ) { $ dataProvider = $ this -> environment -> getDataProvider ( $ model -> getProviderName ( ) ) ; $ propModel = $ model ; if ( $ command instanceof TranslatedToggleCommandInterface && $ dataProvider instanceof MultiLanguageDataProviderInterface ) { $ language = $ dataProvider -> getCurrentLanguage ( ) ; $ dataProvider -> setCurrentLanguage ( $ command -> getLanguage ( ) ) ; $ propModel = $ dataProvider -> fetch ( $ dataProvider -> getEmptyConfig ( ) -> setId ( $ model -> getId ( ) ) -> setFields ( [ $ command -> getToggleProperty ( ) ] ) ) ; $ dataProvider -> setCurrentLanguage ( $ language ) ; } if ( $ command -> isInverse ( ) ) { return ! $ propModel -> getProperty ( $ command -> getToggleProperty ( ) ) ; } return ( bool ) $ propModel -> getProperty ( $ command -> getToggleProperty ( ) ) ; }
Determine the toggle state of a toggle command.

@param ToggleCommandInterface $command The toggle command.
@param ModelInterface         $model   The model in scope.

@return bool
Determine the toggle state of a toggle command .