public function generateModel($packageKey, $modelName, array $fieldDefinitions, $overwrite = false)
    {
        list($baseNamespace, $namespaceEntryPath) = $this->getPrimaryNamespaceAndEntryPath($this->packageManager->getPackage($packageKey));
        $modelName = ucfirst($modelName);
        $namespace = trim($baseNamespace, '\\') . '\\Domain\\Model';
        $fieldDefinitions = $this->normalizeFieldDefinitions($fieldDefinitions, $namespace);

        $templatePathAndFilename = 'resource://Neos.Kickstarter/Private/Generator/Model/EntityTemplate.php.tmpl';

        $contextVariables = [];
        $contextVariables['packageKey'] = $packageKey;
        $contextVariables['modelName'] = $modelName;
        $contextVariables['fieldDefinitions'] = $fieldDefinitions;
        $contextVariables['namespace'] = $namespace;

        $fileContent = $this->renderTemplate($templatePathAndFilename, $contextVariables);

        $modelFilename = $modelName . '.php';
        $modelPath = $namespaceEntryPath . '/Domain/Model/';
        $targetPathAndFilename = $modelPath . $modelFilename;

        $this->generateFile($targetPathAndFilename, $fileContent, $overwrite);

        $this->generateTestsForModel($packageKey, $modelName, $overwrite);

        return $this->generatedFiles;
    }
public function generateModel($packageKey, $modelName, array $fieldDefinitions, $overwrite = false)
    {
        list($baseNamespace, $namespaceEntryPath) = $this->getPrimaryNamespaceAndEntryPath($this->packageManager->getPackage($packageKey));
        $modelName = ucfirst($modelName);
        $namespace = trim($baseNamespace, '\\') . '\\Domain\\Model';
        $fieldDefinitions = $this->normalizeFieldDefinitions($fieldDefinitions, $namespace);

        $templatePathAndFilename = 'resource://Neos.Kickstarter/Private/Generator/Model/EntityTemplate.php.tmpl';

        $contextVariables = [];
        $contextVariables['packageKey'] = $packageKey;
        $contextVariables['modelName'] = $modelName;
        $contextVariables['fieldDefinitions'] = $fieldDefinitions;
        $contextVariables['namespace'] = $namespace;

        $fileContent = $this->renderTemplate($templatePathAndFilename, $contextVariables);

        $modelFilename = $modelName . '.php';
        $modelPath = $namespaceEntryPath . '/Domain/Model/';
        $targetPathAndFilename = $modelPath . $modelFilename;

        $this->generateFile($targetPathAndFilename, $fileContent, $overwrite);

        $this->generateTestsForModel($packageKey, $modelName, $overwrite);

        return $this->generatedFiles;
    }
public function generateModel ( $ packageKey , $ modelName , array $ fieldDefinitions , $ overwrite = false ) { list ( $ baseNamespace , $ namespaceEntryPath ) = $ this -> getPrimaryNamespaceAndEntryPath ( $ this -> packageManager -> getPackage ( $ packageKey ) ) ; $ modelName = ucfirst ( $ modelName ) ; $ namespace = trim ( $ baseNamespace , '\\' ) . '\\Domain\\Model' ; $ fieldDefinitions = $ this -> normalizeFieldDefinitions ( $ fieldDefinitions , $ namespace ) ; $ templatePathAndFilename = 'resource://Neos.Kickstarter/Private/Generator/Model/EntityTemplate.php.tmpl' ; $ contextVariables = [ ] ; $ contextVariables [ 'packageKey' ] = $ packageKey ; $ contextVariables [ 'modelName' ] = $ modelName ; $ contextVariables [ 'fieldDefinitions' ] = $ fieldDefinitions ; $ contextVariables [ 'namespace' ] = $ namespace ; $ fileContent = $ this -> renderTemplate ( $ templatePathAndFilename , $ contextVariables ) ; $ modelFilename = $ modelName . '.php' ; $ modelPath = $ namespaceEntryPath . '/Domain/Model/' ; $ targetPathAndFilename = $ modelPath . $ modelFilename ; $ this -> generateFile ( $ targetPathAndFilename , $ fileContent , $ overwrite ) ; $ this -> generateTestsForModel ( $ packageKey , $ modelName , $ overwrite ) ; return $ this -> generatedFiles ; }
Generate a model for the package with the given model name and fields

@param string $packageKey The package key of the controller's package
@param string $modelName The name of the new model
@param array $fieldDefinitions The field definitions
@param boolean $overwrite Overwrite any existing files?
@return array An array of generated filenames
Generate a model for the package with the given model name and fields