Skip to content

Commit

Permalink
Added treatAsSingle param
Browse files Browse the repository at this point in the history
  • Loading branch information
sprain committed Feb 24, 2015
1 parent d707a1a commit 3d2dd7c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Autoloader/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function setContainer(ContainerInterface $container = null)
* @param \Doctrine\Common\Persistence\ObjectManager $manager
* @param array $setterMethods
*/
protected function autoload(array $data, ObjectManager $manager, array $setterMethods = null)
protected function autoload(array $data, ObjectManager $manager, array $setterMethods = null, array $treatAsSingle = array())
{
foreach($data as $item){

Expand All @@ -82,7 +82,7 @@ protected function autoload(array $data, ObjectManager $manager, array $setterMe
continue;
}

if (is_array($values)) {
if (is_array($values) && !in_array($key, $treatAsSingle)) {
//Example: turns value 'prices' into 'addPrice'
$func = 'add'.ucfirst(substr($key, 0, -1));

Expand Down Expand Up @@ -114,15 +114,15 @@ protected function autoload(array $data, ObjectManager $manager, array $setterMe

$manager->persist($entity);

//Flush after each element due to some possible EventListeners
//Flush after each element due to possible event listeners
$manager->flush();
}
}

/**
* Determines reference prefix
* Get reference prefix
*/
protected function getReferencePrefix()
public function getReferencePrefix()
{
if ($this->referencePrefix === null) {

Expand All @@ -136,9 +136,9 @@ protected function getReferencePrefix()
}

/**
* Determines entity class
* Get entity class to actually load data with
*/
protected function getEntityClass()
public function getEntityClass()
{
if ($this->entityClass === null) {

Expand Down

0 comments on commit 3d2dd7c

Please sign in to comment.