Skip to content

Commit

Permalink
Fixed excluded
Browse files Browse the repository at this point in the history
  • Loading branch information
omerucel committed Jul 10, 2013
1 parent 19e0220 commit 4e0a121
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -57,6 +57,11 @@ class User
*/
public $status;

/**
* @var array
*/
public $service_ids = array();

/**
* @return bool
*/
Expand All @@ -80,6 +85,7 @@ class UserProducer extends ModelProducerProxyAbstract
{
protected static $tableName = 'user';
protected static $modelClass = 'OurApplication\Model\User';
protected static $excludedFields = array('service_ids');

public function getDefinition()
{
Expand Down
8 changes: 7 additions & 1 deletion src/Fabrika/Producer/ModelProducer.php
Expand Up @@ -69,7 +69,13 @@ public function build(array $attributes = null)
public function create(array $attributes = null)
{
$class = $this->build($attributes);
$attributes = get_object_vars($class);
$tempAttributes = get_object_vars($class);
$attributes = array();
foreach ($tempAttributes as $key => $value) {
if (!in_array($key, $this->excludedFields)) {
$attributes[$key] = $value;
}
}

$attributeKeys = implode(', ', array_keys($attributes));
$attributeValues = substr(str_repeat('?,', count($attributes)), 0, -1);
Expand Down

0 comments on commit 4e0a121

Please sign in to comment.