public function modelCommand($packageKey, $modelName, $force = false)
    {
        $this->validatePackageKey($packageKey);
        if (!$this->packageManager->isPackageAvailable($packageKey)) {
            $this->outputLine('Package "%s" is not available.', [$packageKey]);
            exit(2);
        }

        $this->validateModelName($modelName);

        $fieldsArguments = $this->request->getExceedingArguments();
        $fieldDefinitions = [];
        foreach ($fieldsArguments as $fieldArgument) {
            list($fieldName, $fieldType) = explode(':', $fieldArgument, 2);

            $fieldDefinitions[$fieldName] = ['type' => $fieldType];
            if (strpos($fieldType, 'array') !== false) {
                $fieldDefinitions[$fieldName]['typeHint'] = 'array';
            } elseif (strpos($fieldType, '\\') !== false) {
                if (strpos($fieldType, '<') !== false) {
                    $fieldDefinitions[$fieldName]['typeHint'] = substr($fieldType, 0, strpos($fieldType, '<'));
                } else {
                    $fieldDefinitions[$fieldName]['typeHint'] = $fieldType;
                }
            }
        };

        $generatedFiles = $this->generatorService->generateModel($packageKey, $modelName, $fieldDefinitions, $force);
        $this->outputLine(implode(PHP_EOL, $generatedFiles));
        $this->outputLine('As a new model was generated, don\'t forget to update the database schema with the respective doctrine:* commands.');
    }
public function modelCommand($packageKey, $modelName, $force = false)
    {
        $this->validatePackageKey($packageKey);
        if (!$this->packageManager->isPackageAvailable($packageKey)) {
            $this->outputLine('Package "%s" is not available.', [$packageKey]);
            exit(2);
        }

        $this->validateModelName($modelName);

        $fieldsArguments = $this->request->getExceedingArguments();
        $fieldDefinitions = [];
        foreach ($fieldsArguments as $fieldArgument) {
            list($fieldName, $fieldType) = explode(':', $fieldArgument, 2);

            $fieldDefinitions[$fieldName] = ['type' => $fieldType];
            if (strpos($fieldType, 'array') !== false) {
                $fieldDefinitions[$fieldName]['typeHint'] = 'array';
            } elseif (strpos($fieldType, '\\') !== false) {
                if (strpos($fieldType, '<') !== false) {
                    $fieldDefinitions[$fieldName]['typeHint'] = substr($fieldType, 0, strpos($fieldType, '<'));
                } else {
                    $fieldDefinitions[$fieldName]['typeHint'] = $fieldType;
                }
            }
        };

        $generatedFiles = $this->generatorService->generateModel($packageKey, $modelName, $fieldDefinitions, $force);
        $this->outputLine(implode(PHP_EOL, $generatedFiles));
        $this->outputLine('As a new model was generated, don\'t forget to update the database schema with the respective doctrine:* commands.');
    }
public function modelCommand ( $ packageKey , $ modelName , $ force = false ) { $ this -> validatePackageKey ( $ packageKey ) ; if ( ! $ this -> packageManager -> isPackageAvailable ( $ packageKey ) ) { $ this -> outputLine ( 'Package "%s" is not available.' , [ $ packageKey ] ) ; exit ( 2 ) ; } $ this -> validateModelName ( $ modelName ) ; $ fieldsArguments = $ this -> request -> getExceedingArguments ( ) ; $ fieldDefinitions = [ ] ; foreach ( $ fieldsArguments as $ fieldArgument ) { list ( $ fieldName , $ fieldType ) = explode ( ':' , $ fieldArgument , 2 ) ; $ fieldDefinitions [ $ fieldName ] = [ 'type' => $ fieldType ] ; if ( strpos ( $ fieldType , 'array' ) !== false ) { $ fieldDefinitions [ $ fieldName ] [ 'typeHint' ] = 'array' ; } elseif ( strpos ( $ fieldType , '\\' ) !== false ) { if ( strpos ( $ fieldType , '<' ) !== false ) { $ fieldDefinitions [ $ fieldName ] [ 'typeHint' ] = substr ( $ fieldType , 0 , strpos ( $ fieldType , '<' ) ) ; } else { $ fieldDefinitions [ $ fieldName ] [ 'typeHint' ] = $ fieldType ; } } } ; $ generatedFiles = $ this -> generatorService -> generateModel ( $ packageKey , $ modelName , $ fieldDefinitions , $ force ) ; $ this -> outputLine ( implode ( PHP_EOL , $ generatedFiles ) ) ; $ this -> outputLine ( 'As a new model was generated, don\'t forget to update the database schema with the respective doctrine:* commands.' ) ; }
Kickstart a new domain model

This command generates a new domain model class. The fields are specified as
a variable list of arguments with field name and type separated by a colon
(for example "title:string" "size:int" "type:MyType").

@param string $packageKey The package key of the package for the domain model
@param string $modelName The name of the new domain model class
@param boolean $force Overwrite any existing model.
@return string
@see neos.kickstarter:kickstart:repository
Kickstart a new domain model