Ejemplo n.º 1
0
 /**
  * Gets record (retrieved from repository if exists, or create new record!)
  *
  * @param  Table $table
  * @param  array $data
  * @param  bool  $exists
  * @throws \UnexpectedValueException
  * @return Record
  */
 public function getOrCreateRecord(Table $table, array $data, $exists = false)
 {
     $id = $table->getIdentifierAsString($data);
     if ($id !== false && $table->isInRepository($id)) {
         $record = $table->getFromRepository($id);
     } else {
         $record = $table->createRecord($data, $exists);
     }
     return $record;
 }