Skip to content

Commit

Permalink
on second thought, RecordSets might contain records from different ma…
Browse files Browse the repository at this point in the history
…ppers
  • Loading branch information
Paul M. Jones committed Apr 19, 2018
1 parent d3f1494 commit 3fca546
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions src/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,32 +199,14 @@ public function delete(Record $record) : void
}

public function persist(
$recordOrRecordSet,
Record $record,
SplObjectStorage $tracker = null
) : void
{
if ($tracker === null) {
$tracker = new SplObjectStorage();
}

if ($recordOrRecordSet instanceof Record) {
$this->persistRecord($recordOrRecordSet, $tracker);
return;
}

if ($recordOrRecordSet instanceof RecordSet) {
$this->persistRecordSet($recordOrRecordSet, $tracker);
return;
}

throw Exception::invalidType('Record or RecordSet', $recordOrRecordSet);
}

protected function persistRecord(
Record $record,
SplObjectStorage $tracker
) : void
{
if ($tracker->contains($record)) {
return;
}
Expand All @@ -243,17 +225,6 @@ protected function persistRecord(
$this->relationships->persistAfterNative($record, $tracker);
}

protected function persistRecordSet(
RecordSet $recordSet,
SplObjectStorage $tracker
) : void
{
foreach ($recordSet as $record) {
$this->persistRecord($record, $tracker);
}
$recordSet->detachDeleted();
}

public function newRecord(array $fields = []) : Record
{
$row = $this->table->newRow($fields);
Expand Down

0 comments on commit 3fca546

Please sign in to comment.