EventListener/ReportSubscriber.php
private function convertToExtendedFieldQuery()
    {
        $this->fieldModel   = $this->dispatcher->getContainer()->get('mautic.lead.model.field');
        $this->selectParts  = $this->query->getQueryPart('select');
        $this->orderByParts = $this->query->getQueryPart('orderBy');
        $this->groupByParts = $this->query->getQueryPart('groupBy');
        $this->filters      = $this->event->getReport()->getFilters();
        $this->where        = $this->query->getQueryPart('where');
        $this->fieldTables  = isset($this->fieldTables) ? $this->fieldTables : [];
        $this->count        = 0;
        if (!$this->extendedFields) {
            // Previous method deprecated:
            // $fields = $this->fieldModel->getEntities(
            //     [
            //         [
            //             'column' => 'f.isPublished',
            //             'expr'   => 'eq',
            //             'value'  => true,
            //         ],
            //         'force'          => [
            //             'column' => 'f.object',
            //             'expr'   => 'in',
            //             'value'  => ['extendedField', 'extendedFieldSecure'],
            //         ],
            //         'hydration_mode' => 'HYDRATE_ARRAY',
            //     ]
            // );
            // // Key by alias.
            // foreach ($fields as $field) {
            //     $this->extendedFields[$field['alias']] = $field;
            // }
            $this->extendedFields = $this->fieldModel->getExtendedFields();
        }

        $this->alterSelect();
        if (method_exists($this->event, 'getQuery')) { // identify ReportQueryEvent instance in backwards compatible way
            $this->alterOrderBy();
        }
        $this->alterGroupBy();
        $this->alterWhere();

        $this->query->select($this->selectParts);
        if (method_exists($this->event, 'getQuery') && !empty($this->orderByParts)) {
            $orderBy = implode(',', $this->orderByParts);
            $this->query->add('orderBy', $orderBy);
        }
        if (!empty($this->groupByParts)) {
            $this->query->groupBy($this->groupByParts);
        }
        if (!empty($this->where)) {
            $this->query->where($this->where);
        }
    }
private function convertToExtendedFieldQuery()
    {
        $this->fieldModel   = $this->dispatcher->getContainer()->get('mautic.lead.model.field');
        $this->selectParts  = $this->query->getQueryPart('select');
        $this->orderByParts = $this->query->getQueryPart('orderBy');
        $this->groupByParts = $this->query->getQueryPart('groupBy');
        $this->filters      = $this->event->getReport()->getFilters();
        $this->where        = $this->query->getQueryPart('where');
        $this->fieldTables  = isset($this->fieldTables) ? $this->fieldTables : [];
        $this->count        = 0;
        if (!$this->extendedFields) {
            // Previous method deprecated:
            // $fields = $this->fieldModel->getEntities(
            //     [
            //         [
            //             'column' => 'f.isPublished',
            //             'expr'   => 'eq',
            //             'value'  => true,
            //         ],
            //         'force'          => [
            //             'column' => 'f.object',
            //             'expr'   => 'in',
            //             'value'  => ['extendedField', 'extendedFieldSecure'],
            //         ],
            //         'hydration_mode' => 'HYDRATE_ARRAY',
            //     ]
            // );
            // // Key by alias.
            // foreach ($fields as $field) {
            //     $this->extendedFields[$field['alias']] = $field;
            // }
            $this->extendedFields = $this->fieldModel->getExtendedFields();
        }

        $this->alterSelect();
        if (method_exists($this->event, 'getQuery')) { // identify ReportQueryEvent instance in backwards compatible way
            $this->alterOrderBy();
        }
        $this->alterGroupBy();
        $this->alterWhere();

        $this->query->select($this->selectParts);
        if (method_exists($this->event, 'getQuery') && !empty($this->orderByParts)) {
            $orderBy = implode(',', $this->orderByParts);
            $this->query->add('orderBy', $orderBy);
        }
        if (!empty($this->groupByParts)) {
            $this->query->groupBy($this->groupByParts);
        }
        if (!empty($this->where)) {
            $this->query->where($this->where);
        }
    }
private function convertToExtendedFieldQuery ( ) { $ this -> fieldModel = $ this -> dispatcher -> getContainer ( ) -> get ( 'mautic.lead.model.field' ) ; $ this -> selectParts = $ this -> query -> getQueryPart ( 'select' ) ; $ this -> orderByParts = $ this -> query -> getQueryPart ( 'orderBy' ) ; $ this -> groupByParts = $ this -> query -> getQueryPart ( 'groupBy' ) ; $ this -> filters = $ this -> event -> getReport ( ) -> getFilters ( ) ; $ this -> where = $ this -> query -> getQueryPart ( 'where' ) ; $ this -> fieldTables = isset ( $ this -> fieldTables ) ? $ this -> fieldTables : [ ] ; $ this -> count = 0 ; if ( ! $ this -> extendedFields ) { // Previous method deprecated: // $fields = $this->fieldModel->getEntities( //     [ //         [ //             'column' => 'f.isPublished', //             'expr'   => 'eq', //             'value'  => true, //         ], //         'force'          => [ //             'column' => 'f.object', //             'expr'   => 'in', //             'value'  => ['extendedField', 'extendedFieldSecure'], //         ], //         'hydration_mode' => 'HYDRATE_ARRAY', //     ] // ); // // Key by alias. // foreach ($fields as $field) { //     $this->extendedFields[$field['alias']] = $field; // } $ this -> extendedFields = $ this -> fieldModel -> getExtendedFields ( ) ; } $ this -> alterSelect ( ) ; if ( method_exists ( $ this -> event , 'getQuery' ) ) { // identify ReportQueryEvent instance in backwards compatible way $ this -> alterOrderBy ( ) ; } $ this -> alterGroupBy ( ) ; $ this -> alterWhere ( ) ; $ this -> query -> select ( $ this -> selectParts ) ; if ( method_exists ( $ this -> event , 'getQuery' ) && ! empty ( $ this -> orderByParts ) ) { $ orderBy = implode ( ',' , $ this -> orderByParts ) ; $ this -> query -> add ( 'orderBy' , $ orderBy ) ; } if ( ! empty ( $ this -> groupByParts ) ) { $ this -> query -> groupBy ( $ this -> groupByParts ) ; } if ( ! empty ( $ this -> where ) ) { $ this -> query -> where ( $ this -> where ) ; } }
helper method to convert queries with extendedField optins
in select, orderBy and GroupBy to work with the
extendedField schema.
helper method to convert queries with extendedField optins in select orderBy and GroupBy to work with the extendedField schema .