Ejemplo n.º 1
0
 public function load()
 {
     $file = file_get_contents(__DIR__ . '/data/store.json');
     $fileData = json_decode($file);
     foreach ($fileData as $data) {
         $entity = new Store();
         $entity->setName($data->name);
         $entity->setUser($data->{'user-id'});
         $entity->save();
         if (!$entity->save()) {
             throw new \Exception('Save fail: ' . implode("\n", $entity->getMessages()));
         }
     }
 }