예제 #1
0
 /**
  * Shorthand to create or update a Property
  *
  * @return Property
  * @author Enrique Martinez
  **/
 public function setProperty($key, $value = null)
 {
     if (!($property = $this->findOneBy(array('key' => $key)))) {
         $property = new Property();
         $property->setKey($key);
     }
     $property->setValue($value);
     return $property;
 }
예제 #2
0
 protected function importProperties(\PDO $dbh, EntityManager $em)
 {
     $count = 0;
     $sth = $dbh->prepare('SELECT * FROM property');
     $sth->execute();
     $repo = $em->getRepository('SiwappConfigBundle:Property');
     foreach ($sth->fetchAll(\PDO::FETCH_ASSOC) as $row) {
         $property = $repo->find($row['keey']);
         if (!$property) {
             $property = new Property();
             $property->setKey($row['keey']);
         }
         $property->setValue(json_decode($row['value']));
         $em->persist($property);
         $count++;
     }
     return $count;
 }