app/console doctrine:mapping:convert annotation src/Xxxx/XxxxxBundle/Entity --from-database
# Regex replace
@ORM\\Index\(
\n@ORM\\\\Index\(
# String replace
, length=65535
# String replace
type="boolean", nullable=true)
type="boolean", nullable=true, options={"default"=0})
# Regex replace
\* @ORM\\Column\(name="(\w*)"(.*)\n \*/\n private \$(\w*)( = '0')?;
\* @ORM\\\\Column\(name="$1"$2\n * @Groups(\{"serialization", "deserialization"\})\n */\n private \\$$1;
Generate getters & setters for each entity
Then :
# Regex replace + Match case
\/\*\*\n \* \@param ([A-Z|\\][\w|\\]+) \$(\w*)(?:(?:\n \* ?)*) \@return \$this\n \*\/\n public function (\w*)\(\$(\w*)\)
\/\*\*\n \* \@param $1 \\$$2\n \*\n \* \@return \\$this\n \*\/\n public function $3\($1 \\$$2\ = null)
Duplicate the boolean getters
php-cs-fixer fix src/Xxxx/XxxxxBundle
Add the translatables fields in the migration script
app/console doctrine:mapping:info
app/console doctrine:schema:validate
ManyToOne relations to integers :
# Regex replace + Match case
\/\*\*\n \* \@var ([A-Z][\w|\\]+)\n \*\n \* \@ORM\\ManyToOne\((?:.*)\)\n \* \@ORM\\JoinColumn\(name\=\"(\w*)\"\, referencedColumnName\=\"id\"\)\n \* \@Groups\(\{\"serialization\"\, \"deserialization\"\}\)\n \*\/\n private \$(\w*)\;
\/\*\*\n \* \ManyToOne relation to $1\n \*\n \* \@var int\n \*\n \* @ORM\\\\Column\(name="$2", type="integer", nullable=true\)\n * @Groups\(\{"serialization", "deserialization"\}\)\n */\n private \\$$3Id;
\/\*\*\n \* \@param (?:[A-Z][\w|\\]+) \$(\w*)(?:(?:\n \* ?)*) \@return \$this\n \*\/\n public function (\w*)\((?:[A-Z][\w|\\]+) \$(\w*)\ = null\)\n \{\n \$this\-\>(?:\w*) \= \$(?:\w*)\;\n\n return \$this\;\n \}
\/\*\*\n \* \@param int \\$$1Id\n \*\n \* \@return \\$this\n \*\/\n public function $2Id\(\\$$1Id = null\)\n \{\n \\$this\-\>$1Id \= \\$$1Id\;\n\n return \\$this\;\n \}
\/\*\*\n \* \@param (?:[A-Z][\w|\\]+) \$(\w*)(?:(?:\n \* ?)*) \@return \$this\n \*\/\n public function (\w*)\(\$(\w*)\)\n \{\n \$this\-\>(?:\w*) \= \$(?:\w*)\;\n\n return \$this\;\n \}
\/\*\*\n \* \@param int \\$$1Id\n \*\n \* \@return \\$this\n \*\/\n public function $2Id\(\\$$1Id = null\)\n \{\n \\$this\-\>$1Id \= \\$$1Id\;\n\n return \\$this\;\n \}
\/\*\*\n \* \@return (?:[A-Z][\w|\\]+)\n \*\/\n public function (\w*)\(\)\n \{\n return \$this\-\>(\w*);\n \}
\/\*\*\n \* \@return int\n \*\/\n public function $1Id\(\)\n \{\n return \\$this->$2Id\;\n \}
\/\*\*\n \* ManyToOne relation to (\w*)\.?\n \*\n \* \@var int\n \*\n \* \@ORM\\Column\(name\=\"(\w*)\"\, type\=\"integer\"\, nullable\=true\)\n \* \@Groups\(\{\"serialization\"\, \"deserialization\"\}\)\n(?: \* \@Assert\\Type\(type\=\"integer\"\)\n)? \*\/
\/\*\*\n \* ManyToOne relation to $1.\n \*\n \* \@var int\n \*\n \* \@ORM\\\\Column\(name\=\"$2\"\, type\=\"integer\"\, nullable\=true\)\n \* \@Groups\(\{\"serialization\"\, \"deserialization\"\}\)\n \* \@Assert\\\\Type\(type\=\"integer\"\)\n \* @ORM\\\\Index\(name="key_index_$2", columns=\{"$2"\}\),TOMOVE\n \*\/
\/\*\*\n \* ManyToOne relation to (\w*)\.?\n \*\n \* \@var int\n \*\n \* \@ORM\\Column\(name\=\"(\w*)\"\, type\=\"integer\"\, nullable\=true\)\n \* \@Groups\(\{\"serialization\"\, \"deserialization\"\}\)\n \*\/
\/\*\*\n \* ManyToOne relation to $1.\n \*\n \* \@var int\n \*\n \* \@ORM\\\\Column\(name\=\"$2\"\, type\=\"integer\"\, nullable\=true\)\n \* \@Groups\(\{\"serialization\"\, \"deserialization\"\}\)\n \* \@Assert\\\\Type\(type\=\"integer\"\)\n \*\/
Then, move TOMOVE lines ... :/
find ./src -type f | grep '/Entity/' | xargs sed -i -e '/TOMOVE/!H;//p;$!d;g;s/\n//'
find ./src -type f | grep '/Entity/' | xargs -iFILE sh -c 'awk '\''/TOMOVE/ { line=$0 } /uniqueConstraints/ { $0 = line RS $0 } 1'\'' FILE > tmp && mv tmp FILE'
find ./src -type f | grep '/Entity/' | xargs sed -i -n '/<?php/,$p'#Regex replace
\}\)\n \* \@ORMIndex\(
\}\),\n \* \@ORMIndex\(
#WORD replace
TOMOVE
#Regex replace
\,\n \* \}\, uniqueConstraints
\n \* \}\, uniqueConstraints