Skip to content

Commit eb578eb

Browse files
committed
Revert breaking change to adapter persist method
1 parent cbcf2d5 commit eb578eb

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

src/Adapter/AbstractResourceAdapter.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ abstract protected function fillAttributes($record, Collection $attributes);
6666
* Persist changes to the record.
6767
*
6868
* @param $record
69-
* @param bool $creating
70-
* whether the record is being created.
7169
* @return AsynchronousProcess|null
7270
*/
73-
abstract protected function persist($record, $creating);
71+
abstract protected function persist($record);
7472

7573
/**
7674
* @inheritdoc
@@ -80,7 +78,7 @@ public function create(array $document, EncodingParametersInterface $parameters)
8078
$resource = ResourceObject::create($document['data']);
8179
$record = $this->createRecord($resource);
8280

83-
return $this->fillAndPersist($record, $resource, $parameters, true);
81+
return $this->fillAndPersist($record, $resource, $parameters);
8482
}
8583

8684
/**
@@ -98,7 +96,7 @@ public function update($record, array $document, EncodingParametersInterface $pa
9896
{
9997
$resource = ResourceObject::create($document['data']);
10098

101-
return $this->fillAndPersist($record, $resource, $parameters, false) ?: $record;
99+
return $this->fillAndPersist($record, $resource, $parameters) ?: $record;
102100
}
103101

104102
/**
@@ -229,18 +227,13 @@ protected function fillRelated($record, ResourceObject $resource, EncodingParame
229227
* @param mixed $record
230228
* @param ResourceObject $resource
231229
* @param EncodingParametersInterface $parameters
232-
* @param bool $creating
233230
* @return AsynchronousProcess|mixed
234231
*/
235-
protected function fillAndPersist(
236-
$record,
237-
ResourceObject $resource,
238-
EncodingParametersInterface $parameters,
239-
$creating
240-
) {
232+
protected function fillAndPersist($record, ResourceObject $resource, EncodingParametersInterface $parameters)
233+
{
241234
$this->fill($record, $resource, $parameters);
242235

243-
if ($async = $this->persist($record, $creating)) {
236+
if ($async = $this->persist($record)) {
244237
return $async;
245238
}
246239

src/Eloquent/AbstractAdapter.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,11 @@ protected function requiresPrimaryRecordPersistence(RelationshipAdapterInterface
403403
}
404404

405405
/**
406-
* @param Model $record
407-
* @param bool $creating
408-
* @return AsynchronousProcess|null
406+
* @inheritdoc
409407
*/
410-
protected function persist($record, $creating)
408+
protected function persist($record)
411409
{
412410
$record->save();
413-
414-
return null;
415411
}
416412

417413
/**

tests/dummy/app/JsonApi/Sites/Adapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected function fillAttribute($record, $field, $value)
132132
/**
133133
* @inheritdoc
134134
*/
135-
protected function persist($record, $creating)
135+
protected function persist($record)
136136
{
137137
$this->repository->store($record);
138138
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy