Skip to content

Commit

Permalink
Merge pull request #3 from sizuhiko/develop
Browse files Browse the repository at this point in the history
Release 0.1.1
  • Loading branch information
sizuhiko committed Mar 23, 2015
2 parents eec1d54 + d7ff95b commit 17c6eb9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Adaptor/CakeFabricateAdaptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class CakeFabricateAdaptor extends AbstractFabricateAdaptor
* If you want to validate each entity, set true.
*/
const OPTION_VALIDATE = "validate";
/**
* Application rles option.
* Default setting is false.
* If you want to check rules for each entity, set true.
*/
const OPTION_CHECK_RULES = "checkRules";

/** option values */
private $options;
Expand All @@ -43,6 +49,7 @@ public function __construct($options = [])
$defaults = [
self::OPTION_FILTER_KEY => false,
self::OPTION_VALIDATE => false,
self::OPTION_CHECK_RULES => false,
];
$this->options = array_merge($defaults, $options);
}
Expand Down Expand Up @@ -98,7 +105,10 @@ public function create($modelName, $attributes, $recordCount)
$entities = $table->newEntities($attributes, ['validate' => $this->options[self::OPTION_VALIDATE]]);
$table->connection()->transactional(function () use ($table, $entities) {
foreach ($entities as $entity) {
$ret = $table->save($entity);
$ret = $table->save($entity, [
'checkRules' => $this->options[self::OPTION_CHECK_RULES],
'atomic' => false
]);
if (!$ret) {
return false;
}
Expand Down

0 comments on commit 17c6eb9

Please sign in to comment.