Skip to content
Permalink
Browse files

Not baking tables with array-valued primary key where there is only,

one key, as in most cases it is just a hassle for end users
  • Loading branch information...
lorenzo committed Jul 12, 2014
1 parent 84a83fa commit 12c275501bc8d54021be62793124f56b50450c44
@@ -43,7 +43,11 @@ class <?= $name ?>Table extends Table {
<?php
$key = array_map(function($el) { return "'$el'"; }, (array)$primaryKey);
?>
<?php if (count($primaryKey) > 1): ?>
$this->primaryKey([<?= implode(', ', $key) ?>]);
<?php else: ?>
$this->primaryKey(<?= current($key) ?>);
<?php endif ?>
<?php endif ?>
<?php foreach ($behaviors as $behavior => $behaviorData): ?>
$this->addBehavior('<?= $behavior ?>'<?= $behaviorData ? ", [" . implode(', ', $behaviorData) . ']' : '' ?>);
@@ -738,7 +738,7 @@ public function testBakeTableConfig() {
$result = $this->Task->bakeTable($model, $config);
$this->assertContains('public function initialize(array $config) {', $result);
$this->assertContains("this->primaryKey(['id']);\n", $result);
$this->assertContains("this->primaryKey('id');\n", $result);
$this->assertContains("this->displayField('title');\n", $result);
$this->assertContains("this->addBehavior('Timestamp');\n", $result);
$this->assertContains("this->table('articles');\n", $result);

0 comments on commit 12c2755

Please sign in to comment.
You can’t perform that action at this time.