Knp\Bundle\KnpBundlesBundle\Entity\Bundle::fromArray PHP Method

fromArray() public method

public fromArray ( array $data )
$data array
    public function fromArray(array $data)
    {
        foreach ($data as $key => $value) {
            $this->{'set' . $key}($value);
        }
        $this->recalculateScore();
    }

Usage Example

Example #1
0
 /**
  * @Given /^the site has following bundles:$/
  */
 public function theSiteHasFollowingBundles(TableNode $table)
 {
     $entityManager = $this->getEntityManager();
     foreach ($table->getHash() as $row) {
         $user = $this->users[$row['username']];
         $bundle = new Entity\Bundle();
         $bundle->fromArray(array('name' => $row['name'], 'user' => $user, 'username' => $user->getName(), 'description' => $row['description'], 'lastCommitAt' => new \DateTime($row['lastCommitAt'])));
         $bundle->setScore($row['score']);
         $this->setPrivateProperty($bundle, "trend1", $row['trend1']);
         $entityManager->persist($bundle);
     }
     $entityManager->flush();
 }
All Usage Examples Of Knp\Bundle\KnpBundlesBundle\Entity\Bundle::fromArray