Skip to content

Commit

Permalink
docs: remove deprecation warning
Browse files Browse the repository at this point in the history
Because there is no backward compatible replacement for the deprecated features yet
  • Loading branch information
Mohammad-Alavi committed Aug 26, 2024
1 parent 27eefcd commit 19eecf6
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions src/Traits/ResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,16 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Request;
use JetBrains\PhpStorm\Deprecated;
use Spatie\Fractal\Facades\Fractal;

#[Deprecated(
reason: 'All methods in this trait are deprecated and will be removed in the next major release.',
replacement: 'Use the Response facade instead.',
)]
// TODO: Remove this after migrating everything to use Response facade
trait ResponseTrait
{
protected array $metaData = [];

/**
* @throws InvalidTransformerException
*/
#[Deprecated(
reason: 'This method is the cause of many bugs and its functionality is already covered by the Response facade. Use the Response facade instead.',
replacement: '\Apiato\Core\Facades\Response::createFrom(%parameter0%,%parameter1%)->parseIncludes(%parameter2%)->addMeta(%parameter3%)->toArray();',
)]
public function transform(
$data,
$transformerName = null,
Expand Down Expand Up @@ -129,39 +121,23 @@ private function filterResponse(array $responseArray, array $filters): array
return $responseArray;
}

#[Deprecated(
reason: 'Its functionality is already covered by the Response facade. Use the addMeta method from the Response facade instead.',
replacement: '\Apiato\Core\Facades\Response::createFrom()->addMeta(%parameter0%)->toArray();',
)]
public function withMeta($data): self
{
$this->metaData = $data;

return $this;
}

#[Deprecated(
reason: 'Its functionality is already covered by the Response facade. Use the toJson method from the Response facade instead.',
replacement: '\Apiato\Core\Facades\Response::createFrom(%parameter0%)->toJson();',
)]
public function json($data, $status = 200, array $headers = [], $options = 0): JsonResponse
{
return new JsonResponse($data, $status, $headers, $options);
}

#[Deprecated(
reason: 'Its functionality is already covered by the Response facade. Use the created method from the Response facade instead.',
replacement: '\Apiato\Core\Facades\Response::createFrom(%parameter0%)->created();',
)]
public function created($data = null, $status = 201, array $headers = [], $options = 0): JsonResponse
{
return new JsonResponse($data, $status, $headers, $options);
}

#[Deprecated(
reason: 'Use the noContent method from the Response facade instead.',
replacement: '\Apiato\Core\Facades\Response::createFrom(%parameter0%)->noContent();',
)]
public function deleted(Model|null $deletedModel = null): JsonResponse
{
if (!$deletedModel) {
Expand All @@ -176,19 +152,11 @@ public function deleted(Model|null $deletedModel = null): JsonResponse
]);
}

#[Deprecated(
reason: 'Its functionality is already covered by the Response facade. Use the accepted method from the Response facade instead.',
replacement: '\Apiato\Core\Facades\Response::createFrom(%parameter0%)->accepted();',
)]
public function accepted($data = null, $status = 202, array $headers = [], $options = 0): JsonResponse
{
return new JsonResponse($data, $status, $headers, $options);
}

#[Deprecated(
reason: 'Its functionality is already covered by the Response facade. Use the noContent method from the Response facade instead.',
replacement: '\Apiato\Core\Facades\Response::createFrom()->noContent();',
)]
public function noContent($status = 204): JsonResponse
{
return new JsonResponse(null, $status);
Expand Down

0 comments on commit 19eecf6

Please sign in to comment.