src/Shell/SeedShell.php
protected function populateDataInModule(string $moduleName) : void
    {
        if ('' === $moduleName) {
            return;
        }

        if (in_array($moduleName, $this->skipModules)) {
            return;
        }

        $module = $this->getCSVModuleAttr($moduleName);

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

        $table = TableRegistry::get($moduleName);

        for ($count = 0; $count < $this->numberOfRecords; $count++) {
            $entity = $table->newEntity();

            $data = [];
            foreach ($module as $fieldName => $fieldData) {
                if (empty($fieldData['type'])) {
                    continue;
                }

                if ($this->isCombinedField($fieldData['type'])) {
                    $fields = $this->getCombinedFieldValueBasedOnType($fieldData['type'], '', (string)$fieldName);
                    foreach ($fields as $field => $value) {
                        $data[$field] = $value;
                    }
                    continue;
                }

                $fieldValue = $this->getFieldValueBasedOnType($fieldData['type']);
                if (empty($fieldValue)) {
                    continue;
                }
                $data[$fieldName] = $fieldValue;
            }
            $entity = $table->patchEntity($entity, $data);
            if ($table->save($entity)) {
                $id = $entity->id;
            }
        }
        $this->modulesPolpulatedWithData[] = $moduleName;
        $this->out($moduleName);
    }
protected function populateDataInModule(string $moduleName) : void
    {
        if ('' === $moduleName) {
            return;
        }

        if (in_array($moduleName, $this->skipModules)) {
            return;
        }

        $module = $this->getCSVModuleAttr($moduleName);

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

        $table = TableRegistry::get($moduleName);

        for ($count = 0; $count < $this->numberOfRecords; $count++) {
            $entity = $table->newEntity();

            $data = [];
            foreach ($module as $fieldName => $fieldData) {
                if (empty($fieldData['type'])) {
                    continue;
                }

                if ($this->isCombinedField($fieldData['type'])) {
                    $fields = $this->getCombinedFieldValueBasedOnType($fieldData['type'], '', (string)$fieldName);
                    foreach ($fields as $field => $value) {
                        $data[$field] = $value;
                    }
                    continue;
                }

                $fieldValue = $this->getFieldValueBasedOnType($fieldData['type']);
                if (empty($fieldValue)) {
                    continue;
                }
                $data[$fieldName] = $fieldValue;
            }
            $entity = $table->patchEntity($entity, $data);
            if ($table->save($entity)) {
                $id = $entity->id;
            }
        }
        $this->modulesPolpulatedWithData[] = $moduleName;
        $this->out($moduleName);
    }
protected function populateDataInModule ( string $ moduleName ) : void { if ( '' === $ moduleName ) { return ; } if ( in_array ( $ moduleName , $ this -> skipModules ) ) { return ; } $ module = $ this -> getCSVModuleAttr ( $ moduleName ) ; if ( empty ( $ module ) ) { return ; } $ table = TableRegistry :: get ( $ moduleName ) ; for ( $ count = 0 ; $ count < $ this -> numberOfRecords ; $ count ++ ) { $ entity = $ table -> newEntity ( ) ; $ data = [ ] ; foreach ( $ module as $ fieldName => $ fieldData ) { if ( empty ( $ fieldData [ 'type' ] ) ) { continue ; } if ( $ this -> isCombinedField ( $ fieldData [ 'type' ] ) ) { $ fields = $ this -> getCombinedFieldValueBasedOnType ( $ fieldData [ 'type' ] , '' , ( string ) $ fieldName ) ; foreach ( $ fields as $ field => $ value ) { $ data [ $ field ] = $ value ; } continue ; } $ fieldValue = $ this -> getFieldValueBasedOnType ( $ fieldData [ 'type' ] ) ; if ( empty ( $ fieldValue ) ) { continue ; } $ data [ $ fieldName ] = $ fieldValue ; } $ entity = $ table -> patchEntity ( $ entity , $ data ) ; if ( $ table -> save ( $ entity ) ) { $ id = $ entity -> id ; } } $ this -> modulesPolpulatedWithData [ ] = $ moduleName ; $ this -> out ( $ moduleName ) ; }
Insert data into module.

@param string $moduleName module name.
@return void
Insert data into module .