- 
                Notifications
    
You must be signed in to change notification settings  - Fork 36
 
Open
Description
So I have been using your exporter for a while and have experienced some problems with generating getters and setters.
Version: 3.1.3
The problem:
Without touching anything the some of the setters are the following:
    /**
     * Set Brand entity (many to one).
     */
    public function setBrand($brands)
    {
        $this->brands = $Brand;
        return $this;
    }
And the problem here is obvious.
The possible solution to this:
Open file "project_folder_name/public/vendor/mysql-workbench-schema-exporter/doctrine2-exporter/lib/Annotation/Model/Table.php", and edit the writer.
From (last method):
->write('public function set'.$nameSingular.'('.$typehints['set_arg'].'$'.$this->getNaming($foreign->getReferencedTable()->getName()).')'.$typehints['set_return'])
                    ->write('{')
                    ->indent()
                        ->write('$this->'.$this->getNaming($this->getRelatedVarName($foreign->getReferencedTable()->getName(), $related)).' = $'.$this->getNaming($foreign->getReferencedTable()->getModelName()).';')
To:
->write('public function set'.$nameSingular.'('.$typehints['set_arg'].'$'.$this->getNaming($foreign->getReferencedTable()->getName()).')'.$typehints['set_return'])
                    ->write('{')
                    ->indent()
                        ->write('$this->'.$this->getNaming($this->getRelatedVarName($foreign->getReferencedTable()->getName(), $related)).' = $'.$this->getNaming($foreign->getReferencedTable()->getName()).';')
Which fixes the setter methods like:
   /**
    * Set Brand entity (many to one).
    */
   public function setBrand($brands)
   {
       $this->brands = $brands;
       return $this;
   }
The export.json I am using to generate entities:
"export": "doctrine2-annotation",
 "zip": false,
 "dir": "...",
 "params": {
     "logToConsole": false,
     "logFile": "doc/wbexporter.log",
     "filename": "%entity%.%extension%",
     "indentation": 4,
     "useTabs": false,
     "eolDelimeter": "unix",
     "backupExistingFile": true,
     "addGeneratorInfoAsComment": false,
     "skipPluralNameChecking": false,
     "useLoggedStorage": false,
     "sortTablesAndViews": true,
     "exportOnlyTableCategorized": "",
     "enhanceManyToManyDetection": true,
     "skipManyToManyTables": true,
     "bundleNamespace": "App",
     "entityNamespace": "Entity",
     "repositoryNamespace": "",
     "useAutomaticRepository": true,
     "skipColumnWithRelation": false,
     "relatedVarNameFormat": "%name%%related%",
     "nullableAttribute": "auto",
     "generatedValueStrategy": "auto",
     "defaultCascade": false,
     "useAnnotationPrefix": "ORM\\",
     "skipGetterAndSetter": false,
     "generateEntitySerialization": true,
     "generateExtendableEntity": false,
     "quoteIdentifierStrategy": "auto",
     "extendsClass": "",
     "propertyTypehint": false,
     "extendableEntityHasDiscriminator": false
 }
Metadata
Metadata
Assignees
Labels
No labels