public function checkQuery(EncodePropertyValueFromWidgetEvent $event)
    {
        if (!$this->scopeMatcher->currentScopeIsBackend()) {
            return;
        }

        if (('tl_metamodel_attribute' !== $event->getEnvironment()->getDataDefinition()->getName())
            || ('tag_where' !== $event->getProperty())
        ) {
            return;
        }

        $where  = $event->getValue();
        $values = $event->getPropertyValueBag();

        if ($where) {
            $query = $this->connection->createQueryBuilder()
                ->select($values->getPropertyValue('tag_table') . '.*')
                ->from($values->getPropertyValue('tag_table'))
                ->where($where)
                ->orderBy($values->getPropertyValue('tag_sorting') ?: $values->getPropertyValue('tag_id'));

            try {
                $query->execute();
            } catch (\Exception $e) {
                throw new \RuntimeException(
                    \sprintf(
                        '%s %s',
                        $this->translator->trans('sql_error', [], 'contao_tl_metamodel_attribute'),
                        $e->getMessage()
                    )
                );
            }
        }
    }
public function checkQuery(EncodePropertyValueFromWidgetEvent $event)
    {
        if (!$this->scopeMatcher->currentScopeIsBackend()) {
            return;
        }

        if (('tl_metamodel_attribute' !== $event->getEnvironment()->getDataDefinition()->getName())
            || ('tag_where' !== $event->getProperty())
        ) {
            return;
        }

        $where  = $event->getValue();
        $values = $event->getPropertyValueBag();

        if ($where) {
            $query = $this->connection->createQueryBuilder()
                ->select($values->getPropertyValue('tag_table') . '.*')
                ->from($values->getPropertyValue('tag_table'))
                ->where($where)
                ->orderBy($values->getPropertyValue('tag_sorting') ?: $values->getPropertyValue('tag_id'));

            try {
                $query->execute();
            } catch (\Exception $e) {
                throw new \RuntimeException(
                    \sprintf(
                        '%s %s',
                        $this->translator->trans('sql_error', [], 'contao_tl_metamodel_attribute'),
                        $e->getMessage()
                    )
                );
            }
        }
    }
public function checkQuery ( EncodePropertyValueFromWidgetEvent $ event ) { if ( ! $ this -> scopeMatcher -> currentScopeIsBackend ( ) ) { return ; } if ( ( 'tl_metamodel_attribute' !== $ event -> getEnvironment ( ) -> getDataDefinition ( ) -> getName ( ) ) || ( 'tag_where' !== $ event -> getProperty ( ) ) ) { return ; } $ where = $ event -> getValue ( ) ; $ values = $ event -> getPropertyValueBag ( ) ; if ( $ where ) { $ query = $ this -> connection -> createQueryBuilder ( ) -> select ( $ values -> getPropertyValue ( 'tag_table' ) . '.*' ) -> from ( $ values -> getPropertyValue ( 'tag_table' ) ) -> where ( $ where ) -> orderBy ( $ values -> getPropertyValue ( 'tag_sorting' ) ? : $ values -> getPropertyValue ( 'tag_id' ) ) ; try { $ query -> execute ( ) ; } catch ( \ Exception $ e ) { throw new \ RuntimeException ( \ sprintf ( '%s %s' , $ this -> translator -> trans ( 'sql_error' , [ ] , 'contao_tl_metamodel_attribute' ) , $ e -> getMessage ( ) ) ) ; } } }
Check if the select_where value is valid by firing a test query.

@param EncodePropertyValueFromWidgetEvent $event The event.

@return void

@throws \RuntimeException When the where condition is invalid.

@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName)
Check if the select_where value is valid by firing a test query .