Skip to content

Commit

Permalink
Merge pull request #15 from loadsys/b/maintain-fixed-ids
Browse files Browse the repository at this point in the history
Sets accessibleFields for all fields by default.
  • Loading branch information
beporter committed Oct 26, 2015
2 parents 58f1fff + cb58dad commit ef8dd69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ $data = [
/**
* The _entityOptions array is passed to Table::newEntity() and
* Table::patchEntity(). It can be used to disable validation.
*
* Also be aware that the Shell sets
* `['accessibleFields' => ['*' => true]]` by default in order to
* more easily "prime" new Entities with all of the values
* specified in $data, including fixed primary keys. This bypasses
* your normal Entity `::$_accessible` settings, so it's good to
* be aware of this if you're using a seed to "refresh" existing
* data.
*/
//'_entityOptions' => [
// 'validate' => false,
Expand Down
7 changes: 4 additions & 3 deletions src/Shell/BasicSeedShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public function entityGenerator(
) {
$defaultOptions = [
'validate' => true,
'accessibleFields' => ['*' => true],
];
$options = $options + $defaultOptions;

Expand All @@ -204,8 +205,7 @@ public function entityGenerator(
}

} else {
$entity = $Table->newEntity([], $options);
$entity->set($r, ['guard' => false]);
$entity = $Table->newEntity($r, $options);
$entity->isNew(true);
}

Expand All @@ -217,7 +217,7 @@ public function entityGenerator(
if ($errors) {
$this->printValidationErrors(
$Table->alias(),
$key,
$id,
$errors
);

Expand All @@ -241,6 +241,7 @@ public function entityGenerator(
public function importTable(Table $Table, $records, array $options = []) {
$defaultOptions = [
'checkRules' => true,
'checkExisting' => true,
];
$options = $options + $defaultOptions;

Expand Down

0 comments on commit ef8dd69

Please sign in to comment.