Skip to content

Commit

Permalink
refactor: add improvements to action interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
lindyhopchris committed Aug 15, 2023
1 parent 56317b4 commit f0d6400
Show file tree
Hide file tree
Showing 99 changed files with 1,306 additions and 1,215 deletions.
2 changes: 1 addition & 1 deletion src/Contracts/Bus/Commands/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace LaravelJsonApi\Contracts\Bus\Commands;

use LaravelJsonApi\Core\Bus\Commands\Command;
use LaravelJsonApi\Core\Bus\Commands\Command\Command;
use LaravelJsonApi\Core\Bus\Commands\Result;

interface Dispatcher
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Bus/Queries/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace LaravelJsonApi\Contracts\Bus\Queries;

use LaravelJsonApi\Core\Bus\Queries\Query;
use LaravelJsonApi\Core\Bus\Queries\Query\Query;
use LaravelJsonApi\Core\Bus\Queries\Result;

interface Dispatcher
Expand Down
14 changes: 5 additions & 9 deletions src/Contracts/Http/Actions/FetchOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,16 @@
interface FetchOne extends Responsable
{
/**
* Set the JSON:API resource type for the action.
* Set the target for the action.
*
* @param ResourceType|string $type
* @return $this
*/
public function withType(ResourceType|string $type): static;

/**
* Set the JSON:API resource id for the action, or the model (if bindings have been substituted).
* A model can be set if the bindings have been substituted, or if the action is being
* run manually.
*
* @param ResourceType|string $type
* @param object|string $idOrModel
* @return $this
*/
public function withIdOrModel(object|string $idOrModel): static;
public function withTarget(ResourceType|string $type, object|string $idOrModel): static;

/**
* Set the object that implements controller hooks.
Expand Down
25 changes: 9 additions & 16 deletions src/Contracts/Http/Actions/FetchRelated.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,21 @@
interface FetchRelated extends Responsable
{
/**
* Set the JSON:API resource type for the action.
* Set the target for the action.
*
* @param ResourceType|string $type
* @return $this
*/
public function withType(ResourceType|string $type): static;

/**
* Set the JSON:API resource id for the action, or the model (if bindings have been substituted).
* A model can be set if the bindings have been substituted, or if the action is being
* run manually.
*
* @param ResourceType|string $type
* @param object|string $idOrModel
* @return $this
*/
public function withIdOrModel(object|string $idOrModel): static;

/**
* Set the JSON:API field name of the relationship that is being fetched.
*
* @param string $fieldName
* @return $this
*/
public function withFieldName(string $fieldName): static;
public function withTarget(
ResourceType|string $type,
object|string $idOrModel,
string $fieldName,
): static;

/**
* Set the object that implements controller hooks.
Expand Down
25 changes: 9 additions & 16 deletions src/Contracts/Http/Actions/FetchRelationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,21 @@
interface FetchRelationship extends Responsable
{
/**
* Set the JSON:API resource type for the action.
* Set the target for the action.
*
* @param ResourceType|string $type
* @return $this
*/
public function withType(ResourceType|string $type): static;

/**
* Set the JSON:API resource id for the action, or the model (if bindings have been substituted).
* A model can be set if the bindings have been substituted, or if the action is being
* run manually.
*
* @param ResourceType|string $type
* @param object|string $idOrModel
* @return $this
*/
public function withIdOrModel(object|string $idOrModel): static;

/**
* Set the JSON:API field name of the relationship that is being fetched.
*
* @param string $fieldName
* @return $this
*/
public function withFieldName(string $fieldName): static;
public function withTarget(
ResourceType|string $type,
object|string $idOrModel,
string $fieldName,
): static;

/**
* Set the object that implements controller hooks.
Expand Down
14 changes: 5 additions & 9 deletions src/Contracts/Http/Actions/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,16 @@
interface Update extends Responsable
{
/**
* Set the JSON:API resource type for the action.
* Set the target for the action.
*
* @param ResourceType|string $type
* @return $this
*/
public function withType(ResourceType|string $type): static;

/**
* Set the JSON:API resource id for the action, or the model (if bindings have been substituted).
* A model can be set if the bindings have been substituted, or if the action is being
* run manually.
*
* @param ResourceType|string $type
* @param object|string $idOrModel
* @return $this
*/
public function withIdOrModel(object|string $idOrModel): static;
public function withTarget(ResourceType|string $type, object|string $idOrModel): static;

/**
* Set the object that implements controller hooks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

declare(strict_types=1);

namespace LaravelJsonApi\Core\Bus\Commands;
namespace LaravelJsonApi\Core\Bus\Commands\Command;

use Illuminate\Http\Request;
use Illuminate\Support\ValidatedInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

declare(strict_types=1);

namespace LaravelJsonApi\Core\Bus\Commands\Concerns;
namespace LaravelJsonApi\Core\Bus\Commands\Command;

use RuntimeException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

declare(strict_types=1);

namespace LaravelJsonApi\Core\Bus\Commands;
namespace LaravelJsonApi\Core\Bus\Commands\Command;

use LaravelJsonApi\Core\Document\Input\Values\ResourceId;

Expand Down
1 change: 1 addition & 0 deletions src/Core/Bus/Commands/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use Illuminate\Contracts\Container\Container;
use LaravelJsonApi\Contracts\Bus\Commands\Dispatcher as DispatcherContract;
use LaravelJsonApi\Core\Bus\Commands\Command\Command;
use LaravelJsonApi\Core\Bus\Commands\Store\StoreCommand;
use LaravelJsonApi\Core\Bus\Commands\Store\StoreCommandHandler;
use LaravelJsonApi\Core\Bus\Commands\Update\UpdateCommand;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Bus/Commands/Middleware/LookupModelIfMissing.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

use Closure;
use LaravelJsonApi\Contracts\Store\Store;
use LaravelJsonApi\Core\Bus\Commands\Command;
use LaravelJsonApi\Core\Bus\Commands\IsIdentifiable;
use LaravelJsonApi\Core\Bus\Commands\Command\Command;
use LaravelJsonApi\Core\Bus\Commands\Command\IsIdentifiable;
use LaravelJsonApi\Core\Bus\Commands\Result;
use LaravelJsonApi\Core\Document\Error;
use Symfony\Component\HttpFoundation\Response;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Bus/Commands/Store/StoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

use Illuminate\Http\Request;
use LaravelJsonApi\Contracts\Http\Controllers\Hooks\StoreImplementation;
use LaravelJsonApi\Core\Bus\Commands\Command\Command;
use LaravelJsonApi\Core\Document\Input\Values\ResourceType;
use LaravelJsonApi\Core\Extensions\Atomic\Operations\Create;
use LaravelJsonApi\Core\Bus\Commands\Command;

class StoreCommand extends Command
{
Expand Down
6 changes: 3 additions & 3 deletions src/Core/Bus/Commands/Update/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

use Illuminate\Http\Request;
use LaravelJsonApi\Contracts\Http\Controllers\Hooks\UpdateImplementation;
use LaravelJsonApi\Core\Bus\Commands\Command;
use LaravelJsonApi\Core\Bus\Commands\Concerns\Identifiable;
use LaravelJsonApi\Core\Bus\Commands\IsIdentifiable;
use LaravelJsonApi\Core\Bus\Commands\Command\Command;
use LaravelJsonApi\Core\Bus\Commands\Command\Identifiable;
use LaravelJsonApi\Core\Bus\Commands\Command\IsIdentifiable;
use LaravelJsonApi\Core\Document\Input\Values\ResourceId;
use LaravelJsonApi\Core\Document\Input\Values\ResourceType;
use LaravelJsonApi\Core\Extensions\Atomic\Operations\Update;
Expand Down
142 changes: 0 additions & 142 deletions src/Core/Bus/Queries/Concerns/Identifiable.php

This file was deleted.

1 change: 1 addition & 0 deletions src/Core/Bus/Queries/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use Illuminate\Contracts\Container\Container;
use LaravelJsonApi\Contracts\Bus\Queries\Dispatcher as DispatcherContract;
use LaravelJsonApi\Core\Bus\Queries\Query\Query;
use RuntimeException;

class Dispatcher implements DispatcherContract
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Bus/Queries/FetchMany/FetchManyQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use Illuminate\Http\Request;
use LaravelJsonApi\Contracts\Http\Controllers\Hooks\IndexImplementation;
use LaravelJsonApi\Core\Bus\Queries\Query;
use LaravelJsonApi\Core\Bus\Queries\Query\Query;
use LaravelJsonApi\Core\Document\Input\Values\ResourceType;

class FetchManyQuery extends Query
Expand Down
Loading

0 comments on commit f0d6400

Please sign in to comment.