public function persistEntity($obj, $values = [])
    {
        if ($values) {
            $reflectedObj = new \ReflectionClass($obj);
            foreach ($values as $key => $val) {
                $property = $reflectedObj->getProperty($key);
                $property->setAccessible(true);
                $property->setValue($obj, $val);
            }
        }

        $this->em->persist($obj);
        $this->em->flush();
    }
public function persistEntity($obj, $values = [])
    {
        if ($values) {
            $reflectedObj = new \ReflectionClass($obj);
            foreach ($values as $key => $val) {
                $property = $reflectedObj->getProperty($key);
                $property->setAccessible(true);
                $property->setValue($obj, $val);
            }
        }

        $this->em->persist($obj);
        $this->em->flush();
    }
public function persistEntity ( $ obj , $ values = [ ] ) { if ( $ values ) { $ reflectedObj = new \ ReflectionClass ( $ obj ) ; foreach ( $ values as $ key => $ val ) { $ property = $ reflectedObj -> getProperty ( $ key ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ obj , $ val ) ; } } $ this -> em -> persist ( $ obj ) ; $ this -> em -> flush ( ) ; }
Adds entity to repository and flushes. You can redefine it's properties with the second parameter.

Example:

``` php
<?php
$I->persistEntity(new \Entity\User, array('name' => 'Miles'));
$I->persistEntity($user, array('name' => 'Miles'));
```

@param $obj
@param array $values
Adds entity to repository and flushes . You can redefine it s properties with the second parameter .