mirror of
https://github.com/flarum/core.git
synced 2025-08-07 00:47:00 +02:00
Apply fixes from StyleCI
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
namespace Flarum\Sticky\Api;
|
||||
|
||||
use Flarum\Api\Context;
|
||||
use Flarum\Api\Endpoint\Update;
|
||||
use Flarum\Api\Schema;
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\Sticky\Event\DiscussionWasStickied;
|
||||
|
@@ -136,6 +136,7 @@ class Context extends BaseContext
|
||||
{
|
||||
$new = parent::withRequest($request);
|
||||
$new->requestIncludes = null;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
@@ -143,6 +144,7 @@ class Context extends BaseContext
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->modelId = $id;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
@@ -150,6 +152,7 @@ class Context extends BaseContext
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->requestIncludes = $requestIncludes;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
|
@@ -1,15 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Endpoint\Concerns;
|
||||
|
||||
use Flarum\Api\Resource\AbstractDatabaseResource;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\Str;
|
||||
use Tobyz\JsonApiServer\Context;
|
||||
use Tobyz\JsonApiServer\Laravel\EloquentResource;
|
||||
|
||||
/**
|
||||
* This is directed at eager loading relationships apart from the request includes.
|
||||
@@ -108,7 +113,7 @@ trait HasEagerLoading
|
||||
|
||||
foreach ($relations as $relation) {
|
||||
if (isset($addedRelationWhere[$relation])) {
|
||||
$whereRelations[$relation] = $addedRelationWhere[$relation];;
|
||||
$whereRelations[$relation] = $addedRelationWhere[$relation];
|
||||
} else {
|
||||
$simpleRelations[] = $relation;
|
||||
}
|
||||
@@ -186,7 +191,7 @@ trait HasEagerLoading
|
||||
}
|
||||
|
||||
/**
|
||||
* From format of: 'relation' => [ ...nested ] to ['relation', 'relation.nested']
|
||||
* From format of: 'relation' => [ ...nested ] to ['relation', 'relation.nested'].
|
||||
*/
|
||||
private function stringInclude(array $include): array
|
||||
{
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Endpoint\Concerns;
|
||||
|
||||
use RuntimeException;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Endpoint\Concerns;
|
||||
|
||||
trait IncludesData
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Endpoint\Concerns;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
|
@@ -18,6 +18,7 @@ use Flarum\Database\Eloquent\Collection;
|
||||
use RuntimeException;
|
||||
use Tobyz\JsonApiServer\Endpoint\Concerns\ShowsResources;
|
||||
use Tobyz\JsonApiServer\Resource\Creatable;
|
||||
|
||||
use function Tobyz\JsonApiServer\has_value;
|
||||
use function Tobyz\JsonApiServer\json_api_response;
|
||||
use function Tobyz\JsonApiServer\set_value;
|
||||
|
@@ -16,6 +16,7 @@ use Nyholm\Psr7\Response;
|
||||
use RuntimeException;
|
||||
use Tobyz\JsonApiServer\Resource\Deletable;
|
||||
use Tobyz\JsonApiServer\Schema\Concerns\HasMeta;
|
||||
|
||||
use function Tobyz\JsonApiServer\json_api_response;
|
||||
|
||||
class Delete extends Endpoint
|
||||
|
@@ -21,6 +21,7 @@ use Tobyz\JsonApiServer\Endpoint\Concerns\FindsResources;
|
||||
use Tobyz\JsonApiServer\Endpoint\Concerns\ShowsResources;
|
||||
use Tobyz\JsonApiServer\Exception\ForbiddenException;
|
||||
use Tobyz\JsonApiServer\Exception\MethodNotAllowedException;
|
||||
|
||||
use function Tobyz\JsonApiServer\json_api_response;
|
||||
|
||||
class Endpoint implements EndpointInterface
|
||||
@@ -96,7 +97,7 @@ class Endpoint implements EndpointInterface
|
||||
public function process(Context $context): mixed
|
||||
{
|
||||
if (! $this->action) {
|
||||
throw new RuntimeException("No action defined for endpoint [".static::class."]");
|
||||
throw new RuntimeException('No action defined for endpoint ['.static::class.']');
|
||||
}
|
||||
|
||||
return ($this->action)($context);
|
||||
@@ -108,7 +109,7 @@ class Endpoint implements EndpointInterface
|
||||
public function handle(\Tobyz\JsonApiServer\Context $context): ?Response
|
||||
{
|
||||
if (! isset($this->method, $this->path)) {
|
||||
throw new RuntimeException("No route defined for endpoint [".static::class."]");
|
||||
throw new RuntimeException('No route defined for endpoint ['.static::class.']');
|
||||
}
|
||||
|
||||
if (strtolower($context->method()) !== strtolower($this->method)) {
|
||||
|
@@ -29,6 +29,7 @@ use Tobyz\JsonApiServer\Pagination\OffsetPagination;
|
||||
use Tobyz\JsonApiServer\Pagination\Pagination;
|
||||
use Tobyz\JsonApiServer\Schema\Concerns\HasMeta;
|
||||
use Tobyz\JsonApiServer\Serializer;
|
||||
|
||||
use function Tobyz\JsonApiServer\apply_filters;
|
||||
use function Tobyz\JsonApiServer\json_api_response;
|
||||
use function Tobyz\JsonApiServer\parse_sort_string;
|
||||
|
@@ -17,13 +17,11 @@ use Laminas\Diactoros\ServerRequestFactory;
|
||||
use Laminas\Diactoros\Uri;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Tobyz\JsonApiServer\Endpoint\Endpoint;
|
||||
use Tobyz\JsonApiServer\Exception\BadRequestException;
|
||||
use Tobyz\JsonApiServer\Exception\ResourceNotFoundException;
|
||||
use Tobyz\JsonApiServer\JsonApi as BaseJsonApi;
|
||||
use Tobyz\JsonApiServer\Resource\Collection;
|
||||
use Tobyz\JsonApiServer\Resource\Resource;
|
||||
use Tobyz\JsonApiServer\Schema\Field\Field;
|
||||
|
||||
class JsonApi extends BaseJsonApi
|
||||
{
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Resource\Contracts;
|
||||
|
||||
use Tobyz\JsonApiServer\Resource\Attachable as AttachableContract;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Resource\Contracts;
|
||||
|
||||
use Tobyz\JsonApiServer\Context;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Resource\Contracts;
|
||||
|
||||
use Tobyz\JsonApiServer\Resource\Creatable as CreatableContract;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Resource\Contracts;
|
||||
|
||||
use Tobyz\JsonApiServer\Resource\Deletable as DeletableContract;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Resource\Contracts;
|
||||
|
||||
use Tobyz\JsonApiServer\Resource\Findable as FindableContract;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Resource\Contracts;
|
||||
|
||||
use Tobyz\JsonApiServer\Context;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Resource\Contracts;
|
||||
|
||||
use Tobyz\JsonApiServer\Resource\Paginatable as PaginatableContract;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Resource\Contracts;
|
||||
|
||||
use Tobyz\JsonApiServer\Resource\Updatable as UpdatableContract;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Resource;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -8,7 +15,6 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Tobyz\JsonApiServer\Context;
|
||||
use Tobyz\JsonApiServer\Laravel\EloquentResource;
|
||||
use Tobyz\JsonApiServer\Laravel\Field\ToMany;
|
||||
use Tobyz\JsonApiServer\Laravel\Field\ToOne;
|
||||
use Tobyz\JsonApiServer\Schema\Field\Relationship;
|
||||
@@ -47,8 +53,6 @@ abstract class EloquentBuffer
|
||||
}
|
||||
|
||||
$loader = function ($relation) use (
|
||||
$model,
|
||||
$relationName,
|
||||
$relationship,
|
||||
$context,
|
||||
$aggregate,
|
||||
@@ -75,7 +79,7 @@ abstract class EloquentBuffer
|
||||
$modelClass = get_class($resource->newModel($context));
|
||||
|
||||
if ($resource instanceof AbstractDatabaseResource && ! isset($constrain[$modelClass])) {
|
||||
$constrain[$modelClass] = function (Builder $query) use ($resource, $context, $relationship, $relation, $aggregate) {
|
||||
$constrain[$modelClass] = function (Builder $query) use ($resource, $context, $relationship, $aggregate) {
|
||||
if (! $aggregate) {
|
||||
$query
|
||||
->with($context->endpoint->getEagerLoadsFor($relationship->name, $context))
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Schema\Concerns;
|
||||
|
||||
use Flarum\Api\Context;
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Schema\Concerns;
|
||||
|
||||
trait FlarumRelationship
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Schema\Concerns;
|
||||
|
||||
use Closure;
|
||||
|
@@ -1,9 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Schema\Concerns;
|
||||
|
||||
use Flarum\Api\Context;
|
||||
use Tobyz\JsonApiServer\Endpoint\Update;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
trait HasValidationRules
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Schema\Contracts;
|
||||
|
||||
interface RelationAggregator
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Api\Sort;
|
||||
|
||||
use Tobyz\JsonApiServer\Laravel\Sort\SortWithCount as BaseSortWithCount;
|
||||
|
Reference in New Issue
Block a user