mirror of
https://github.com/flarum/core.git
synced 2025-08-08 01:16:52 +02:00
Apply fixes from StyleCI
[ci skip] [skip ci]
This commit is contained in:
@@ -1,16 +1,20 @@
|
|||||||
<?php
|
<?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\Discussion;
|
namespace Flarum\Discussion;
|
||||||
|
|
||||||
|
|
||||||
use Flarum\Database\AbstractModel;
|
use Flarum\Database\AbstractModel;
|
||||||
use Flarum\Http\SlugDriverInterface;
|
use Flarum\Http\SlugDriverInterface;
|
||||||
use Flarum\User\User;
|
use Flarum\User\User;
|
||||||
|
|
||||||
class IdWithSlugDriver implements SlugDriverInterface
|
class IdWithSlugDriver implements SlugDriverInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function toSlug(AbstractModel $instance): string
|
public function toSlug(AbstractModel $instance): string
|
||||||
{
|
{
|
||||||
return $instance->id.(trim($instance->slug) ? '-'.$instance->slug : '');
|
return $instance->id.(trim($instance->slug) ? '-'.$instance->slug : '');
|
||||||
@@ -22,6 +26,7 @@ class IdWithSlugDriver implements SlugDriverInterface
|
|||||||
$slug_array = explode('-', $slug);
|
$slug_array = explode('-', $slug);
|
||||||
$slug = $slug_array[0];
|
$slug = $slug_array[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Discussion::where('id', $slug)->whereVisibleTo($actor)->firstOrFail();
|
return Discussion::where('id', $slug)->whereVisibleTo($actor)->firstOrFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
namespace Flarum\Forum\Content;
|
namespace Flarum\Forum\Content;
|
||||||
|
|
||||||
use Flarum\Api\Client;
|
use Flarum\Api\Client;
|
||||||
use Flarum\Discussion\Discussion as FlarumDiscussion;
|
|
||||||
use Flarum\Frontend\Document;
|
use Flarum\Frontend\Document;
|
||||||
use Flarum\Http\Exception\RouteNotFoundException;
|
use Flarum\Http\Exception\RouteNotFoundException;
|
||||||
use Flarum\Http\UrlGenerator;
|
use Flarum\Http\UrlGenerator;
|
||||||
|
@@ -86,7 +86,8 @@ class HttpServiceProvider extends AbstractServiceProvider
|
|||||||
$this->app->bind(UrlGenerator::class, function () {
|
$this->app->bind(UrlGenerator::class, function () {
|
||||||
return new UrlGenerator(
|
return new UrlGenerator(
|
||||||
$this->app->make(Application::class),
|
$this->app->make(Application::class),
|
||||||
$this->app->make('flarum.http.resourceUrlGenerators'));
|
$this->app->make('flarum.http.resourceUrlGenerators')
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,14 @@
|
|||||||
<?php
|
<?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\Http;
|
namespace Flarum\Http;
|
||||||
|
|
||||||
|
|
||||||
use Flarum\Database\AbstractModel;
|
use Flarum\Database\AbstractModel;
|
||||||
use Flarum\User\User;
|
use Flarum\User\User;
|
||||||
|
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
namespace Flarum\Http;
|
namespace Flarum\Http;
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class SlugManager
|
class SlugManager
|
||||||
|
@@ -68,7 +68,7 @@ class UrlGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a URL to an instance of a resource
|
* Generate a URL to an instance of a resource.
|
||||||
*
|
*
|
||||||
* @param string $resourceClass
|
* @param string $resourceClass
|
||||||
* @param AbstractModel $instance
|
* @param AbstractModel $instance
|
||||||
|
@@ -1,15 +1,19 @@
|
|||||||
<?php
|
<?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\User;
|
namespace Flarum\User;
|
||||||
|
|
||||||
|
|
||||||
use Flarum\Database\AbstractModel;
|
use Flarum\Database\AbstractModel;
|
||||||
use Flarum\Http\SlugDriverInterface;
|
use Flarum\Http\SlugDriverInterface;
|
||||||
|
|
||||||
class UsernameSlugDriver implements SlugDriverInterface
|
class UsernameSlugDriver implements SlugDriverInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function toSlug(AbstractModel $instance): string
|
public function toSlug(AbstractModel $instance): string
|
||||||
{
|
{
|
||||||
return $instance->username;
|
return $instance->username;
|
||||||
|
@@ -77,7 +77,7 @@ class ShowTest extends TestCase
|
|||||||
$this->request('GET', '/api/discussions/1-fdsafdsajfsakf', [
|
$this->request('GET', '/api/discussions/1-fdsafdsajfsakf', [
|
||||||
'authenticatedAs' => 2,
|
'authenticatedAs' => 2,
|
||||||
])->withQueryParams([
|
])->withQueryParams([
|
||||||
"bySlug" => true
|
'bySlug' => true
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -1,9 +1,14 @@
|
|||||||
<?php
|
<?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\Tests\integration\api\users;
|
namespace Flarum\Tests\integration\api\users;
|
||||||
|
|
||||||
|
|
||||||
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
|
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
|
||||||
use Flarum\Tests\integration\TestCase;
|
use Flarum\Tests\integration\TestCase;
|
||||||
|
|
||||||
@@ -55,7 +60,7 @@ class ShowTest extends TestCase
|
|||||||
$this->request('GET', '/api/users/normal', [
|
$this->request('GET', '/api/users/normal', [
|
||||||
'authenticatedAs' => 1,
|
'authenticatedAs' => 1,
|
||||||
])->withQueryParams([
|
])->withQueryParams([
|
||||||
"bySlug" => true
|
'bySlug' => true
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -81,7 +86,7 @@ class ShowTest extends TestCase
|
|||||||
{
|
{
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/users/2')->withQueryParams([
|
$this->request('GET', '/api/users/2')->withQueryParams([
|
||||||
"bySlug" => true
|
'bySlug' => true
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -111,7 +116,7 @@ class ShowTest extends TestCase
|
|||||||
$this->request('GET', '/api/users/normal', [
|
$this->request('GET', '/api/users/normal', [
|
||||||
'authenticatedAs' => 2,
|
'authenticatedAs' => 2,
|
||||||
])->withQueryParams([
|
])->withQueryParams([
|
||||||
"bySlug" => true
|
'bySlug' => true
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -141,7 +146,7 @@ class ShowTest extends TestCase
|
|||||||
$this->request('GET', '/api/users/admin', [
|
$this->request('GET', '/api/users/admin', [
|
||||||
'authenticatedAs' => 2,
|
'authenticatedAs' => 2,
|
||||||
])->withQueryParams([
|
])->withQueryParams([
|
||||||
"bySlug" => true
|
'bySlug' => true
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -173,7 +178,7 @@ class ShowTest extends TestCase
|
|||||||
$this->request('GET', '/api/users/admin', [
|
$this->request('GET', '/api/users/admin', [
|
||||||
'authenticatedAs' => 2,
|
'authenticatedAs' => 2,
|
||||||
])->withQueryParams([
|
])->withQueryParams([
|
||||||
"bySlug" => true
|
'bySlug' => true
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user