diff --git a/README.md b/README.md index bf856f0..a4d88fa 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ propel: generator: defaultConnection: default connections: [ default ] - platformClass: \APinnecke\CompositeNumberRange\Platform\MysqlPlatform + platformClass: \FelixWillmann\CompositeNumberRange\Platform\MysqlPlatform ``` ## Add behavior to table @@ -69,7 +69,7 @@ Following the user <-> document example: ```xml - +
@@ -101,4 +101,4 @@ $userDocumentId = $document->getUserDocumentId(); ## Migrations Notice Because `propel:migrations:diff` does not know anything about triggers, they have to be checked via SQL Statement. If you use triggers and change something on any table having triggers appended, they will always appear in your `down()` section of the migration. At the moment you have to remove them by hand, -this bug will be solved in the future during Propel 2 release. \ No newline at end of file +this bug will be solved in the future during Propel 2 release. diff --git a/composer.json b/composer.json index 824af5d..3c161e9 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "apinnecke/composite-number-range-behavior", + "name": "felixwillmann/composite-number-range-behavior", "description": "A behavior providing composite number ranges with a foreign key and a composite key.", "license": "MIT", "require": { @@ -10,7 +10,7 @@ }, "autoload": { "psr-4": { - "APinnecke\\CompositeNumberRange\\": "src/" + "FelixWillmann\\CompositeNumberRange\\": "src/" } }, "authors": [ @@ -21,6 +21,6 @@ ], "extra": { "name": "composite_number_range", - "class": "\\APinnecke\\CompositeNumberRange\\CompositeNumberRangeBehavior" + "class": "\\FelixWillmann\\CompositeNumberRange\\CompositeNumberRangeBehavior" } } diff --git a/src/CompositeNumberRangeBehavior.php b/src/CompositeNumberRangeBehavior.php index 472608e..8d53ff9 100644 --- a/src/CompositeNumberRangeBehavior.php +++ b/src/CompositeNumberRangeBehavior.php @@ -1,6 +1,6 @@ null, - 'refPhpName' => null + 'refPhpName' => null, + 'phpName' => null, ); /** @@ -46,6 +47,18 @@ protected function getRefPhpName() return $name; } + /** + * Gets the phpName parameter from config array. + * will only be set if !== null + * + * @return string + */ + protected function getPhpName() + { + $name = $this->getParameter('phpName'); + return $name; + } + /** * Adds all columns, indexes, constraints and additional tables. */ @@ -54,6 +67,7 @@ public function modifyTable() $table = $this->getTable(); $tableName = $table->getName(); $foreignTableName = $this->getForeignTable(); + $phpName = $this->getPhpName(); // enable reload on insert to force the model to load the trigger generated id(s) $table->setReloadOnInsert(true); @@ -90,6 +104,9 @@ public function modifyTable() $foreignKey->setForeignTableCommonName($foreignTableName); $foreignKey->setOnUpdate(ForeignKey::CASCADE); $foreignKey->setOnDelete(ForeignKey::CASCADE); + if (null !== $phpName) { + $foreignKey->setPhpName($phpName); + } $table->addForeignKey($foreignKey); } diff --git a/src/Platform/MysqlPlatform.php b/src/Platform/MysqlPlatform.php index 7b556c7..033e627 100644 --- a/src/Platform/MysqlPlatform.php +++ b/src/Platform/MysqlPlatform.php @@ -1,15 +1,15 @@ - + @@ -159,4 +159,4 @@ public function testInsertThirdRowWithDifferentParentTableIdCreatesAnotherParent $this->assertEquals($child2->getParentTableChildTableId(), $sequence->getParentTableMaxSequenceId()); } } - \ No newline at end of file +