src/Controller/Component/CsvViewComponent.php
protected function filterBatchFields(Event $event) : void
    {
        $config = new ModuleConfig(ConfigType::MIGRATION(), $this->request->getParam('controller'));
        $config = json_encode($config->parse());
        $fields = false === $config ? [] : json_decode($config, true);

        $batchFields = (array)Configure::read('CsvMigrations.batch.types');

        $nonBatchFields = [];
        foreach ($fields as $field) {
            $csvField = new CsvField($field);
            if (in_array($csvField->getType(), $batchFields)) {
                continue;
            }

            $nonBatchFields[] = $csvField->getName();
        }

        if (empty($nonBatchFields)) {
            return;
        }

        $controller = $event->getSubject();
        Assert::isInstanceOf($controller, Controller::class);

        $fields = $controller->viewVars['fields'];
        foreach ($fields as $panel => $panelFields) {
            foreach ($panelFields as $section => $sectionFields) {
                foreach ($sectionFields as $key => $field) {
                    if (!in_array($field['name'], $nonBatchFields)) {
                        continue;
                    }

                    $fields[$panel][$section][$key]['name'] = '';
                }
            }
        }

        $controller->viewVars['fields'] = $fields;
    }
protected function filterBatchFields(Event $event) : void
    {
        $config = new ModuleConfig(ConfigType::MIGRATION(), $this->request->getParam('controller'));
        $config = json_encode($config->parse());
        $fields = false === $config ? [] : json_decode($config, true);

        $batchFields = (array)Configure::read('CsvMigrations.batch.types');

        $nonBatchFields = [];
        foreach ($fields as $field) {
            $csvField = new CsvField($field);
            if (in_array($csvField->getType(), $batchFields)) {
                continue;
            }

            $nonBatchFields[] = $csvField->getName();
        }

        if (empty($nonBatchFields)) {
            return;
        }

        $controller = $event->getSubject();
        Assert::isInstanceOf($controller, Controller::class);

        $fields = $controller->viewVars['fields'];
        foreach ($fields as $panel => $panelFields) {
            foreach ($panelFields as $section => $sectionFields) {
                foreach ($sectionFields as $key => $field) {
                    if (!in_array($field['name'], $nonBatchFields)) {
                        continue;
                    }

                    $fields[$panel][$section][$key]['name'] = '';
                }
            }
        }

        $controller->viewVars['fields'] = $fields;
    }
protected function filterBatchFields ( Event $ event ) : void { $ config = new ModuleConfig ( ConfigType :: MIGRATION ( ) , $ this -> request -> getParam ( 'controller' ) ) ; $ config = json_encode ( $ config -> parse ( ) ) ; $ fields = false === $ config ? [ ] : json_decode ( $ config , true ) ; $ batchFields = ( array ) Configure :: read ( 'CsvMigrations.batch.types' ) ; $ nonBatchFields = [ ] ; foreach ( $ fields as $ field ) { $ csvField = new CsvField ( $ field ) ; if ( in_array ( $ csvField -> getType ( ) , $ batchFields ) ) { continue ; } $ nonBatchFields [ ] = $ csvField -> getName ( ) ; } if ( empty ( $ nonBatchFields ) ) { return ; } $ controller = $ event -> getSubject ( ) ; Assert :: isInstanceOf ( $ controller , Controller :: class ) ; $ fields = $ controller -> viewVars [ 'fields' ] ; foreach ( $ fields as $ panel => $ panelFields ) { foreach ( $ panelFields as $ section => $ sectionFields ) { foreach ( $ sectionFields as $ key => $ field ) { if ( ! in_array ( $ field [ 'name' ] , $ nonBatchFields ) ) { continue ; } $ fields [ $ panel ] [ $ section ] [ $ key ] [ 'name' ] = '' ; } } } $ controller -> viewVars [ 'fields' ] = $ fields ; }
Filter batch fields.

@param \Cake\Event\Event $event Event instance
@return void
Filter batch fields .