From 5127514d351a50510d665692d2b1a67df5a4be14 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 24 Jun 2017 11:11:55 +0200 Subject: [PATCH 01/86] Restructure Flarum\Admin namespace --- src/Admin/AdminServiceProvider.php | 11 ++++------ ...pController.php => FrontendController.php} | 8 +++---- src/Admin/{WebApp.php => Frontend.php} | 2 +- src/Admin/routes.php | 22 +++++++++++++++++++ src/Debug/Console/CacheClearCommand.php | 4 ++-- src/Event/ConfigureWebApp.php | 2 +- 6 files changed, 34 insertions(+), 15 deletions(-) rename src/Admin/Controller/{WebAppController.php => FrontendController.php} (85%) rename src/Admin/{WebApp.php => Frontend.php} (91%) create mode 100644 src/Admin/routes.php diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index 576f0e7bd..80713c37e 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -55,13 +55,10 @@ class AdminServiceProvider extends AbstractServiceProvider */ protected function populateRoutes(RouteCollection $routes) { - $route = $this->app->make(RouteHandlerFactory::class); + $factory = $this->app->make(RouteHandlerFactory::class); - $routes->get( - '/', - 'index', - $route->toController(Controller\WebAppController::class) - ); + $callback = include __DIR__.'/routes.php'; + $callback($routes, $factory); } protected function flushWebAppAssetsWhenThemeChanged() @@ -91,6 +88,6 @@ class AdminServiceProvider extends AbstractServiceProvider */ protected function getWebAppAssets() { - return $this->app->make(WebApp::class)->getAssets(); + return $this->app->make(Frontend::class)->getAssets(); } } diff --git a/src/Admin/Controller/WebAppController.php b/src/Admin/Controller/FrontendController.php similarity index 85% rename from src/Admin/Controller/WebAppController.php rename to src/Admin/Controller/FrontendController.php index d0870900a..db8cc5c41 100644 --- a/src/Admin/Controller/WebAppController.php +++ b/src/Admin/Controller/FrontendController.php @@ -11,7 +11,7 @@ namespace Flarum\Admin\Controller; -use Flarum\Admin\WebApp; +use Flarum\Admin\Frontend; use Flarum\Core\Permission; use Flarum\Event\PrepareUnserializedSettings; use Flarum\Extension\ExtensionManager; @@ -20,7 +20,7 @@ use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface; -class WebAppController extends AbstractWebAppController +class FrontendController extends AbstractWebAppController { /** * @var SettingsRepositoryInterface @@ -33,12 +33,12 @@ class WebAppController extends AbstractWebAppController protected $extensions; /** - * @param WebApp $webApp + * @param Frontend $webApp * @param Dispatcher $events * @param SettingsRepositoryInterface $settings * @param ExtensionManager $extensions */ - public function __construct(WebApp $webApp, Dispatcher $events, SettingsRepositoryInterface $settings, ExtensionManager $extensions) + public function __construct(Frontend $webApp, Dispatcher $events, SettingsRepositoryInterface $settings, ExtensionManager $extensions) { $this->webApp = $webApp; $this->events = $events; diff --git a/src/Admin/WebApp.php b/src/Admin/Frontend.php similarity index 91% rename from src/Admin/WebApp.php rename to src/Admin/Frontend.php index 5e130130d..65be577f0 100644 --- a/src/Admin/WebApp.php +++ b/src/Admin/Frontend.php @@ -13,7 +13,7 @@ namespace Flarum\Admin; use Flarum\Http\WebApp\AbstractWebApp; -class WebApp extends AbstractWebApp +class Frontend extends AbstractWebApp { /** * {@inheritdoc} diff --git a/src/Admin/routes.php b/src/Admin/routes.php new file mode 100644 index 000000000..76f1aad4a --- /dev/null +++ b/src/Admin/routes.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Flarum\Admin\Controller; +use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteCollection; + +return function (RouteCollection $map, RouteHandlerFactory $route) { + $map->get( + '/', + 'index', + $route->toController(Controller\FrontendController::class) + ); +}; diff --git a/src/Debug/Console/CacheClearCommand.php b/src/Debug/Console/CacheClearCommand.php index cf8e4b466..554e24824 100644 --- a/src/Debug/Console/CacheClearCommand.php +++ b/src/Debug/Console/CacheClearCommand.php @@ -11,7 +11,7 @@ namespace Flarum\Debug\Console; -use Flarum\Admin\WebApp as AdminWebApp; +use Flarum\Admin\Frontend as AdminWebApp; use Flarum\Console\Command\AbstractCommand; use Flarum\Forum\WebApp as ForumWebApp; use Illuminate\Contracts\Cache\Store; @@ -29,7 +29,7 @@ class CacheClearCommand extends AbstractCommand protected $forum; /** - * @var \Flarum\Admin\WebApp + * @var \Flarum\Admin\Frontend */ protected $admin; diff --git a/src/Event/ConfigureWebApp.php b/src/Event/ConfigureWebApp.php index a4d1b71ee..014672ffc 100644 --- a/src/Event/ConfigureWebApp.php +++ b/src/Event/ConfigureWebApp.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Admin\Controller\WebAppController as AdminWebAppController; +use Flarum\Admin\Controller\FrontendController as AdminWebAppController; use Flarum\Forum\Controller\WebAppController as ForumWebAppController; use Flarum\Http\Controller\AbstractWebAppController; use Flarum\Http\WebApp\WebAppView; From 9b24fbd5e5f8b30ff986f66a6183e07ec1211b42 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 24 Jun 2017 11:25:07 +0200 Subject: [PATCH 02/86] Restructure Flarum\Api namespace --- src/Api/ApiServiceProvider.php | 313 +----------------- .../Controller/AbstractCreateController.php | 2 +- ...troller.php => AbstractListController.php} | 2 +- ...troller.php => AbstractShowController.php} | 2 +- src/Api/Controller/DeleteAvatarController.php | 2 +- .../Controller/ListDiscussionsController.php | 2 +- src/Api/Controller/ListGroupsController.php | 2 +- .../ListNotificationsController.php | 2 +- src/Api/Controller/ListPostsController.php | 2 +- src/Api/Controller/ListUsersController.php | 2 +- .../Controller/ShowDiscussionController.php | 2 +- src/Api/Controller/ShowForumController.php | 2 +- src/Api/Controller/ShowPostController.php | 2 +- src/Api/Controller/ShowUserController.php | 2 +- .../Controller/UpdateDiscussionController.php | 2 +- src/Api/Controller/UpdateGroupController.php | 2 +- .../UpdateNotificationController.php | 2 +- src/Api/Controller/UpdatePostController.php | 2 +- src/Api/Controller/UpdateUserController.php | 2 +- src/Api/Controller/UploadAvatarController.php | 2 +- .../FloodingExceptionHandler.php | 2 +- .../IlluminateValidationExceptionHandler.php | 2 +- .../InvalidAccessTokenExceptionHandler.php | 2 +- ...validConfirmationTokenExceptionHandler.php | 2 +- .../MethodNotAllowedExceptionHandler.php | 2 +- .../ModelNotFoundExceptionHandler.php | 2 +- .../PermissionDeniedExceptionHandler.php | 2 +- .../RouteNotFoundExceptionHandler.php | 2 +- .../TokenMismatchExceptionHandler.php | 2 +- .../ValidationExceptionHandler.php | 2 +- ...izer.php => BasicDiscussionSerializer.php} | 2 +- ...Serializer.php => BasicPostSerializer.php} | 2 +- ...Serializer.php => BasicUserSerializer.php} | 2 +- src/Api/Serializer/DiscussionSerializer.php | 2 +- src/Api/Serializer/PostSerializer.php | 2 +- src/Api/Serializer/UserSerializer.php | 2 +- src/Api/routes.php | 304 +++++++++++++++++ .../Handler/FloodingExceptionHandlerTest.php | 2 +- ...luminateValidationExceptionHandlerTest.php | 2 +- ...InvalidAccessTokenExceptionHandlerTest.php | 2 +- ...dConfirmationTokenExceptionHandlerTest.php | 2 +- .../MethodNotAllowedExceptionHandlerTest.php | 2 +- .../ModelNotFoundExceptionHandlerTest.php | 2 +- .../PermissionDeniedExceptionHandlerTest.php | 2 +- .../RouteNotFoundExceptionHandlerTest.php | 2 +- .../TokenMismatchExceptionHandlerTest.php | 2 +- .../ValidationExceptionHandlerTest.php | 2 +- 47 files changed, 363 insertions(+), 344 deletions(-) rename src/Api/Controller/{AbstractCollectionController.php => AbstractListController.php} (86%) rename src/Api/Controller/{AbstractResourceController.php => AbstractShowController.php} (86%) rename src/Api/{Handler => ExceptionHandler}/FloodingExceptionHandler.php (95%) rename src/Api/{Handler => ExceptionHandler}/IlluminateValidationExceptionHandler.php (97%) rename src/Api/{Handler => ExceptionHandler}/InvalidAccessTokenExceptionHandler.php (95%) rename src/Api/{Handler => ExceptionHandler}/InvalidConfirmationTokenExceptionHandler.php (96%) rename src/Api/{Handler => ExceptionHandler}/MethodNotAllowedExceptionHandler.php (95%) rename src/Api/{Handler => ExceptionHandler}/ModelNotFoundExceptionHandler.php (95%) rename src/Api/{Handler => ExceptionHandler}/PermissionDeniedExceptionHandler.php (95%) rename src/Api/{Handler => ExceptionHandler}/RouteNotFoundExceptionHandler.php (95%) rename src/Api/{Handler => ExceptionHandler}/TokenMismatchExceptionHandler.php (95%) rename src/Api/{Handler => ExceptionHandler}/ValidationExceptionHandler.php (97%) rename src/Api/Serializer/{DiscussionBasicSerializer.php => BasicDiscussionSerializer.php} (97%) rename src/Api/Serializer/{PostBasicSerializer.php => BasicPostSerializer.php} (96%) rename src/Api/Serializer/{UserBasicSerializer.php => BasicUserSerializer.php} (95%) create mode 100644 src/Api/routes.php diff --git a/src/Api/ApiServiceProvider.php b/src/Api/ApiServiceProvider.php index 7aa246cd3..24020af42 100644 --- a/src/Api/ApiServiceProvider.php +++ b/src/Api/ApiServiceProvider.php @@ -41,16 +41,16 @@ class ApiServiceProvider extends AbstractServiceProvider $this->app->singleton(ErrorHandler::class, function () { $handler = new ErrorHandler; - $handler->registerHandler(new Handler\FloodingExceptionHandler); - $handler->registerHandler(new Handler\IlluminateValidationExceptionHandler); - $handler->registerHandler(new Handler\InvalidAccessTokenExceptionHandler); - $handler->registerHandler(new Handler\InvalidConfirmationTokenExceptionHandler); - $handler->registerHandler(new Handler\MethodNotAllowedExceptionHandler); - $handler->registerHandler(new Handler\ModelNotFoundExceptionHandler); - $handler->registerHandler(new Handler\PermissionDeniedExceptionHandler); - $handler->registerHandler(new Handler\RouteNotFoundExceptionHandler); - $handler->registerHandler(new Handler\TokenMismatchExceptionHandler); - $handler->registerHandler(new Handler\ValidationExceptionHandler); + $handler->registerHandler(new ExceptionHandler\FloodingExceptionHandler); + $handler->registerHandler(new ExceptionHandler\IlluminateValidationExceptionHandler); + $handler->registerHandler(new ExceptionHandler\InvalidAccessTokenExceptionHandler); + $handler->registerHandler(new ExceptionHandler\InvalidConfirmationTokenExceptionHandler); + $handler->registerHandler(new ExceptionHandler\MethodNotAllowedExceptionHandler); + $handler->registerHandler(new ExceptionHandler\ModelNotFoundExceptionHandler); + $handler->registerHandler(new ExceptionHandler\PermissionDeniedExceptionHandler); + $handler->registerHandler(new ExceptionHandler\RouteNotFoundExceptionHandler); + $handler->registerHandler(new ExceptionHandler\TokenMismatchExceptionHandler); + $handler->registerHandler(new ExceptionHandler\ValidationExceptionHandler); $handler->registerHandler(new InvalidParameterExceptionHandler); $handler->registerHandler(new FallbackExceptionHandler($this->app->inDebugMode())); @@ -100,298 +100,13 @@ class ApiServiceProvider extends AbstractServiceProvider */ protected function populateRoutes(RouteCollection $routes) { - $route = $this->app->make(RouteHandlerFactory::class); + $factory = $this->app->make(RouteHandlerFactory::class); - // Get forum information - $routes->get( - '/forum', - 'forum.show', - $route->toController(Controller\ShowForumController::class) - ); - - // Retrieve authentication token - $routes->post( - '/token', - 'token', - $route->toController(Controller\TokenController::class) - ); - - // Send forgot password email - $routes->post( - '/forgot', - 'forgot', - $route->toController(Controller\ForgotPasswordController::class) - ); - - /* - |-------------------------------------------------------------------------- - | Users - |-------------------------------------------------------------------------- - */ - - // List users - $routes->get( - '/users', - 'users.index', - $route->toController(Controller\ListUsersController::class) - ); - - // Register a user - $routes->post( - '/users', - 'users.create', - $route->toController(Controller\CreateUserController::class) - ); - - // Get a single user - $routes->get( - '/users/{id}', - 'users.show', - $route->toController(Controller\ShowUserController::class) - ); - - // Edit a user - $routes->patch( - '/users/{id}', - 'users.update', - $route->toController(Controller\UpdateUserController::class) - ); - - // Delete a user - $routes->delete( - '/users/{id}', - 'users.delete', - $route->toController(Controller\DeleteUserController::class) - ); - - // Upload avatar - $routes->post( - '/users/{id}/avatar', - 'users.avatar.upload', - $route->toController(Controller\UploadAvatarController::class) - ); - - // Remove avatar - $routes->delete( - '/users/{id}/avatar', - 'users.avatar.delete', - $route->toController(Controller\DeleteAvatarController::class) - ); - - // send confirmation email - $routes->post( - '/users/{id}/send-confirmation', - 'users.confirmation.send', - $route->toController(Controller\SendConfirmationEmailController::class) - ); - - /* - |-------------------------------------------------------------------------- - | Notifications - |-------------------------------------------------------------------------- - */ - - // List notifications for the current user - $routes->get( - '/notifications', - 'notifications.index', - $route->toController(Controller\ListNotificationsController::class) - ); - - // Mark all notifications as read - $routes->post( - '/notifications/read', - 'notifications.readAll', - $route->toController(Controller\ReadAllNotificationsController::class) - ); - - // Mark a single notification as read - $routes->patch( - '/notifications/{id}', - 'notifications.update', - $route->toController(Controller\UpdateNotificationController::class) - ); - - /* - |-------------------------------------------------------------------------- - | Discussions - |-------------------------------------------------------------------------- - */ - - // List discussions - $routes->get( - '/discussions', - 'discussions.index', - $route->toController(Controller\ListDiscussionsController::class) - ); - - // Create a discussion - $routes->post( - '/discussions', - 'discussions.create', - $route->toController(Controller\CreateDiscussionController::class) - ); - - // Show a single discussion - $routes->get( - '/discussions/{id}', - 'discussions.show', - $route->toController(Controller\ShowDiscussionController::class) - ); - - // Edit a discussion - $routes->patch( - '/discussions/{id}', - 'discussions.update', - $route->toController(Controller\UpdateDiscussionController::class) - ); - - // Delete a discussion - $routes->delete( - '/discussions/{id}', - 'discussions.delete', - $route->toController(Controller\DeleteDiscussionController::class) - ); - - /* - |-------------------------------------------------------------------------- - | Posts - |-------------------------------------------------------------------------- - */ - - // List posts, usually for a discussion - $routes->get( - '/posts', - 'posts.index', - $route->toController(Controller\ListPostsController::class) - ); - - // Create a post - $routes->post( - '/posts', - 'posts.create', - $route->toController(Controller\CreatePostController::class) - ); - - // Show a single or multiple posts by ID - $routes->get( - '/posts/{id}', - 'posts.show', - $route->toController(Controller\ShowPostController::class) - ); - - // Edit a post - $routes->patch( - '/posts/{id}', - 'posts.update', - $route->toController(Controller\UpdatePostController::class) - ); - - // Delete a post - $routes->delete( - '/posts/{id}', - 'posts.delete', - $route->toController(Controller\DeletePostController::class) - ); - - /* - |-------------------------------------------------------------------------- - | Groups - |-------------------------------------------------------------------------- - */ - - // List groups - $routes->get( - '/groups', - 'groups.index', - $route->toController(Controller\ListGroupsController::class) - ); - - // Create a group - $routes->post( - '/groups', - 'groups.create', - $route->toController(Controller\CreateGroupController::class) - ); - - // Edit a group - $routes->patch( - '/groups/{id}', - 'groups.update', - $route->toController(Controller\UpdateGroupController::class) - ); - - // Delete a group - $routes->delete( - '/groups/{id}', - 'groups.delete', - $route->toController(Controller\DeleteGroupController::class) - ); - - /* - |-------------------------------------------------------------------------- - | Administration - |-------------------------------------------------------------------------- - */ - - // Toggle an extension - $routes->patch( - '/extensions/{name}', - 'extensions.update', - $route->toController(Controller\UpdateExtensionController::class) - ); - - // Uninstall an extension - $routes->delete( - '/extensions/{name}', - 'extensions.delete', - $route->toController(Controller\UninstallExtensionController::class) - ); - - // Update settings - $routes->post( - '/settings', - 'settings', - $route->toController(Controller\SetSettingsController::class) - ); - - // Update a permission - $routes->post( - '/permission', - 'permission', - $route->toController(Controller\SetPermissionController::class) - ); - - // Upload a logo - $routes->post( - '/logo', - 'logo', - $route->toController(Controller\UploadLogoController::class) - ); - - // Remove the logo - $routes->delete( - '/logo', - 'logo.delete', - $route->toController(Controller\DeleteLogoController::class) - ); - - // Upload a favicon - $routes->post( - '/favicon', - 'favicon', - $route->toController(Controller\UploadFaviconController::class) - ); - - // Remove the favicon - $routes->delete( - '/favicon', - 'favicon.delete', - $route->toController(Controller\DeleteFaviconController::class) - ); + $callback = include __DIR__.'/routes.php'; + $callback($routes, $factory); $this->app->make('events')->fire( - new ConfigureApiRoutes($routes, $route) + new ConfigureApiRoutes($routes, $factory) ); } } diff --git a/src/Api/Controller/AbstractCreateController.php b/src/Api/Controller/AbstractCreateController.php index 939ead0ca..bb31ede70 100644 --- a/src/Api/Controller/AbstractCreateController.php +++ b/src/Api/Controller/AbstractCreateController.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Controller; use Psr\Http\Message\ServerRequestInterface; -abstract class AbstractCreateController extends AbstractResourceController +abstract class AbstractCreateController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Controller/AbstractCollectionController.php b/src/Api/Controller/AbstractListController.php similarity index 86% rename from src/Api/Controller/AbstractCollectionController.php rename to src/Api/Controller/AbstractListController.php index aa6883967..f8525af34 100644 --- a/src/Api/Controller/AbstractCollectionController.php +++ b/src/Api/Controller/AbstractListController.php @@ -14,7 +14,7 @@ namespace Flarum\Api\Controller; use Tobscure\JsonApi\Collection; use Tobscure\JsonApi\SerializerInterface; -abstract class AbstractCollectionController extends AbstractSerializeController +abstract class AbstractListController extends AbstractSerializeController { /** * {@inheritdoc} diff --git a/src/Api/Controller/AbstractResourceController.php b/src/Api/Controller/AbstractShowController.php similarity index 86% rename from src/Api/Controller/AbstractResourceController.php rename to src/Api/Controller/AbstractShowController.php index 6c5dc96ca..309ee2b34 100644 --- a/src/Api/Controller/AbstractResourceController.php +++ b/src/Api/Controller/AbstractShowController.php @@ -14,7 +14,7 @@ namespace Flarum\Api\Controller; use Tobscure\JsonApi\Resource; use Tobscure\JsonApi\SerializerInterface; -abstract class AbstractResourceController extends AbstractSerializeController +abstract class AbstractShowController extends AbstractSerializeController { /** * {@inheritdoc} diff --git a/src/Api/Controller/DeleteAvatarController.php b/src/Api/Controller/DeleteAvatarController.php index b360b87e4..73cbe9dd1 100644 --- a/src/Api/Controller/DeleteAvatarController.php +++ b/src/Api/Controller/DeleteAvatarController.php @@ -16,7 +16,7 @@ use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class DeleteAvatarController extends AbstractResourceController +class DeleteAvatarController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Controller/ListDiscussionsController.php b/src/Api/Controller/ListDiscussionsController.php index ab8b21283..c39d2d6a4 100644 --- a/src/Api/Controller/ListDiscussionsController.php +++ b/src/Api/Controller/ListDiscussionsController.php @@ -17,7 +17,7 @@ use Flarum\Core\Search\SearchCriteria; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class ListDiscussionsController extends AbstractCollectionController +class ListDiscussionsController extends AbstractListController { /** * {@inheritdoc} diff --git a/src/Api/Controller/ListGroupsController.php b/src/Api/Controller/ListGroupsController.php index 01ac443e0..66d734917 100644 --- a/src/Api/Controller/ListGroupsController.php +++ b/src/Api/Controller/ListGroupsController.php @@ -15,7 +15,7 @@ use Flarum\Core\Group; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class ListGroupsController extends AbstractCollectionController +class ListGroupsController extends AbstractListController { /** * {@inheritdoc} diff --git a/src/Api/Controller/ListNotificationsController.php b/src/Api/Controller/ListNotificationsController.php index 7af1cd561..dd7303efa 100644 --- a/src/Api/Controller/ListNotificationsController.php +++ b/src/Api/Controller/ListNotificationsController.php @@ -17,7 +17,7 @@ use Flarum\Core\Repository\NotificationRepository; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class ListNotificationsController extends AbstractCollectionController +class ListNotificationsController extends AbstractListController { /** * {@inheritdoc} diff --git a/src/Api/Controller/ListPostsController.php b/src/Api/Controller/ListPostsController.php index e202acd36..c50490d07 100644 --- a/src/Api/Controller/ListPostsController.php +++ b/src/Api/Controller/ListPostsController.php @@ -18,7 +18,7 @@ use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; use Tobscure\JsonApi\Exception\InvalidParameterException; -class ListPostsController extends AbstractCollectionController +class ListPostsController extends AbstractListController { /** * {@inheritdoc} diff --git a/src/Api/Controller/ListUsersController.php b/src/Api/Controller/ListUsersController.php index 733f25e79..eb42a97db 100644 --- a/src/Api/Controller/ListUsersController.php +++ b/src/Api/Controller/ListUsersController.php @@ -18,7 +18,7 @@ use Flarum\Core\Search\User\UserSearcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class ListUsersController extends AbstractCollectionController +class ListUsersController extends AbstractListController { /** * {@inheritdoc} diff --git a/src/Api/Controller/ShowDiscussionController.php b/src/Api/Controller/ShowDiscussionController.php index 7f04ca167..58417fae4 100644 --- a/src/Api/Controller/ShowDiscussionController.php +++ b/src/Api/Controller/ShowDiscussionController.php @@ -18,7 +18,7 @@ use Flarum\Core\User; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class ShowDiscussionController extends AbstractResourceController +class ShowDiscussionController extends AbstractShowController { /** * @var DiscussionRepository diff --git a/src/Api/Controller/ShowForumController.php b/src/Api/Controller/ShowForumController.php index 5449df604..d221646e8 100644 --- a/src/Api/Controller/ShowForumController.php +++ b/src/Api/Controller/ShowForumController.php @@ -15,7 +15,7 @@ use Flarum\Core\Group; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class ShowForumController extends AbstractResourceController +class ShowForumController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Controller/ShowPostController.php b/src/Api/Controller/ShowPostController.php index 1ce1f367b..25e2f0e79 100644 --- a/src/Api/Controller/ShowPostController.php +++ b/src/Api/Controller/ShowPostController.php @@ -15,7 +15,7 @@ use Flarum\Core\Repository\PostRepository; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class ShowPostController extends AbstractResourceController +class ShowPostController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Controller/ShowUserController.php b/src/Api/Controller/ShowUserController.php index fd35b2867..2879a3c8b 100644 --- a/src/Api/Controller/ShowUserController.php +++ b/src/Api/Controller/ShowUserController.php @@ -15,7 +15,7 @@ use Flarum\Core\Repository\UserRepository; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class ShowUserController extends AbstractResourceController +class ShowUserController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Controller/UpdateDiscussionController.php b/src/Api/Controller/UpdateDiscussionController.php index fc7070be0..09ba078c5 100644 --- a/src/Api/Controller/UpdateDiscussionController.php +++ b/src/Api/Controller/UpdateDiscussionController.php @@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class UpdateDiscussionController extends AbstractResourceController +class UpdateDiscussionController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Controller/UpdateGroupController.php b/src/Api/Controller/UpdateGroupController.php index 748d35231..ccb6a8b6e 100644 --- a/src/Api/Controller/UpdateGroupController.php +++ b/src/Api/Controller/UpdateGroupController.php @@ -16,7 +16,7 @@ use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class UpdateGroupController extends AbstractResourceController +class UpdateGroupController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Controller/UpdateNotificationController.php b/src/Api/Controller/UpdateNotificationController.php index 46b015d8b..01e305bc7 100644 --- a/src/Api/Controller/UpdateNotificationController.php +++ b/src/Api/Controller/UpdateNotificationController.php @@ -16,7 +16,7 @@ use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class UpdateNotificationController extends AbstractResourceController +class UpdateNotificationController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Controller/UpdatePostController.php b/src/Api/Controller/UpdatePostController.php index a1e135e0b..bb5a5f08a 100644 --- a/src/Api/Controller/UpdatePostController.php +++ b/src/Api/Controller/UpdatePostController.php @@ -16,7 +16,7 @@ use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class UpdatePostController extends AbstractResourceController +class UpdatePostController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Controller/UpdateUserController.php b/src/Api/Controller/UpdateUserController.php index d11e07e68..78c009012 100644 --- a/src/Api/Controller/UpdateUserController.php +++ b/src/Api/Controller/UpdateUserController.php @@ -17,7 +17,7 @@ use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class UpdateUserController extends AbstractResourceController +class UpdateUserController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Controller/UploadAvatarController.php b/src/Api/Controller/UploadAvatarController.php index cd71f2b10..ac3619d24 100644 --- a/src/Api/Controller/UploadAvatarController.php +++ b/src/Api/Controller/UploadAvatarController.php @@ -16,7 +16,7 @@ use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class UploadAvatarController extends AbstractResourceController +class UploadAvatarController extends AbstractShowController { /** * {@inheritdoc} diff --git a/src/Api/Handler/FloodingExceptionHandler.php b/src/Api/ExceptionHandler/FloodingExceptionHandler.php similarity index 95% rename from src/Api/Handler/FloodingExceptionHandler.php rename to src/Api/ExceptionHandler/FloodingExceptionHandler.php index f589baa0a..53b6de082 100644 --- a/src/Api/Handler/FloodingExceptionHandler.php +++ b/src/Api/ExceptionHandler/FloodingExceptionHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Api\Handler; +namespace Flarum\Api\ExceptionHandler; use Exception; use Flarum\Core\Exception\FloodingException; diff --git a/src/Api/Handler/IlluminateValidationExceptionHandler.php b/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php similarity index 97% rename from src/Api/Handler/IlluminateValidationExceptionHandler.php rename to src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php index 16ccb3eff..ab5bfadcf 100644 --- a/src/Api/Handler/IlluminateValidationExceptionHandler.php +++ b/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Api\Handler; +namespace Flarum\Api\ExceptionHandler; use Exception; use Illuminate\Contracts\Validation\ValidationException; diff --git a/src/Api/Handler/InvalidAccessTokenExceptionHandler.php b/src/Api/ExceptionHandler/InvalidAccessTokenExceptionHandler.php similarity index 95% rename from src/Api/Handler/InvalidAccessTokenExceptionHandler.php rename to src/Api/ExceptionHandler/InvalidAccessTokenExceptionHandler.php index 4a8c4b5e5..c91964f17 100644 --- a/src/Api/Handler/InvalidAccessTokenExceptionHandler.php +++ b/src/Api/ExceptionHandler/InvalidAccessTokenExceptionHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Api\Handler; +namespace Flarum\Api\ExceptionHandler; use Exception; use Flarum\Api\Exception\InvalidAccessTokenException; diff --git a/src/Api/Handler/InvalidConfirmationTokenExceptionHandler.php b/src/Api/ExceptionHandler/InvalidConfirmationTokenExceptionHandler.php similarity index 96% rename from src/Api/Handler/InvalidConfirmationTokenExceptionHandler.php rename to src/Api/ExceptionHandler/InvalidConfirmationTokenExceptionHandler.php index bce460c0d..7c2465dce 100644 --- a/src/Api/Handler/InvalidConfirmationTokenExceptionHandler.php +++ b/src/Api/ExceptionHandler/InvalidConfirmationTokenExceptionHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Api\Handler; +namespace Flarum\Api\ExceptionHandler; use Exception; use Flarum\Core\Exception\InvalidConfirmationTokenException; diff --git a/src/Api/Handler/MethodNotAllowedExceptionHandler.php b/src/Api/ExceptionHandler/MethodNotAllowedExceptionHandler.php similarity index 95% rename from src/Api/Handler/MethodNotAllowedExceptionHandler.php rename to src/Api/ExceptionHandler/MethodNotAllowedExceptionHandler.php index 04d16075a..729815e95 100644 --- a/src/Api/Handler/MethodNotAllowedExceptionHandler.php +++ b/src/Api/ExceptionHandler/MethodNotAllowedExceptionHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Api\Handler; +namespace Flarum\Api\ExceptionHandler; use Exception; use Flarum\Http\Exception\MethodNotAllowedException; diff --git a/src/Api/Handler/ModelNotFoundExceptionHandler.php b/src/Api/ExceptionHandler/ModelNotFoundExceptionHandler.php similarity index 95% rename from src/Api/Handler/ModelNotFoundExceptionHandler.php rename to src/Api/ExceptionHandler/ModelNotFoundExceptionHandler.php index fe8b24fce..e921eb166 100644 --- a/src/Api/Handler/ModelNotFoundExceptionHandler.php +++ b/src/Api/ExceptionHandler/ModelNotFoundExceptionHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Api\Handler; +namespace Flarum\Api\ExceptionHandler; use Exception; use Illuminate\Database\Eloquent\ModelNotFoundException; diff --git a/src/Api/Handler/PermissionDeniedExceptionHandler.php b/src/Api/ExceptionHandler/PermissionDeniedExceptionHandler.php similarity index 95% rename from src/Api/Handler/PermissionDeniedExceptionHandler.php rename to src/Api/ExceptionHandler/PermissionDeniedExceptionHandler.php index d9c863e2d..059c9369d 100644 --- a/src/Api/Handler/PermissionDeniedExceptionHandler.php +++ b/src/Api/ExceptionHandler/PermissionDeniedExceptionHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Api\Handler; +namespace Flarum\Api\ExceptionHandler; use Exception; use Flarum\Core\Exception\PermissionDeniedException; diff --git a/src/Api/Handler/RouteNotFoundExceptionHandler.php b/src/Api/ExceptionHandler/RouteNotFoundExceptionHandler.php similarity index 95% rename from src/Api/Handler/RouteNotFoundExceptionHandler.php rename to src/Api/ExceptionHandler/RouteNotFoundExceptionHandler.php index 382c218ce..67c25d6a1 100644 --- a/src/Api/Handler/RouteNotFoundExceptionHandler.php +++ b/src/Api/ExceptionHandler/RouteNotFoundExceptionHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Api\Handler; +namespace Flarum\Api\ExceptionHandler; use Exception; use Flarum\Http\Exception\RouteNotFoundException; diff --git a/src/Api/Handler/TokenMismatchExceptionHandler.php b/src/Api/ExceptionHandler/TokenMismatchExceptionHandler.php similarity index 95% rename from src/Api/Handler/TokenMismatchExceptionHandler.php rename to src/Api/ExceptionHandler/TokenMismatchExceptionHandler.php index c4abf7408..2258b4cd6 100644 --- a/src/Api/Handler/TokenMismatchExceptionHandler.php +++ b/src/Api/ExceptionHandler/TokenMismatchExceptionHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Api\Handler; +namespace Flarum\Api\ExceptionHandler; use Exception; use Flarum\Http\Exception\TokenMismatchException; diff --git a/src/Api/Handler/ValidationExceptionHandler.php b/src/Api/ExceptionHandler/ValidationExceptionHandler.php similarity index 97% rename from src/Api/Handler/ValidationExceptionHandler.php rename to src/Api/ExceptionHandler/ValidationExceptionHandler.php index d165ff68f..9a1f77ec1 100644 --- a/src/Api/Handler/ValidationExceptionHandler.php +++ b/src/Api/ExceptionHandler/ValidationExceptionHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Api\Handler; +namespace Flarum\Api\ExceptionHandler; use Exception; use Flarum\Core\Exception\ValidationException; diff --git a/src/Api/Serializer/DiscussionBasicSerializer.php b/src/Api/Serializer/BasicDiscussionSerializer.php similarity index 97% rename from src/Api/Serializer/DiscussionBasicSerializer.php rename to src/Api/Serializer/BasicDiscussionSerializer.php index 39bee72ff..82b4536c1 100644 --- a/src/Api/Serializer/DiscussionBasicSerializer.php +++ b/src/Api/Serializer/BasicDiscussionSerializer.php @@ -14,7 +14,7 @@ namespace Flarum\Api\Serializer; use Flarum\Core\Discussion; use InvalidArgumentException; -class DiscussionBasicSerializer extends AbstractSerializer +class BasicDiscussionSerializer extends AbstractSerializer { /** * {@inheritdoc} diff --git a/src/Api/Serializer/PostBasicSerializer.php b/src/Api/Serializer/BasicPostSerializer.php similarity index 96% rename from src/Api/Serializer/PostBasicSerializer.php rename to src/Api/Serializer/BasicPostSerializer.php index 962a7b28b..7bee512bd 100644 --- a/src/Api/Serializer/PostBasicSerializer.php +++ b/src/Api/Serializer/BasicPostSerializer.php @@ -15,7 +15,7 @@ use Flarum\Core\Post; use Flarum\Core\Post\CommentPost; use InvalidArgumentException; -class PostBasicSerializer extends AbstractSerializer +class BasicPostSerializer extends AbstractSerializer { /** * {@inheritdoc} diff --git a/src/Api/Serializer/UserBasicSerializer.php b/src/Api/Serializer/BasicUserSerializer.php similarity index 95% rename from src/Api/Serializer/UserBasicSerializer.php rename to src/Api/Serializer/BasicUserSerializer.php index 2699c8714..1d854c330 100644 --- a/src/Api/Serializer/UserBasicSerializer.php +++ b/src/Api/Serializer/BasicUserSerializer.php @@ -14,7 +14,7 @@ namespace Flarum\Api\Serializer; use Flarum\Core\User; use InvalidArgumentException; -class UserBasicSerializer extends AbstractSerializer +class BasicUserSerializer extends AbstractSerializer { /** * {@inheritdoc} diff --git a/src/Api/Serializer/DiscussionSerializer.php b/src/Api/Serializer/DiscussionSerializer.php index 47ef8c0ea..e26f8929b 100644 --- a/src/Api/Serializer/DiscussionSerializer.php +++ b/src/Api/Serializer/DiscussionSerializer.php @@ -14,7 +14,7 @@ namespace Flarum\Api\Serializer; use Flarum\Core\Access\Gate; use Flarum\Core\Discussion; -class DiscussionSerializer extends DiscussionBasicSerializer +class DiscussionSerializer extends BasicDiscussionSerializer { /** * @var Gate diff --git a/src/Api/Serializer/PostSerializer.php b/src/Api/Serializer/PostSerializer.php index cb6a40457..bb584dd3e 100644 --- a/src/Api/Serializer/PostSerializer.php +++ b/src/Api/Serializer/PostSerializer.php @@ -14,7 +14,7 @@ namespace Flarum\Api\Serializer; use Flarum\Core\Access\Gate; use Flarum\Core\Post\CommentPost; -class PostSerializer extends PostBasicSerializer +class PostSerializer extends BasicPostSerializer { /** * @var \Flarum\Core\Access\Gate diff --git a/src/Api/Serializer/UserSerializer.php b/src/Api/Serializer/UserSerializer.php index 5db640678..7bf6f62b2 100644 --- a/src/Api/Serializer/UserSerializer.php +++ b/src/Api/Serializer/UserSerializer.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Serializer; use Flarum\Core\Access\Gate; -class UserSerializer extends UserBasicSerializer +class UserSerializer extends BasicUserSerializer { /** * @var Gate diff --git a/src/Api/routes.php b/src/Api/routes.php new file mode 100644 index 000000000..0203b6131 --- /dev/null +++ b/src/Api/routes.php @@ -0,0 +1,304 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Flarum\Api\Controller; +use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteCollection; + +return function (RouteCollection $map, RouteHandlerFactory $route) { + // Get forum information + $map->get( + '/forum', + 'forum.show', + $route->toController(Controller\ShowForumController::class) + ); + + // Retrieve authentication token + $map->post( + '/token', + 'token', + $route->toController(Controller\TokenController::class) + ); + + // Send forgot password email + $map->post( + '/forgot', + 'forgot', + $route->toController(Controller\ForgotPasswordController::class) + ); + + /* + |-------------------------------------------------------------------------- + | Users + |-------------------------------------------------------------------------- + */ + + // List users + $map->get( + '/users', + 'users.index', + $route->toController(Controller\ListUsersController::class) + ); + + // Register a user + $map->post( + '/users', + 'users.create', + $route->toController(Controller\CreateUserController::class) + ); + + // Get a single user + $map->get( + '/users/{id}', + 'users.show', + $route->toController(Controller\ShowUserController::class) + ); + + // Edit a user + $map->patch( + '/users/{id}', + 'users.update', + $route->toController(Controller\UpdateUserController::class) + ); + + // Delete a user + $map->delete( + '/users/{id}', + 'users.delete', + $route->toController(Controller\DeleteUserController::class) + ); + + // Upload avatar + $map->post( + '/users/{id}/avatar', + 'users.avatar.upload', + $route->toController(Controller\UploadAvatarController::class) + ); + + // Remove avatar + $map->delete( + '/users/{id}/avatar', + 'users.avatar.delete', + $route->toController(Controller\DeleteAvatarController::class) + ); + + // send confirmation email + $map->post( + '/users/{id}/send-confirmation', + 'users.confirmation.send', + $route->toController(Controller\SendConfirmationEmailController::class) + ); + + /* + |-------------------------------------------------------------------------- + | Notifications + |-------------------------------------------------------------------------- + */ + + // List notifications for the current user + $map->get( + '/notifications', + 'notifications.index', + $route->toController(Controller\ListNotificationsController::class) + ); + + // Mark all notifications as read + $map->post( + '/notifications/read', + 'notifications.readAll', + $route->toController(Controller\ReadAllNotificationsController::class) + ); + + // Mark a single notification as read + $map->patch( + '/notifications/{id}', + 'notifications.update', + $route->toController(Controller\UpdateNotificationController::class) + ); + + /* + |-------------------------------------------------------------------------- + | Discussions + |-------------------------------------------------------------------------- + */ + + // List discussions + $map->get( + '/discussions', + 'discussions.index', + $route->toController(Controller\ListDiscussionsController::class) + ); + + // Create a discussion + $map->post( + '/discussions', + 'discussions.create', + $route->toController(Controller\CreateDiscussionController::class) + ); + + // Show a single discussion + $map->get( + '/discussions/{id}', + 'discussions.show', + $route->toController(Controller\ShowDiscussionController::class) + ); + + // Edit a discussion + $map->patch( + '/discussions/{id}', + 'discussions.update', + $route->toController(Controller\UpdateDiscussionController::class) + ); + + // Delete a discussion + $map->delete( + '/discussions/{id}', + 'discussions.delete', + $route->toController(Controller\DeleteDiscussionController::class) + ); + + /* + |-------------------------------------------------------------------------- + | Posts + |-------------------------------------------------------------------------- + */ + + // List posts, usually for a discussion + $map->get( + '/posts', + 'posts.index', + $route->toController(Controller\ListPostsController::class) + ); + + // Create a post + $map->post( + '/posts', + 'posts.create', + $route->toController(Controller\CreatePostController::class) + ); + + // Show a single or multiple posts by ID + $map->get( + '/posts/{id}', + 'posts.show', + $route->toController(Controller\ShowPostController::class) + ); + + // Edit a post + $map->patch( + '/posts/{id}', + 'posts.update', + $route->toController(Controller\UpdatePostController::class) + ); + + // Delete a post + $map->delete( + '/posts/{id}', + 'posts.delete', + $route->toController(Controller\DeletePostController::class) + ); + + /* + |-------------------------------------------------------------------------- + | Groups + |-------------------------------------------------------------------------- + */ + + // List groups + $map->get( + '/groups', + 'groups.index', + $route->toController(Controller\ListGroupsController::class) + ); + + // Create a group + $map->post( + '/groups', + 'groups.create', + $route->toController(Controller\CreateGroupController::class) + ); + + // Edit a group + $map->patch( + '/groups/{id}', + 'groups.update', + $route->toController(Controller\UpdateGroupController::class) + ); + + // Delete a group + $map->delete( + '/groups/{id}', + 'groups.delete', + $route->toController(Controller\DeleteGroupController::class) + ); + + /* + |-------------------------------------------------------------------------- + | Administration + |-------------------------------------------------------------------------- + */ + + // Toggle an extension + $map->patch( + '/extensions/{name}', + 'extensions.update', + $route->toController(Controller\UpdateExtensionController::class) + ); + + // Uninstall an extension + $map->delete( + '/extensions/{name}', + 'extensions.delete', + $route->toController(Controller\UninstallExtensionController::class) + ); + + // Update settings + $map->post( + '/settings', + 'settings', + $route->toController(Controller\SetSettingsController::class) + ); + + // Update a permission + $map->post( + '/permission', + 'permission', + $route->toController(Controller\SetPermissionController::class) + ); + + // Upload a logo + $map->post( + '/logo', + 'logo', + $route->toController(Controller\UploadLogoController::class) + ); + + // Remove the logo + $map->delete( + '/logo', + 'logo.delete', + $route->toController(Controller\DeleteLogoController::class) + ); + + // Upload a favicon + $map->post( + '/favicon', + 'favicon', + $route->toController(Controller\UploadFaviconController::class) + ); + + // Remove the favicon + $map->delete( + '/favicon', + 'favicon.delete', + $route->toController(Controller\DeleteFaviconController::class) + ); +}; diff --git a/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php b/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php index 0b57f03b6..6a70a96bc 100644 --- a/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php @@ -12,7 +12,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; -use Flarum\Api\Handler\FloodingExceptionHandler; +use Flarum\Api\ExceptionHandler\FloodingExceptionHandler; use Flarum\Core\Exception\FloodingException; use Tests\Test\TestCase; diff --git a/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php b/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php index 2830d723a..4960aba36 100644 --- a/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php @@ -12,7 +12,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; -use Flarum\Api\Handler\IlluminateValidationExceptionHandler; +use Flarum\Api\ExceptionHandler\IlluminateValidationExceptionHandler; use Illuminate\Contracts\Validation\ValidationException; use Illuminate\Validation\Factory; use Symfony\Component\Translation\Translator; diff --git a/tests/Flarum/Api/Handler/InvalidAccessTokenExceptionHandlerTest.php b/tests/Flarum/Api/Handler/InvalidAccessTokenExceptionHandlerTest.php index 244523505..86620c558 100644 --- a/tests/Flarum/Api/Handler/InvalidAccessTokenExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/InvalidAccessTokenExceptionHandlerTest.php @@ -13,7 +13,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; use Flarum\Api\Exception\InvalidAccessTokenException; -use Flarum\Api\Handler\InvalidAccessTokenExceptionHandler; +use Flarum\Api\ExceptionHandler\InvalidAccessTokenExceptionHandler; use Tests\Test\TestCase; class InvalidAccessTokenExceptionHandlerTest extends TestCase diff --git a/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php b/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php index d11910065..6591fff1f 100644 --- a/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php @@ -12,7 +12,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; -use Flarum\Api\Handler\InvalidConfirmationTokenExceptionHandler; +use Flarum\Api\ExceptionHandler\InvalidConfirmationTokenExceptionHandler; use Flarum\Core\Exception\InvalidConfirmationTokenException; use Tests\Test\TestCase; diff --git a/tests/Flarum/Api/Handler/MethodNotAllowedExceptionHandlerTest.php b/tests/Flarum/Api/Handler/MethodNotAllowedExceptionHandlerTest.php index a03233ff0..e9c2b4e95 100644 --- a/tests/Flarum/Api/Handler/MethodNotAllowedExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/MethodNotAllowedExceptionHandlerTest.php @@ -12,7 +12,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; -use Flarum\Api\Handler\MethodNotAllowedExceptionHandler; +use Flarum\Api\ExceptionHandler\MethodNotAllowedExceptionHandler; use Flarum\Http\Exception\MethodNotAllowedException; use Tests\Test\TestCase; diff --git a/tests/Flarum/Api/Handler/ModelNotFoundExceptionHandlerTest.php b/tests/Flarum/Api/Handler/ModelNotFoundExceptionHandlerTest.php index aa20afd6f..fa0b88b9d 100644 --- a/tests/Flarum/Api/Handler/ModelNotFoundExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/ModelNotFoundExceptionHandlerTest.php @@ -12,7 +12,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; -use Flarum\Api\Handler\ModelNotFoundExceptionHandler; +use Flarum\Api\ExceptionHandler\ModelNotFoundExceptionHandler; use Illuminate\Database\Eloquent\ModelNotFoundException; use Tests\Test\TestCase; diff --git a/tests/Flarum/Api/Handler/PermissionDeniedExceptionHandlerTest.php b/tests/Flarum/Api/Handler/PermissionDeniedExceptionHandlerTest.php index 4f5e19729..10d52b19f 100644 --- a/tests/Flarum/Api/Handler/PermissionDeniedExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/PermissionDeniedExceptionHandlerTest.php @@ -12,7 +12,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; -use Flarum\Api\Handler\PermissionDeniedExceptionHandler; +use Flarum\Api\ExceptionHandler\PermissionDeniedExceptionHandler; use Flarum\Core\Exception\PermissionDeniedException; use Tests\Test\TestCase; diff --git a/tests/Flarum/Api/Handler/RouteNotFoundExceptionHandlerTest.php b/tests/Flarum/Api/Handler/RouteNotFoundExceptionHandlerTest.php index 570a8a9ce..6c2cca427 100644 --- a/tests/Flarum/Api/Handler/RouteNotFoundExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/RouteNotFoundExceptionHandlerTest.php @@ -12,7 +12,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; -use Flarum\Api\Handler\RouteNotFoundExceptionHandler; +use Flarum\Api\ExceptionHandler\RouteNotFoundExceptionHandler; use Flarum\Http\Exception\RouteNotFoundException; use Tests\Test\TestCase; diff --git a/tests/Flarum/Api/Handler/TokenMismatchExceptionHandlerTest.php b/tests/Flarum/Api/Handler/TokenMismatchExceptionHandlerTest.php index 0a4dba406..4faf9b7c8 100644 --- a/tests/Flarum/Api/Handler/TokenMismatchExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/TokenMismatchExceptionHandlerTest.php @@ -12,7 +12,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; -use Flarum\Api\Handler\TokenMismatchExceptionHandler; +use Flarum\Api\ExceptionHandler\TokenMismatchExceptionHandler; use Flarum\Http\Exception\TokenMismatchException; use Tests\Test\TestCase; diff --git a/tests/Flarum/Api/Handler/ValidationExceptionHandlerTest.php b/tests/Flarum/Api/Handler/ValidationExceptionHandlerTest.php index d32bcc6cc..2d2130cf1 100644 --- a/tests/Flarum/Api/Handler/ValidationExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/ValidationExceptionHandlerTest.php @@ -12,7 +12,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; -use Flarum\Api\Handler\ValidationExceptionHandler; +use Flarum\Api\ExceptionHandler\ValidationExceptionHandler; use Flarum\Core\Exception\ValidationException; use Tests\Test\TestCase; From c6985ae31c093cf72a223ef4659e673807703368 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 24 Jun 2017 11:29:44 +0200 Subject: [PATCH 03/86] Restructure Flarum\Console namespace --- src/Console/{Command => }/AbstractCommand.php | 2 +- src/Console/Server.php | 2 +- .../Command => Database/Console}/GenerateMigrationCommand.php | 3 ++- src/Debug/Console/CacheClearCommand.php | 2 +- src/Debug/Console/InfoCommand.php | 2 +- src/Install/Console/InstallCommand.php | 2 +- src/Update/Console/MigrateCommand.php | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) rename src/Console/{Command => }/AbstractCommand.php (97%) rename src/{Console/Command => Database/Console}/GenerateMigrationCommand.php (97%) diff --git a/src/Console/Command/AbstractCommand.php b/src/Console/AbstractCommand.php similarity index 97% rename from src/Console/Command/AbstractCommand.php rename to src/Console/AbstractCommand.php index 771a85b6e..3d01d5ecc 100644 --- a/src/Console/Command/AbstractCommand.php +++ b/src/Console/AbstractCommand.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Console\Command; +namespace Flarum\Console; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Console/Server.php b/src/Console/Server.php index f58971735..ecbf3f8ab 100644 --- a/src/Console/Server.php +++ b/src/Console/Server.php @@ -11,7 +11,7 @@ namespace Flarum\Console; -use Flarum\Console\Command\GenerateMigrationCommand; +use Flarum\Database\Console\GenerateMigrationCommand; use Flarum\Debug\Console\CacheClearCommand; use Flarum\Debug\Console\InfoCommand; use Flarum\Foundation\AbstractServer; diff --git a/src/Console/Command/GenerateMigrationCommand.php b/src/Database/Console/GenerateMigrationCommand.php similarity index 97% rename from src/Console/Command/GenerateMigrationCommand.php rename to src/Database/Console/GenerateMigrationCommand.php index cfdc59229..edf7a7024 100644 --- a/src/Console/Command/GenerateMigrationCommand.php +++ b/src/Database/Console/GenerateMigrationCommand.php @@ -9,8 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Console\Command; +namespace Flarum\Database\Console; +use Flarum\Console\AbstractCommand; use Flarum\Database\MigrationCreator; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Debug/Console/CacheClearCommand.php b/src/Debug/Console/CacheClearCommand.php index 554e24824..76b66b3b0 100644 --- a/src/Debug/Console/CacheClearCommand.php +++ b/src/Debug/Console/CacheClearCommand.php @@ -12,7 +12,7 @@ namespace Flarum\Debug\Console; use Flarum\Admin\Frontend as AdminWebApp; -use Flarum\Console\Command\AbstractCommand; +use Flarum\Console\AbstractCommand; use Flarum\Forum\WebApp as ForumWebApp; use Illuminate\Contracts\Cache\Store; diff --git a/src/Debug/Console/InfoCommand.php b/src/Debug/Console/InfoCommand.php index 9f3c36831..e14fb8468 100644 --- a/src/Debug/Console/InfoCommand.php +++ b/src/Debug/Console/InfoCommand.php @@ -11,7 +11,7 @@ namespace Flarum\Debug\Console; -use Flarum\Console\Command\AbstractCommand; +use Flarum\Console\AbstractCommand; use Flarum\Extension\ExtensionManager; use Flarum\Foundation\Application; diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index 6dacaeb6f..1a7317830 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -12,7 +12,7 @@ namespace Flarum\Install\Console; use Exception; -use Flarum\Console\Command\AbstractCommand; +use Flarum\Console\AbstractCommand; use Flarum\Core\Group; use Flarum\Core\Permission; use Flarum\Core\User; diff --git a/src/Update/Console/MigrateCommand.php b/src/Update/Console/MigrateCommand.php index 1f2c62f83..bdff208c0 100644 --- a/src/Update/Console/MigrateCommand.php +++ b/src/Update/Console/MigrateCommand.php @@ -11,7 +11,7 @@ namespace Flarum\Update\Console; -use Flarum\Console\Command\AbstractCommand; +use Flarum\Console\AbstractCommand; use Illuminate\Contracts\Container\Container; class MigrateCommand extends AbstractCommand From d897839097c7340c3d23592dae163d646f47ca26 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 24 Jun 2017 11:34:29 +0200 Subject: [PATCH 04/86] Restructure Flarum\Database namespace --- src/Console/Server.php | 2 +- .../Console/MigrateCommand.php | 2 +- src/Database/DatabaseServiceProvider.php | 9 ------ src/Database/MigrationServiceProvider.php | 32 +++++++++++++++++++ src/Update/Controller/UpdateController.php | 2 +- 5 files changed, 35 insertions(+), 12 deletions(-) rename src/{Update => Database}/Console/MigrateCommand.php (98%) create mode 100644 src/Database/MigrationServiceProvider.php diff --git a/src/Console/Server.php b/src/Console/Server.php index ecbf3f8ab..d18533e42 100644 --- a/src/Console/Server.php +++ b/src/Console/Server.php @@ -16,7 +16,7 @@ use Flarum\Debug\Console\CacheClearCommand; use Flarum\Debug\Console\InfoCommand; use Flarum\Foundation\AbstractServer; use Flarum\Install\Console\InstallCommand; -use Flarum\Update\Console\MigrateCommand; +use Flarum\Database\Console\MigrateCommand; use Symfony\Component\Console\Application; class Server extends AbstractServer diff --git a/src/Update/Console/MigrateCommand.php b/src/Database/Console/MigrateCommand.php similarity index 98% rename from src/Update/Console/MigrateCommand.php rename to src/Database/Console/MigrateCommand.php index bdff208c0..f5782d13f 100644 --- a/src/Update/Console/MigrateCommand.php +++ b/src/Database/Console/MigrateCommand.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Update\Console; +namespace Flarum\Database\Console; use Flarum\Console\AbstractCommand; use Illuminate\Contracts\Container\Container; diff --git a/src/Database/DatabaseServiceProvider.php b/src/Database/DatabaseServiceProvider.php index 87324330c..c4b349074 100644 --- a/src/Database/DatabaseServiceProvider.php +++ b/src/Database/DatabaseServiceProvider.php @@ -12,7 +12,6 @@ namespace Flarum\Database; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Foundation\Application; use Illuminate\Database\ConnectionResolver; use Illuminate\Database\Connectors\ConnectionFactory; use PDO; @@ -46,14 +45,6 @@ class DatabaseServiceProvider extends AbstractServiceProvider }); $this->app->alias('Illuminate\Database\ConnectionResolverInterface', 'db'); - - $this->app->singleton('Flarum\Database\MigrationRepositoryInterface', function ($app) { - return new DatabaseMigrationRepository($app['db'], 'migrations'); - }); - - $this->app->bind(MigrationCreator::class, function (Application $app) { - return new MigrationCreator($app->make('Illuminate\Filesystem\Filesystem'), $app->basePath()); - }); } /** diff --git a/src/Database/MigrationServiceProvider.php b/src/Database/MigrationServiceProvider.php new file mode 100644 index 000000000..5a21c9ada --- /dev/null +++ b/src/Database/MigrationServiceProvider.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Database; + +use Flarum\Foundation\AbstractServiceProvider; +use Flarum\Foundation\Application; + +class MigrationServiceProvider extends AbstractServiceProvider +{ + /** + * {@inheritdoc} + */ + public function register() + { + $this->app->singleton('Flarum\Database\MigrationRepositoryInterface', function ($app) { + return new DatabaseMigrationRepository($app['db'], 'migrations'); + }); + + $this->app->bind(MigrationCreator::class, function (Application $app) { + return new MigrationCreator($app->make('Illuminate\Filesystem\Filesystem'), $app->basePath()); + }); + } +} diff --git a/src/Update/Controller/UpdateController.php b/src/Update/Controller/UpdateController.php index 9b20ede72..2a0335030 100644 --- a/src/Update/Controller/UpdateController.php +++ b/src/Update/Controller/UpdateController.php @@ -14,7 +14,7 @@ namespace Flarum\Update\Controller; use Exception; use Flarum\Foundation\Application; use Flarum\Http\Controller\ControllerInterface; -use Flarum\Update\Console\MigrateCommand; +use Flarum\Database\Console\MigrateCommand; use Psr\Http\Message\ServerRequestInterface as Request; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\StreamOutput; From 5ae2e9d232471449facbdc6bd3c287e3e2509adb Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 24 Jun 2017 11:36:24 +0200 Subject: [PATCH 05/86] Get rid of Flarum\Debug namespace --- src/Console/Server.php | 4 ++-- src/{Debug => Foundation}/Console/CacheClearCommand.php | 2 +- src/{Debug => Foundation}/Console/InfoCommand.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename src/{Debug => Foundation}/Console/CacheClearCommand.php (97%) rename src/{Debug => Foundation}/Console/InfoCommand.php (98%) diff --git a/src/Console/Server.php b/src/Console/Server.php index d18533e42..45366ec83 100644 --- a/src/Console/Server.php +++ b/src/Console/Server.php @@ -12,8 +12,8 @@ namespace Flarum\Console; use Flarum\Database\Console\GenerateMigrationCommand; -use Flarum\Debug\Console\CacheClearCommand; -use Flarum\Debug\Console\InfoCommand; +use Flarum\Foundation\Console\CacheClearCommand; +use Flarum\Foundation\Console\InfoCommand; use Flarum\Foundation\AbstractServer; use Flarum\Install\Console\InstallCommand; use Flarum\Database\Console\MigrateCommand; diff --git a/src/Debug/Console/CacheClearCommand.php b/src/Foundation/Console/CacheClearCommand.php similarity index 97% rename from src/Debug/Console/CacheClearCommand.php rename to src/Foundation/Console/CacheClearCommand.php index 76b66b3b0..f669205bd 100644 --- a/src/Debug/Console/CacheClearCommand.php +++ b/src/Foundation/Console/CacheClearCommand.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Debug\Console; +namespace Flarum\Foundation\Console; use Flarum\Admin\Frontend as AdminWebApp; use Flarum\Console\AbstractCommand; diff --git a/src/Debug/Console/InfoCommand.php b/src/Foundation/Console/InfoCommand.php similarity index 98% rename from src/Debug/Console/InfoCommand.php rename to src/Foundation/Console/InfoCommand.php index e14fb8468..1a467051a 100644 --- a/src/Debug/Console/InfoCommand.php +++ b/src/Foundation/Console/InfoCommand.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Debug\Console; +namespace Flarum\Foundation\Console; use Flarum\Console\AbstractCommand; use Flarum\Extension\ExtensionManager; From acf43606a86a94a3a116754d7365026fc2cb9e53 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 24 Jun 2017 11:38:23 +0200 Subject: [PATCH 06/86] Register new MigrationServiceProvider --- src/Foundation/AbstractServer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Foundation/AbstractServer.php b/src/Foundation/AbstractServer.php index e98ec05cf..34ef520d2 100644 --- a/src/Foundation/AbstractServer.php +++ b/src/Foundation/AbstractServer.php @@ -168,6 +168,7 @@ abstract class AbstractServer $this->registerCache($app); $app->register('Flarum\Database\DatabaseServiceProvider'); + $app->register('Flarum\Database\MigrationServiceProvider'); $app->register('Flarum\Settings\SettingsServiceProvider'); $app->register('Flarum\Locale\LocaleServiceProvider'); $app->register('Illuminate\Bus\BusServiceProvider'); From 6268c3010f8d35489f9369db5ec5b26cb56eb69b Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 24 Jun 2017 11:40:45 +0200 Subject: [PATCH 07/86] Fix serializer class names --- src/Api/Serializer/BasicDiscussionSerializer.php | 10 +++++----- src/Api/Serializer/BasicPostSerializer.php | 4 ++-- src/Api/Serializer/NotificationSerializer.php | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Api/Serializer/BasicDiscussionSerializer.php b/src/Api/Serializer/BasicDiscussionSerializer.php index 82b4536c1..1fb175601 100644 --- a/src/Api/Serializer/BasicDiscussionSerializer.php +++ b/src/Api/Serializer/BasicDiscussionSerializer.php @@ -46,7 +46,7 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function startUser($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\UserBasicSerializer'); + return $this->hasOne($discussion, 'Flarum\Api\Serializer\BasicUserSerializer'); } /** @@ -54,7 +54,7 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function startPost($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\PostBasicSerializer'); + return $this->hasOne($discussion, 'Flarum\Api\Serializer\BasicPostSerializer'); } /** @@ -62,7 +62,7 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function lastUser($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\UserBasicSerializer'); + return $this->hasOne($discussion, 'Flarum\Api\Serializer\BasicUserSerializer'); } /** @@ -70,7 +70,7 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function lastPost($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\PostBasicSerializer'); + return $this->hasOne($discussion, 'Flarum\Api\Serializer\BasicPostSerializer'); } /** @@ -86,6 +86,6 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function relevantPosts($discussion) { - return $this->hasMany($discussion, 'Flarum\Api\Serializer\PostBasicSerializer'); + return $this->hasMany($discussion, 'Flarum\Api\Serializer\BasicPostSerializer'); } } diff --git a/src/Api/Serializer/BasicPostSerializer.php b/src/Api/Serializer/BasicPostSerializer.php index 7bee512bd..2988a6343 100644 --- a/src/Api/Serializer/BasicPostSerializer.php +++ b/src/Api/Serializer/BasicPostSerializer.php @@ -57,7 +57,7 @@ class BasicPostSerializer extends AbstractSerializer */ protected function user($post) { - return $this->hasOne($post, 'Flarum\Api\Serializer\UserBasicSerializer'); + return $this->hasOne($post, 'Flarum\Api\Serializer\BasicUserSerializer'); } /** @@ -65,6 +65,6 @@ class BasicPostSerializer extends AbstractSerializer */ protected function discussion($post) { - return $this->hasOne($post, 'Flarum\Api\Serializer\DiscussionBasicSerializer'); + return $this->hasOne($post, 'Flarum\Api\Serializer\BasicDiscussionSerializer'); } } diff --git a/src/Api/Serializer/NotificationSerializer.php b/src/Api/Serializer/NotificationSerializer.php index a599ffe31..bfbd8e943 100644 --- a/src/Api/Serializer/NotificationSerializer.php +++ b/src/Api/Serializer/NotificationSerializer.php @@ -57,7 +57,7 @@ class NotificationSerializer extends AbstractSerializer */ protected function user($notification) { - return $this->hasOne($notification, 'Flarum\Api\Serializer\UserBasicSerializer'); + return $this->hasOne($notification, 'Flarum\Api\Serializer\BasicUserSerializer'); } /** @@ -65,7 +65,7 @@ class NotificationSerializer extends AbstractSerializer */ protected function sender($notification) { - return $this->hasOne($notification, 'Flarum\Api\Serializer\UserBasicSerializer'); + return $this->hasOne($notification, 'Flarum\Api\Serializer\BasicUserSerializer'); } /** From 0be13d50bd32847f88803d098e00c99a19ad97de Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 24 Jun 2017 11:52:53 +0200 Subject: [PATCH 08/86] Create new Flarum\Frontend namespace It replaces the old Http\WebApp namespace and swallows other namespaces and files, such as Flarum\Asset. --- src/Admin/AdminServiceProvider.php | 2 +- src/Admin/Controller/FrontendController.php | 4 +-- src/Admin/Frontend.php | 4 +-- src/Event/ConfigureWebApp.php | 16 +++++----- .../Controller/AuthorizedWebAppController.php | 2 +- src/Forum/Controller/DiscussionController.php | 6 ++-- src/Forum/Controller/IndexController.php | 6 ++-- src/Forum/Controller/WebAppController.php | 8 ++--- src/Forum/ForumServiceProvider.php | 6 ++-- src/Forum/WebApp.php | 12 ++++---- src/Foundation/Console/CacheClearCommand.php | 4 +-- .../AbstractFrontend.php} | 30 +++++++++---------- .../AbstractFrontendController.php} | 10 +++---- .../Asset/CompilerInterface.php | 2 +- src/{ => Frontend}/Asset/JsCompiler.php | 2 +- src/{ => Frontend}/Asset/LessCompiler.php | 2 +- .../Asset/LocaleJsCompiler.php} | 6 ++-- src/{ => Frontend}/Asset/RevisionCompiler.php | 2 +- .../FrontendAssets.php} | 10 +++---- .../FrontendAssetsFactory.php} | 8 ++--- .../FrontendView.php} | 16 +++++----- .../FrontendViewFactory.php} | 12 ++++---- 22 files changed, 84 insertions(+), 86 deletions(-) rename src/{Http/WebApp/AbstractWebApp.php => Frontend/AbstractFrontend.php} (85%) rename src/{Http/Controller/AbstractWebAppController.php => Frontend/AbstractFrontendController.php} (82%) rename src/{ => Frontend}/Asset/CompilerInterface.php (95%) rename src/{ => Frontend}/Asset/JsCompiler.php (98%) rename src/{ => Frontend}/Asset/LessCompiler.php (97%) rename src/{Locale/JsCompiler.php => Frontend/Asset/LocaleJsCompiler.php} (88%) rename src/{ => Frontend}/Asset/RevisionCompiler.php (99%) rename src/{Http/WebApp/WebAppAssets.php => Frontend/FrontendAssets.php} (94%) rename src/{Http/WebApp/WebAppAssetsFactory.php => Frontend/FrontendAssetsFactory.php} (84%) rename src/{Http/WebApp/WebAppView.php => Frontend/FrontendView.php} (96%) rename src/{Http/WebApp/WebAppViewFactory.php => Frontend/FrontendViewFactory.php} (81%) diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index 80713c37e..2cbd60a78 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -84,7 +84,7 @@ class AdminServiceProvider extends AbstractServiceProvider } /** - * @return \Flarum\Http\WebApp\WebAppAssets + * @return \Flarum\Frontend\FrontendAssets */ protected function getWebAppAssets() { diff --git a/src/Admin/Controller/FrontendController.php b/src/Admin/Controller/FrontendController.php index db8cc5c41..eb691f88f 100644 --- a/src/Admin/Controller/FrontendController.php +++ b/src/Admin/Controller/FrontendController.php @@ -15,12 +15,12 @@ use Flarum\Admin\Frontend; use Flarum\Core\Permission; use Flarum\Event\PrepareUnserializedSettings; use Flarum\Extension\ExtensionManager; -use Flarum\Http\Controller\AbstractWebAppController; +use Flarum\Frontend\AbstractFrontendController; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface; -class FrontendController extends AbstractWebAppController +class FrontendController extends AbstractFrontendController { /** * @var SettingsRepositoryInterface diff --git a/src/Admin/Frontend.php b/src/Admin/Frontend.php index 65be577f0..b984e15e2 100644 --- a/src/Admin/Frontend.php +++ b/src/Admin/Frontend.php @@ -11,9 +11,9 @@ namespace Flarum\Admin; -use Flarum\Http\WebApp\AbstractWebApp; +use Flarum\Frontend\AbstractFrontend; -class Frontend extends AbstractWebApp +class Frontend extends AbstractFrontend { /** * {@inheritdoc} diff --git a/src/Event/ConfigureWebApp.php b/src/Event/ConfigureWebApp.php index 014672ffc..a7f26591e 100644 --- a/src/Event/ConfigureWebApp.php +++ b/src/Event/ConfigureWebApp.php @@ -12,20 +12,20 @@ namespace Flarum\Event; use Flarum\Admin\Controller\FrontendController as AdminWebAppController; -use Flarum\Forum\Controller\WebAppController as ForumWebAppController; -use Flarum\Http\Controller\AbstractWebAppController; -use Flarum\Http\WebApp\WebAppView; +use Flarum\Forum\Controller\FrontendController as ForumWebAppController; +use Flarum\Frontend\AbstractFrontendController; +use Flarum\Frontend\FrontendView; use Psr\Http\Message\ServerRequestInterface; class ConfigureWebApp { /** - * @var AbstractWebAppController + * @var AbstractFrontendController */ public $controller; /** - * @var WebAppView + * @var FrontendView */ public $view; @@ -35,11 +35,11 @@ class ConfigureWebApp public $request; /** - * @param AbstractWebAppController $controller - * @param WebAppView $view + * @param AbstractFrontendController $controller + * @param FrontendView $view * @param ServerRequestInterface $request */ - public function __construct(AbstractWebAppController $controller, WebAppView $view, ServerRequestInterface $request) + public function __construct(AbstractFrontendController $controller, FrontendView $view, ServerRequestInterface $request) { $this->controller = $controller; $this->view = $view; diff --git a/src/Forum/Controller/AuthorizedWebAppController.php b/src/Forum/Controller/AuthorizedWebAppController.php index 51131479f..05a5baf96 100644 --- a/src/Forum/Controller/AuthorizedWebAppController.php +++ b/src/Forum/Controller/AuthorizedWebAppController.php @@ -14,7 +14,7 @@ namespace Flarum\Forum\Controller; use Flarum\Core\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface as Request; -class AuthorizedWebAppController extends WebAppController +class AuthorizedWebAppController extends FrontendController { /** * {@inheritdoc} diff --git a/src/Forum/Controller/DiscussionController.php b/src/Forum/Controller/DiscussionController.php index ebc7ab0de..f12b1092e 100644 --- a/src/Forum/Controller/DiscussionController.php +++ b/src/Forum/Controller/DiscussionController.php @@ -14,12 +14,12 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; use Flarum\Core\User; use Flarum\Forum\UrlGenerator; -use Flarum\Forum\WebApp; +use Flarum\Forum\Frontend; use Flarum\Http\Exception\RouteNotFoundException; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; -class DiscussionController extends WebAppController +class DiscussionController extends FrontendController { /** * @var ApiClient @@ -34,7 +34,7 @@ class DiscussionController extends WebAppController /** * {@inheritdoc} */ - public function __construct(WebApp $webApp, Dispatcher $events, Client $api, UrlGenerator $url) + public function __construct(Frontend $webApp, Dispatcher $events, Client $api, UrlGenerator $url) { parent::__construct($webApp, $events); diff --git a/src/Forum/Controller/IndexController.php b/src/Forum/Controller/IndexController.php index a4c059f34..8deeb7867 100644 --- a/src/Forum/Controller/IndexController.php +++ b/src/Forum/Controller/IndexController.php @@ -13,11 +13,11 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client as ApiClient; use Flarum\Core\User; -use Flarum\Forum\WebApp; +use Flarum\Forum\Frontend; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; -class IndexController extends WebAppController +class IndexController extends FrontendController { /** * @var ApiClient @@ -39,7 +39,7 @@ class IndexController extends WebAppController /** * {@inheritdoc} */ - public function __construct(WebApp $webApp, Dispatcher $events, ApiClient $api) + public function __construct(Frontend $webApp, Dispatcher $events, ApiClient $api) { parent::__construct($webApp, $events); diff --git a/src/Forum/Controller/WebAppController.php b/src/Forum/Controller/WebAppController.php index e24405150..ba863c019 100644 --- a/src/Forum/Controller/WebAppController.php +++ b/src/Forum/Controller/WebAppController.php @@ -11,16 +11,16 @@ namespace Flarum\Forum\Controller; -use Flarum\Forum\WebApp; -use Flarum\Http\Controller\AbstractWebAppController; +use Flarum\Forum\Frontend; +use Flarum\Frontend\AbstractFrontendController; use Illuminate\Contracts\Events\Dispatcher; -class WebAppController extends AbstractWebAppController +class FrontendController extends AbstractFrontendController { /** * {@inheritdoc} */ - public function __construct(WebApp $webApp, Dispatcher $events) + public function __construct(Frontend $webApp, Dispatcher $events) { $this->webApp = $webApp; $this->events = $events; diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 43f4c2bed..4c1fa33f7 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -73,7 +73,7 @@ class ForumServiceProvider extends AbstractServiceProvider $routes->get( '/u/{username}[/{filter:[^/]*}]', 'user', - $route->toController(Controller\WebAppController::class) + $route->toController(Controller\FrontendController::class) ); $routes->get( @@ -164,10 +164,10 @@ class ForumServiceProvider extends AbstractServiceProvider } /** - * @return \Flarum\Http\WebApp\WebAppAssets + * @return \Flarum\Frontend\FrontendAssets */ protected function getWebAppAssets() { - return $this->app->make(WebApp::class)->getAssets(); + return $this->app->make(Frontend::class)->getAssets(); } } diff --git a/src/Forum/WebApp.php b/src/Forum/WebApp.php index 310532922..c59ce5345 100644 --- a/src/Forum/WebApp.php +++ b/src/Forum/WebApp.php @@ -12,13 +12,13 @@ namespace Flarum\Forum; use Flarum\Formatter\Formatter; -use Flarum\Http\WebApp\AbstractWebApp; -use Flarum\Http\WebApp\WebAppAssetsFactory; -use Flarum\Http\WebApp\WebAppViewFactory; +use Flarum\Frontend\AbstractFrontend; +use Flarum\Frontend\FrontendAssetsFactory; +use Flarum\Frontend\FrontendViewFactory; use Flarum\Locale\LocaleManager; use Flarum\Settings\SettingsRepositoryInterface; -class WebApp extends AbstractWebApp +class Frontend extends AbstractFrontend { /** * @var Formatter @@ -29,8 +29,8 @@ class WebApp extends AbstractWebApp * {@inheritdoc} */ public function __construct( - WebAppAssetsFactory $assets, - WebAppViewFactory $view, + FrontendAssetsFactory $assets, + FrontendViewFactory $view, SettingsRepositoryInterface $settings, LocaleManager $locales, Formatter $formatter diff --git a/src/Foundation/Console/CacheClearCommand.php b/src/Foundation/Console/CacheClearCommand.php index f669205bd..957c33478 100644 --- a/src/Foundation/Console/CacheClearCommand.php +++ b/src/Foundation/Console/CacheClearCommand.php @@ -13,7 +13,7 @@ namespace Flarum\Foundation\Console; use Flarum\Admin\Frontend as AdminWebApp; use Flarum\Console\AbstractCommand; -use Flarum\Forum\WebApp as ForumWebApp; +use Flarum\Forum\Frontend as ForumWebApp; use Illuminate\Contracts\Cache\Store; class CacheClearCommand extends AbstractCommand @@ -24,7 +24,7 @@ class CacheClearCommand extends AbstractCommand protected $cache; /** - * @var \Flarum\Forum\WebApp + * @var \Flarum\Forum\Frontend */ protected $forum; diff --git a/src/Http/WebApp/AbstractWebApp.php b/src/Frontend/AbstractFrontend.php similarity index 85% rename from src/Http/WebApp/AbstractWebApp.php rename to src/Frontend/AbstractFrontend.php index 0e2bc24aa..d556e81b8 100644 --- a/src/Http/WebApp/AbstractWebApp.php +++ b/src/Frontend/AbstractFrontend.php @@ -9,20 +9,20 @@ * file that was distributed with this source code. */ -namespace Flarum\Http\WebApp; +namespace Flarum\Frontend; use Flarum\Locale\LocaleManager; use Flarum\Settings\SettingsRepositoryInterface; -abstract class AbstractWebApp +abstract class AbstractFrontend { /** - * @var WebAppAssetsFactory + * @var FrontendAssetsFactory */ protected $assets; /** - * @var WebAppViewFactory + * @var FrontendViewFactory */ protected $view; @@ -37,12 +37,12 @@ abstract class AbstractWebApp protected $locales; /** - * @param WebAppAssetsFactory $assets - * @param WebAppViewFactory $view + * @param FrontendAssetsFactory $assets + * @param FrontendViewFactory $view * @param SettingsRepositoryInterface $settings * @param LocaleManager $locales */ - public function __construct(WebAppAssetsFactory $assets, WebAppViewFactory $view, SettingsRepositoryInterface $settings, LocaleManager $locales) + public function __construct(FrontendAssetsFactory $assets, FrontendViewFactory $view, SettingsRepositoryInterface $settings, LocaleManager $locales) { $this->assets = $assets; $this->view = $view; @@ -51,7 +51,7 @@ abstract class AbstractWebApp } /** - * @return WebAppView + * @return FrontendView */ public function getView() { @@ -65,7 +65,7 @@ abstract class AbstractWebApp } /** - * @return WebAppAssets + * @return FrontendAssets */ public function getAssets() { @@ -100,9 +100,9 @@ abstract class AbstractWebApp } /** - * @param WebAppView $view + * @param FrontendView $view */ - private function addDefaultAssets(WebAppView $view) + private function addDefaultAssets(FrontendView $view) { $root = __DIR__.'/../../..'; $name = $this->getName(); @@ -112,9 +112,9 @@ abstract class AbstractWebApp } /** - * @param WebAppView $view + * @param FrontendView $view */ - private function addCustomLess(WebAppView $view) + private function addCustomLess(FrontendView $view) { $css = $view->getCss(); $localeCss = $view->getLocaleCss(); @@ -154,9 +154,9 @@ abstract class AbstractWebApp } /** - * @param WebAppView $view + * @param FrontendView $view */ - private function addTranslations(WebAppView $view) + private function addTranslations(FrontendView $view) { $translations = array_get($this->locales->getTranslator()->getMessages(), 'messages', []); diff --git a/src/Http/Controller/AbstractWebAppController.php b/src/Frontend/AbstractFrontendController.php similarity index 82% rename from src/Http/Controller/AbstractWebAppController.php rename to src/Frontend/AbstractFrontendController.php index a9af1f576..52eed3ac4 100644 --- a/src/Http/Controller/AbstractWebAppController.php +++ b/src/Frontend/AbstractFrontendController.php @@ -9,18 +9,18 @@ * file that was distributed with this source code. */ -namespace Flarum\Http\Controller; +namespace Flarum\Frontend; use Flarum\Event\ConfigureClientView; use Flarum\Event\ConfigureWebApp; -use Flarum\Http\WebApp\AbstractWebApp; +use Flarum\Http\Controller\AbstractHtmlController; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; -abstract class AbstractWebAppController extends AbstractHtmlController +abstract class AbstractFrontendController extends AbstractHtmlController { /** - * @var AbstractWebApp + * @var AbstractFrontend */ protected $webApp; @@ -48,7 +48,7 @@ abstract class AbstractWebAppController extends AbstractHtmlController /** * @param Request $request - * @return \Flarum\Http\WebApp\WebAppView + * @return \Flarum\Frontend\FrontendView */ protected function getView(Request $request) { diff --git a/src/Asset/CompilerInterface.php b/src/Frontend/Asset/CompilerInterface.php similarity index 95% rename from src/Asset/CompilerInterface.php rename to src/Frontend/Asset/CompilerInterface.php index 5e65eb596..2fb113ab5 100644 --- a/src/Asset/CompilerInterface.php +++ b/src/Frontend/Asset/CompilerInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Asset; +namespace Flarum\Frontend\Asset; interface CompilerInterface { diff --git a/src/Asset/JsCompiler.php b/src/Frontend/Asset/JsCompiler.php similarity index 98% rename from src/Asset/JsCompiler.php rename to src/Frontend/Asset/JsCompiler.php index 55771ead5..f99880a19 100644 --- a/src/Asset/JsCompiler.php +++ b/src/Frontend/Asset/JsCompiler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Asset; +namespace Flarum\Frontend\Asset; use Exception; use Illuminate\Cache\Repository; diff --git a/src/Asset/LessCompiler.php b/src/Frontend/Asset/LessCompiler.php similarity index 97% rename from src/Asset/LessCompiler.php rename to src/Frontend/Asset/LessCompiler.php index 382a1b210..e1b74af0c 100644 --- a/src/Asset/LessCompiler.php +++ b/src/Frontend/Asset/LessCompiler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Asset; +namespace Flarum\Frontend\Asset; use Less_Exception_Parser; use Less_Parser; diff --git a/src/Locale/JsCompiler.php b/src/Frontend/Asset/LocaleJsCompiler.php similarity index 88% rename from src/Locale/JsCompiler.php rename to src/Frontend/Asset/LocaleJsCompiler.php index db1d0b1e5..87b3d52a2 100644 --- a/src/Locale/JsCompiler.php +++ b/src/Frontend/Asset/LocaleJsCompiler.php @@ -9,11 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Locale; +namespace Flarum\Frontend\Asset; -use Flarum\Asset\JsCompiler as BaseJsCompiler; - -class JsCompiler extends BaseJsCompiler +class LocaleJsCompiler extends JsCompiler { protected $translations = []; diff --git a/src/Asset/RevisionCompiler.php b/src/Frontend/Asset/RevisionCompiler.php similarity index 99% rename from src/Asset/RevisionCompiler.php rename to src/Frontend/Asset/RevisionCompiler.php index 3993b90a7..74670af1f 100644 --- a/src/Asset/RevisionCompiler.php +++ b/src/Frontend/Asset/RevisionCompiler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Asset; +namespace Flarum\Frontend\Asset; class RevisionCompiler implements CompilerInterface { diff --git a/src/Http/WebApp/WebAppAssets.php b/src/Frontend/FrontendAssets.php similarity index 94% rename from src/Http/WebApp/WebAppAssets.php rename to src/Frontend/FrontendAssets.php index 92a7539be..e3bce2f16 100644 --- a/src/Http/WebApp/WebAppAssets.php +++ b/src/Frontend/FrontendAssets.php @@ -9,16 +9,16 @@ * file that was distributed with this source code. */ -namespace Flarum\Http\WebApp; +namespace Flarum\Frontend; -use Flarum\Asset\JsCompiler; -use Flarum\Asset\LessCompiler; +use Flarum\Frontend\Asset\JsCompiler; +use Flarum\Frontend\Asset\LessCompiler; use Flarum\Foundation\Application; -use Flarum\Locale\JsCompiler as LocaleJsCompiler; +use Flarum\Frontend\Asset\LocaleJsCompiler as LocaleJsCompiler; use Flarum\Locale\LocaleManager; use Illuminate\Contracts\Cache\Repository; -class WebAppAssets +class FrontendAssets { /** * @var string diff --git a/src/Http/WebApp/WebAppAssetsFactory.php b/src/Frontend/FrontendAssetsFactory.php similarity index 84% rename from src/Http/WebApp/WebAppAssetsFactory.php rename to src/Frontend/FrontendAssetsFactory.php index cb32ed30f..781963c41 100644 --- a/src/Http/WebApp/WebAppAssetsFactory.php +++ b/src/Frontend/FrontendAssetsFactory.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Http\WebApp; +namespace Flarum\Frontend; use Flarum\Foundation\Application; use Flarum\Locale\LocaleManager; use Illuminate\Contracts\Cache\Repository; -class WebAppAssetsFactory +class FrontendAssetsFactory { /** * @var Application @@ -46,10 +46,10 @@ class WebAppAssetsFactory /** * @param string $name - * @return WebAppAssets + * @return FrontendAssets */ public function make($name) { - return new WebAppAssets($name, $this->app, $this->cache, $this->locales); + return new FrontendAssets($name, $this->app, $this->cache, $this->locales); } } diff --git a/src/Http/WebApp/WebAppView.php b/src/Frontend/FrontendView.php similarity index 96% rename from src/Http/WebApp/WebAppView.php rename to src/Frontend/FrontendView.php index d38e95839..f564443ea 100644 --- a/src/Http/WebApp/WebAppView.php +++ b/src/Frontend/FrontendView.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Http\WebApp; +namespace Flarum\Frontend; use Flarum\Api\Client; use Flarum\Api\Serializer\AbstractSerializer; -use Flarum\Asset\CompilerInterface; +use Flarum\Frontend\Asset\CompilerInterface; use Flarum\Foundation\Application; -use Flarum\Locale\JsCompiler; +use Flarum\Frontend\Asset\LocaleJsCompiler; use Flarum\Locale\LocaleManager; use Illuminate\View\Factory; use Psr\Http\Message\ServerRequestInterface as Request; @@ -25,7 +25,7 @@ use Tobscure\JsonApi\Resource; /** * This class represents a view which boots up Flarum's client. */ -class WebAppView +class FrontendView { /** * The title of the document, displayed in the tag. @@ -135,7 +135,7 @@ class WebAppView protected $localeCss; /** - * @var WebAppAssets + * @var FrontendAssets */ protected $assets; @@ -166,14 +166,14 @@ class WebAppView /** * @param string $layout - * @param WebAppAssets $assets + * @param FrontendAssets $assets * @param Client $api * @param Factory $view * @param LocaleManager $locales * @param AbstractSerializer $userSerializer * @param Application $app */ - public function __construct($layout, WebAppAssets $assets, Client $api, Factory $view, LocaleManager $locales, AbstractSerializer $userSerializer, Application $app) + public function __construct($layout, FrontendAssets $assets, Client $api, Factory $view, LocaleManager $locales, AbstractSerializer $userSerializer, Application $app) { $this->layout = $layout; $this->api = $api; @@ -397,7 +397,7 @@ class WebAppView } /** - * @return JsCompiler + * @return LocaleJsCompiler */ public function getLocaleJs() { diff --git a/src/Http/WebApp/WebAppViewFactory.php b/src/Frontend/FrontendViewFactory.php similarity index 81% rename from src/Http/WebApp/WebAppViewFactory.php rename to src/Frontend/FrontendViewFactory.php index 037a162e9..82682c22a 100644 --- a/src/Http/WebApp/WebAppViewFactory.php +++ b/src/Frontend/FrontendViewFactory.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Http\WebApp; +namespace Flarum\Frontend; use Flarum\Api\Client; use Flarum\Api\Serializer\CurrentUserSerializer; @@ -17,7 +17,7 @@ use Flarum\Foundation\Application; use Flarum\Locale\LocaleManager; use Illuminate\Contracts\View\Factory; -class WebAppViewFactory +class FrontendViewFactory { /** * @var Client @@ -62,11 +62,11 @@ class WebAppViewFactory /** * @param string $layout - * @param WebAppAssets $assets - * @return WebAppView + * @param FrontendAssets $assets + * @return FrontendView */ - public function make($layout, WebAppAssets $assets) + public function make($layout, FrontendAssets $assets) { - return new WebAppView($layout, $assets, $this->api, $this->view, $this->locales, $this->userSerializer, $this->app); + return new FrontendView($layout, $assets, $this->api, $this->view, $this->locales, $this->userSerializer, $this->app); } } From 927e4ca3edf8db0eb9d512bc84fe29728c7c3f53 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 12:08:04 +0200 Subject: [PATCH 09/86] Restructure Flarum\Forum namespace --- src/Forum/ForumServiceProvider.php | 73 ++--------------------- src/Forum/{WebApp.php => Frontend.php} | 0 src/Forum/routes.php | 82 ++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 67 deletions(-) rename src/Forum/{WebApp.php => Frontend.php} (100%) create mode 100644 src/Forum/routes.php diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 4c1fa33f7..86ef67d31 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -56,82 +56,21 @@ class ForumServiceProvider extends AbstractServiceProvider */ protected function populateRoutes(RouteCollection $routes) { - $route = $this->app->make(RouteHandlerFactory::class); + $factory = $this->app->make(RouteHandlerFactory::class); - $routes->get( - '/all', - 'index', - $toDefaultController = $route->toController(Controller\IndexController::class) - ); - - $routes->get( - '/d/{id:\d+(?:-[^/]*)?}[/{near:[^/]*}]', - 'discussion', - $route->toController(Controller\DiscussionController::class) - ); - - $routes->get( - '/u/{username}[/{filter:[^/]*}]', - 'user', - $route->toController(Controller\FrontendController::class) - ); - - $routes->get( - '/settings', - 'settings', - $route->toController(Controller\AuthorizedWebAppController::class) - ); - - $routes->get( - '/notifications', - 'notifications', - $route->toController(Controller\AuthorizedWebAppController::class) - ); - - $routes->get( - '/logout', - 'logout', - $route->toController(Controller\LogOutController::class) - ); - - $routes->post( - '/login', - 'login', - $route->toController(Controller\LogInController::class) - ); - - $routes->post( - '/register', - 'register', - $route->toController(Controller\RegisterController::class) - ); - - $routes->get( - '/confirm/{token}', - 'confirmEmail', - $route->toController(Controller\ConfirmEmailController::class) - ); - - $routes->get( - '/reset/{token}', - 'resetPassword', - $route->toController(Controller\ResetPasswordController::class) - ); - - $routes->post( - '/reset', - 'savePassword', - $route->toController(Controller\SavePasswordController::class) - ); + $callback = include __DIR__.'/routes.php'; + $callback($routes, $factory); $this->app->make('events')->fire( - new ConfigureForumRoutes($routes, $route) + new ConfigureForumRoutes($routes, $factory) ); $defaultRoute = $this->app->make('flarum.settings')->get('default_route'); if (isset($routes->getRouteData()[0]['GET'][$defaultRoute])) { $toDefaultController = $routes->getRouteData()[0]['GET'][$defaultRoute]; + } else { + $toDefaultController = $factory->toController(Controller\IndexController::class); } $routes->get( diff --git a/src/Forum/WebApp.php b/src/Forum/Frontend.php similarity index 100% rename from src/Forum/WebApp.php rename to src/Forum/Frontend.php diff --git a/src/Forum/routes.php b/src/Forum/routes.php new file mode 100644 index 000000000..96e26dc3a --- /dev/null +++ b/src/Forum/routes.php @@ -0,0 +1,82 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Flarum\Forum\Controller; +use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteCollection; + +return function (RouteCollection $map, RouteHandlerFactory $route) { + $map->get( + '/all', + 'index', + $route->toController(Controller\IndexController::class) + ); + + $map->get( + '/d/{id:\d+(?:-[^/]*)?}[/{near:[^/]*}]', + 'discussion', + $route->toController(Controller\DiscussionController::class) + ); + + $map->get( + '/u/{username}[/{filter:[^/]*}]', + 'user', + $route->toController(Controller\FrontendController::class) + ); + + $map->get( + '/settings', + 'settings', + $route->toController(Controller\AuthorizedWebAppController::class) + ); + + $map->get( + '/notifications', + 'notifications', + $route->toController(Controller\AuthorizedWebAppController::class) + ); + + $map->get( + '/logout', + 'logout', + $route->toController(Controller\LogOutController::class) + ); + + $map->post( + '/login', + 'login', + $route->toController(Controller\LogInController::class) + ); + + $map->post( + '/register', + 'register', + $route->toController(Controller\RegisterController::class) + ); + + $map->get( + '/confirm/{token}', + 'confirmEmail', + $route->toController(Controller\ConfirmEmailController::class) + ); + + $map->get( + '/reset/{token}', + 'resetPassword', + $route->toController(Controller\ResetPasswordController::class) + ); + + $map->post( + '/reset', + 'savePassword', + $route->toController(Controller\SavePasswordController::class) + ); +}; From bdf455c0c69a8fd9f315e8e8510226519b656d0f Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 12:09:22 +0200 Subject: [PATCH 10/86] Move ScopeVisibilityTrait to Database namespace --- src/Core/Discussion.php | 2 +- src/Core/Group.php | 2 +- src/Core/Post.php | 2 +- src/Core/User.php | 2 +- src/{Core/Support => Database}/ScopeVisibilityTrait.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename src/{Core/Support => Database}/ScopeVisibilityTrait.php (95%) diff --git a/src/Core/Discussion.php b/src/Core/Discussion.php index a73e437e2..2d510ede5 100644 --- a/src/Core/Discussion.php +++ b/src/Core/Discussion.php @@ -13,7 +13,7 @@ namespace Flarum\Core; use Flarum\Core\Post\MergeableInterface; use Flarum\Core\Support\EventGeneratorTrait; -use Flarum\Core\Support\ScopeVisibilityTrait; +use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\DiscussionWasDeleted; use Flarum\Event\DiscussionWasHidden; diff --git a/src/Core/Group.php b/src/Core/Group.php index ad265e6f0..db081ffe5 100755 --- a/src/Core/Group.php +++ b/src/Core/Group.php @@ -12,7 +12,7 @@ namespace Flarum\Core; use Flarum\Core\Support\EventGeneratorTrait; -use Flarum\Core\Support\ScopeVisibilityTrait; +use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\GroupWasCreated; use Flarum\Event\GroupWasDeleted; diff --git a/src/Core/Post.php b/src/Core/Post.php index cb6717f4d..6d4ad5620 100755 --- a/src/Core/Post.php +++ b/src/Core/Post.php @@ -13,7 +13,7 @@ namespace Flarum\Core; use Flarum\Core\Post\RegisteredTypesScope; use Flarum\Core\Support\EventGeneratorTrait; -use Flarum\Core\Support\ScopeVisibilityTrait; +use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\PostWasDeleted; use Illuminate\Database\Eloquent\Builder; diff --git a/src/Core/User.php b/src/Core/User.php index 32f58e86a..fd175c998 100755 --- a/src/Core/User.php +++ b/src/Core/User.php @@ -14,7 +14,7 @@ namespace Flarum\Core; use DomainException; use Flarum\Core\Access\Gate; use Flarum\Core\Support\EventGeneratorTrait; -use Flarum\Core\Support\ScopeVisibilityTrait; +use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\CheckUserPassword; use Flarum\Event\ConfigureUserPreferences; diff --git a/src/Core/Support/ScopeVisibilityTrait.php b/src/Database/ScopeVisibilityTrait.php similarity index 95% rename from src/Core/Support/ScopeVisibilityTrait.php rename to src/Database/ScopeVisibilityTrait.php index 2768cbe62..0cfe43fc3 100644 --- a/src/Core/Support/ScopeVisibilityTrait.php +++ b/src/Database/ScopeVisibilityTrait.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Support; +namespace Flarum\Database; use Flarum\Core\User; use Flarum\Event\ScopeModelVisibility; From 1f1b63363ecc65d3856fcb005d2f4edf0dc481da Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 12:15:48 +0200 Subject: [PATCH 11/86] Rename controller file --- .../Controller/{WebAppController.php => FrontendController.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Forum/Controller/{WebAppController.php => FrontendController.php} (100%) diff --git a/src/Forum/Controller/WebAppController.php b/src/Forum/Controller/FrontendController.php similarity index 100% rename from src/Forum/Controller/WebAppController.php rename to src/Forum/Controller/FrontendController.php From 5d1564e0fc6551e5b750bfe4da30e551e9080a41 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 12:16:00 +0200 Subject: [PATCH 12/86] Flarum\Frontend: Fix view paths after renaming namespace --- src/Frontend/AbstractFrontend.php | 4 ++-- src/Frontend/FrontendView.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Frontend/AbstractFrontend.php b/src/Frontend/AbstractFrontend.php index d556e81b8..af4fc954e 100644 --- a/src/Frontend/AbstractFrontend.php +++ b/src/Frontend/AbstractFrontend.php @@ -86,7 +86,7 @@ abstract class AbstractFrontend */ protected function getLayout() { - return __DIR__.'/../../../views/'.$this->getName().'.blade.php'; + return __DIR__.'/../../views/'.$this->getName().'.blade.php'; } /** @@ -104,7 +104,7 @@ abstract class AbstractFrontend */ private function addDefaultAssets(FrontendView $view) { - $root = __DIR__.'/../../..'; + $root = __DIR__.'/../..'; $name = $this->getName(); $view->getJs()->addFile("$root/js/$name/dist/app.js"); diff --git a/src/Frontend/FrontendView.php b/src/Frontend/FrontendView.php index f564443ea..0593e070a 100644 --- a/src/Frontend/FrontendView.php +++ b/src/Frontend/FrontendView.php @@ -287,7 +287,7 @@ class FrontendView $this->view->share('forum', array_get($forum, 'data')); $this->view->share('debug', $this->app->inDebugMode()); - $view = $this->view->file(__DIR__.'/../../../views/app.blade.php'); + $view = $this->view->file(__DIR__.'/../../views/app.blade.php'); $view->title = $this->buildTitle(array_get($forum, 'data.attributes.title')); $view->description = $this->description ?: array_get($forum, 'data.attributes.description'); @@ -345,7 +345,7 @@ class FrontendView protected function buildContent() { - $view = $this->view->file(__DIR__.'/../../../views/content.blade.php'); + $view = $this->view->file(__DIR__.'/../../views/content.blade.php'); $view->content = $this->content; From fda8c597f4ff752f4168cc12c675b6f7c63be13b Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 12:19:59 +0200 Subject: [PATCH 13/86] Flarum\Frontend: Rename ConfigureWebApp event to Rendering --- src/Event/ConfigureClientView.php | 4 +++- src/Frontend/AbstractFrontendController.php | 4 ++-- .../ConfigureWebApp.php => Frontend/Event/Rendering.php} | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) rename src/{Event/ConfigureWebApp.php => Frontend/Event/Rendering.php} (97%) diff --git a/src/Event/ConfigureClientView.php b/src/Event/ConfigureClientView.php index 787b7ab9a..52375b9fe 100644 --- a/src/Event/ConfigureClientView.php +++ b/src/Event/ConfigureClientView.php @@ -11,9 +11,11 @@ namespace Flarum\Event; +use Flarum\Frontend\Event\Rendering; + /** * @deprecated */ -class ConfigureClientView extends ConfigureWebApp +class ConfigureClientView extends Rendering { } diff --git a/src/Frontend/AbstractFrontendController.php b/src/Frontend/AbstractFrontendController.php index 52eed3ac4..cd7eba06b 100644 --- a/src/Frontend/AbstractFrontendController.php +++ b/src/Frontend/AbstractFrontendController.php @@ -12,7 +12,7 @@ namespace Flarum\Frontend; use Flarum\Event\ConfigureClientView; -use Flarum\Event\ConfigureWebApp; +use Flarum\Frontend\Event\Rendering; use Flarum\Http\Controller\AbstractHtmlController; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; @@ -40,7 +40,7 @@ abstract class AbstractFrontendController extends AbstractHtmlController new ConfigureClientView($this, $view, $request) ); $this->events->fire( - new ConfigureWebApp($this, $view, $request) + new Rendering($this, $view, $request) ); return $view->render($request); diff --git a/src/Event/ConfigureWebApp.php b/src/Frontend/Event/Rendering.php similarity index 97% rename from src/Event/ConfigureWebApp.php rename to src/Frontend/Event/Rendering.php index a7f26591e..6219c557f 100644 --- a/src/Event/ConfigureWebApp.php +++ b/src/Frontend/Event/Rendering.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Frontend\Event; use Flarum\Admin\Controller\FrontendController as AdminWebAppController; use Flarum\Forum\Controller\FrontendController as ForumWebAppController; @@ -17,7 +17,7 @@ use Flarum\Frontend\AbstractFrontendController; use Flarum\Frontend\FrontendView; use Psr\Http\Message\ServerRequestInterface; -class ConfigureWebApp +class Rendering { /** * @var AbstractFrontendController From 564ea8ff73b58bcc889b15c587e8b3c9cd0cd67c Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 12:55:22 +0200 Subject: [PATCH 14/86] Extract new Flarum\User namespace --- src/Api/Client.php | 2 +- .../Controller/ForgotPasswordController.php | 6 +-- .../ListNotificationsController.php | 2 +- src/Api/Controller/ListUsersController.php | 4 +- .../SendConfirmationEmailController.php | 4 +- .../Controller/ShowDiscussionController.php | 2 +- src/Api/Controller/ShowUserController.php | 6 +-- src/Api/Controller/TokenController.php | 6 +-- src/Api/Controller/UpdateUserController.php | 2 +- ...validConfirmationTokenExceptionHandler.php | 2 +- .../PermissionDeniedExceptionHandler.php | 2 +- src/Api/Serializer/AbstractSerializer.php | 2 +- src/Api/Serializer/BasicUserSerializer.php | 2 +- src/Api/Serializer/DiscussionSerializer.php | 6 +-- src/Api/Serializer/PostSerializer.php | 6 +-- src/Api/Serializer/UserSerializer.php | 4 +- src/Core/Access/AssertPermissionTrait.php | 6 +-- src/Core/Access/DiscussionPolicy.php | 4 +- src/Core/Access/GroupPolicy.php | 3 +- src/Core/Access/PostPolicy.php | 3 +- src/Core/Command/ConfirmEmailHandler.php | 10 ++--- src/Core/Command/CreateGroup.php | 2 +- src/Core/Command/CreateGroupHandler.php | 4 +- src/Core/Command/DeleteAvatar.php | 2 +- src/Core/Command/DeleteAvatarHandler.php | 8 ++-- src/Core/Command/DeleteDiscussion.php | 2 +- src/Core/Command/DeleteDiscussionHandler.php | 2 +- src/Core/Command/DeleteGroup.php | 2 +- src/Core/Command/DeleteGroupHandler.php | 2 +- src/Core/Command/DeletePost.php | 2 +- src/Core/Command/DeletePostHandler.php | 4 +- src/Core/Command/DeleteUser.php | 2 +- src/Core/Command/DeleteUserHandler.php | 10 ++--- src/Core/Command/EditDiscussion.php | 6 +-- src/Core/Command/EditDiscussionHandler.php | 4 +- src/Core/Command/EditGroup.php | 2 +- src/Core/Command/EditGroupHandler.php | 2 +- src/Core/Command/EditPost.php | 2 +- src/Core/Command/EditPostHandler.php | 2 +- src/Core/Command/EditUser.php | 2 +- src/Core/Command/EditUserHandler.php | 20 ++++----- src/Core/Command/PostReply.php | 2 +- src/Core/Command/PostReplyHandler.php | 2 +- src/Core/Command/ReadAllNotifications.php | 2 +- .../Command/ReadAllNotificationsHandler.php | 2 +- src/Core/Command/ReadDiscussion.php | 2 +- src/Core/Command/ReadDiscussionHandler.php | 2 +- src/Core/Command/ReadNotification.php | 2 +- src/Core/Command/ReadNotificationHandler.php | 2 +- src/Core/Command/RegisterUser.php | 2 +- src/Core/Command/RegisterUserHandler.php | 14 +++--- .../Command/RequestPasswordResetHandler.php | 8 ++-- src/Core/Command/StartDiscussion.php | 2 +- src/Core/Command/UploadAvatar.php | 2 +- src/Core/Command/UploadAvatarHandler.php | 14 +++--- src/Core/CoreServiceProvider.php | 11 ++--- src/Core/Discussion.php | 8 ++-- src/Core/DiscussionState.php | 4 +- src/Core/Group.php | 2 +- src/Core/Notification.php | 8 ++-- src/Core/Notification/BlueprintInterface.php | 2 +- src/Core/Notification/NotificationMailer.php | 2 +- .../NotificationServiceProvider.php | 2 +- src/Core/Notification/NotificationSyncer.php | 2 +- src/Core/Post.php | 6 +-- src/Core/Post/CommentPost.php | 2 +- src/Core/Post/Floodgate.php | 2 +- src/Core/Repository/DiscussionRepository.php | 2 +- src/Core/Repository/GroupRepository.php | 2 +- .../Repository/NotificationRepository.php | 2 +- src/Core/Repository/PostRepository.php | 10 ++--- src/Core/Search/AbstractSearch.php | 2 +- .../Search/Discussion/Gambit/AuthorGambit.php | 6 +-- src/Core/Search/SearchCriteria.php | 2 +- src/Core/Search/SearchServiceProvider.php | 8 ++-- src/Core/Support/DispatchEventsTrait.php | 2 +- src/Database/ScopeVisibilityTrait.php | 2 +- src/Event/AvatarWillBeDeleted.php | 2 +- src/Event/AvatarWillBeSaved.php | 2 +- src/Event/CheckUserPassword.php | 2 +- src/Event/ConfigureUserPreferences.php | 2 +- src/Event/ConfigureUserSearch.php | 4 +- src/Event/DiscussionWasDeleted.php | 2 +- src/Event/DiscussionWasHidden.php | 2 +- src/Event/DiscussionWasRenamed.php | 2 +- src/Event/DiscussionWasRestored.php | 2 +- src/Event/DiscussionWasStarted.php | 2 +- src/Event/DiscussionWillBeDeleted.php | 2 +- src/Event/DiscussionWillBeSaved.php | 2 +- src/Event/GetPermission.php | 2 +- src/Event/GroupWasCreated.php | 2 +- src/Event/GroupWasDeleted.php | 2 +- src/Event/GroupWasRenamed.php | 2 +- src/Event/GroupWillBeDeleted.php | 2 +- src/Event/GroupWillBeSaved.php | 2 +- src/Event/NotificationWillBeSent.php | 2 +- src/Event/PostWasDeleted.php | 2 +- src/Event/PostWasHidden.php | 2 +- src/Event/PostWasPosted.php | 2 +- src/Event/PostWasRestored.php | 2 +- src/Event/PostWasRevised.php | 2 +- src/Event/PostWillBeDeleted.php | 2 +- src/Event/PostWillBeSaved.php | 2 +- src/Event/PrepareApiAttributes.php | 2 +- src/Event/PrepareApiData.php | 2 +- src/Event/PrepareUserGroups.php | 2 +- src/Event/ScopeHiddenDiscussionVisibility.php | 2 +- src/Event/ScopeModelVisibility.php | 2 +- src/Event/ScopePostVisibility.php | 2 +- .../ScopePrivateDiscussionVisibility.php | 2 +- src/Event/ScopePrivatePostVisibility.php | 2 +- src/Event/UserEmailWasChanged.php | 37 ---------------- src/Event/UserPasswordWasChanged.php | 37 ---------------- src/Forum/AuthenticationResponseFactory.php | 4 +- .../Controller/AuthorizedWebAppController.php | 2 +- .../Controller/ConfirmEmailController.php | 2 +- src/Forum/Controller/DiscussionController.php | 2 +- src/Forum/Controller/IndexController.php | 2 +- src/Forum/Controller/LogInController.php | 10 ++--- src/Forum/Controller/LogOutController.php | 4 +- .../Controller/ResetPasswordController.php | 6 +-- .../Controller/SavePasswordController.php | 6 +-- src/Http/AbstractServer.php | 6 +-- src/Http/AccessToken.php | 4 +- .../Middleware/AuthenticateWithHeader.php | 2 +- .../Middleware/AuthenticateWithSession.php | 4 +- src/Install/Console/InstallCommand.php | 2 +- src/{Core/Access => User}/AbstractPolicy.php | 2 +- src/{Core => User}/AuthToken.php | 6 +-- .../Validator => User}/AvatarValidator.php | 4 +- .../EmailConfirmationMailer.php | 21 ++++----- src/{Core => User}/EmailToken.php | 4 +- .../Event/Activated.php} | 6 +-- src/User/Event/AvatarChanged.php | 37 ++++++++++++++++ .../Event/BioChanged.php} | 6 +-- .../Event/Deleted.php} | 6 +-- .../Event/Deleting.php} | 6 +-- .../Event/EmailChangeRequested.php} | 6 +-- .../Event/EmailChanged.php} | 6 +-- .../Event/GroupsChanged.php} | 6 +-- .../Event/LoggedIn.php} | 6 +-- .../Event/LoggedOut.php} | 6 +-- .../Event/PasswordChanged.php} | 6 +-- .../Event/Registered.php} | 6 +-- src/User/Event/Renamed.php | 37 ++++++++++++++++ .../Event/Saving.php} | 6 +-- .../InvalidConfirmationTokenException.php | 2 +- .../Exception/PermissionDeniedException.php | 2 +- src/{Core/Access => User}/Gate.php | 2 +- src/{Core => User}/Guest.php | 4 +- src/{Core => User}/PasswordToken.php | 2 +- .../Search}/Gambit/EmailGambit.php | 10 ++--- .../Search}/Gambit/FulltextGambit.php | 6 +-- .../Search}/Gambit/GroupGambit.php | 4 +- .../User => User/Search}/UserSearch.php | 2 +- .../User => User/Search}/UserSearcher.php | 7 +-- src/{Core => User}/User.php | 43 ++++++++++--------- .../Listener => User}/UserMetadataUpdater.php | 4 +- src/{Core/Access => User}/UserPolicy.php | 4 +- .../Repository => User}/UserRepository.php | 3 +- .../Validator => User}/UserValidator.php | 4 +- ...dConfirmationTokenExceptionHandlerTest.php | 2 +- .../PermissionDeniedExceptionHandlerTest.php | 2 +- 163 files changed, 405 insertions(+), 394 deletions(-) delete mode 100644 src/Event/UserEmailWasChanged.php delete mode 100644 src/Event/UserPasswordWasChanged.php rename src/{Core/Access => User}/AbstractPolicy.php (98%) rename src/{Core => User}/AuthToken.php (92%) rename src/{Core/Validator => User}/AvatarValidator.php (86%) rename src/{Core/Listener => User}/EmailConfirmationMailer.php (82%) rename src/{Core => User}/EmailToken.php (95%) rename src/{Event/UserWasDeleted.php => User/Event/Activated.php} (88%) create mode 100644 src/User/Event/AvatarChanged.php rename src/{Event/UserWasActivated.php => User/Event/BioChanged.php} (88%) rename src/{Event/UserWasRenamed.php => User/Event/Deleted.php} (88%) rename src/{Event/UserWillBeDeleted.php => User/Event/Deleting.php} (92%) rename src/{Event/UserEmailChangeWasRequested.php => User/Event/EmailChangeRequested.php} (89%) rename src/{Event/UserBioWasChanged.php => User/Event/EmailChanged.php} (88%) rename src/{Event/UserGroupsWereChanged.php => User/Event/GroupsChanged.php} (91%) rename src/{Event/UserLoggedIn.php => User/Event/LoggedIn.php} (86%) rename src/{Event/UserLoggedOut.php => User/Event/LoggedOut.php} (83%) rename src/{Event/UserAvatarWasChanged.php => User/Event/PasswordChanged.php} (88%) rename src/{Event/UserWasRegistered.php => User/Event/Registered.php} (88%) create mode 100644 src/User/Event/Renamed.php rename src/{Event/UserWillBeSaved.php => User/Event/Saving.php} (93%) rename src/{Core => User}/Exception/InvalidConfirmationTokenException.php (90%) rename src/{Core => User}/Exception/PermissionDeniedException.php (93%) rename src/{Core/Access => User}/Gate.php (99%) rename src/{Core => User}/Guest.php (94%) rename src/{Core => User}/PasswordToken.php (98%) rename src/{Core/Search/User => User/Search}/Gambit/EmailGambit.php (85%) rename src/{Core/Search/User => User/Search}/Gambit/FulltextGambit.php (87%) rename src/{Core/Search/User => User/Search}/Gambit/GroupGambit.php (95%) rename src/{Core/Search/User => User/Search}/UserSearch.php (89%) rename src/{Core/Search/User => User/Search}/UserSearcher.php (93%) rename src/{Core => User}/User.php (94%) rename src/{Core/Listener => User}/UserMetadataUpdater.php (97%) rename src/{Core/Access => User}/UserPolicy.php (94%) rename src/{Core/Repository => User}/UserRepository.php (98%) rename src/{Core/Validator => User}/UserValidator.php (95%) diff --git a/src/Api/Client.php b/src/Api/Client.php index b99be47e6..774f0dadc 100644 --- a/src/Api/Client.php +++ b/src/Api/Client.php @@ -12,9 +12,9 @@ namespace Flarum\Api; use Exception; -use Flarum\Core\User; use Flarum\Foundation\Application; use Flarum\Http\Controller\ControllerInterface; +use Flarum\User\User; use InvalidArgumentException; use Zend\Diactoros\ServerRequestFactory; diff --git a/src/Api/Controller/ForgotPasswordController.php b/src/Api/Controller/ForgotPasswordController.php index 72c7ee759..5516c6d47 100644 --- a/src/Api/Controller/ForgotPasswordController.php +++ b/src/Api/Controller/ForgotPasswordController.php @@ -12,7 +12,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Command\RequestPasswordReset; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\UserRepository; use Flarum\Http\Controller\ControllerInterface; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; @@ -21,7 +21,7 @@ use Zend\Diactoros\Response\EmptyResponse; class ForgotPasswordController implements ControllerInterface { /** - * @var \Flarum\Core\Repository\UserRepository + * @var \Flarum\User\UserRepository */ protected $users; @@ -31,7 +31,7 @@ class ForgotPasswordController implements ControllerInterface protected $bus; /** - * @param \Flarum\Core\Repository\UserRepository $users + * @param \Flarum\User\UserRepository $users * @param Dispatcher $bus */ public function __construct(UserRepository $users, Dispatcher $bus) diff --git a/src/Api/Controller/ListNotificationsController.php b/src/Api/Controller/ListNotificationsController.php index dd7303efa..c1681d645 100644 --- a/src/Api/Controller/ListNotificationsController.php +++ b/src/Api/Controller/ListNotificationsController.php @@ -12,7 +12,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Discussion; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Repository\NotificationRepository; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/ListUsersController.php b/src/Api/Controller/ListUsersController.php index eb42a97db..7d1f6526f 100644 --- a/src/Api/Controller/ListUsersController.php +++ b/src/Api/Controller/ListUsersController.php @@ -12,9 +12,9 @@ namespace Flarum\Api\Controller; use Flarum\Api\UrlGenerator; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Search\SearchCriteria; -use Flarum\Core\Search\User\UserSearcher; +use Flarum\Core\User\Search\UserSearcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/SendConfirmationEmailController.php b/src/Api/Controller/SendConfirmationEmailController.php index 3f870f160..02c22b020 100644 --- a/src/Api/Controller/SendConfirmationEmailController.php +++ b/src/Api/Controller/SendConfirmationEmailController.php @@ -12,8 +12,8 @@ namespace Flarum\Api\Controller; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\EmailToken; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\EmailToken; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\Forum\UrlGenerator; use Flarum\Http\Controller\ControllerInterface; use Flarum\Settings\SettingsRepositoryInterface; diff --git a/src/Api/Controller/ShowDiscussionController.php b/src/Api/Controller/ShowDiscussionController.php index 58417fae4..d3417ff8c 100644 --- a/src/Api/Controller/ShowDiscussionController.php +++ b/src/Api/Controller/ShowDiscussionController.php @@ -14,7 +14,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Discussion; use Flarum\Core\Repository\DiscussionRepository; use Flarum\Core\Repository\PostRepository; -use Flarum\Core\User; +use Flarum\User\User; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/ShowUserController.php b/src/Api/Controller/ShowUserController.php index 2879a3c8b..f61d3a1b6 100644 --- a/src/Api/Controller/ShowUserController.php +++ b/src/Api/Controller/ShowUserController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\UserRepository; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -28,12 +28,12 @@ class ShowUserController extends AbstractShowController public $include = ['groups']; /** - * @var UserRepository + * @var \Flarum\User\UserRepository */ protected $users; /** - * @param UserRepository $users + * @param \Flarum\User\UserRepository $users */ public function __construct(UserRepository $users) { diff --git a/src/Api/Controller/TokenController.php b/src/Api/Controller/TokenController.php index e5f1c445c..376e48747 100644 --- a/src/Api/Controller/TokenController.php +++ b/src/Api/Controller/TokenController.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Exception\PermissionDeniedException; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\Exception\PermissionDeniedException; +use Flarum\User\UserRepository; use Flarum\Http\AccessToken; use Flarum\Http\Controller\ControllerInterface; use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher; @@ -23,7 +23,7 @@ use Zend\Diactoros\Response\JsonResponse; class TokenController implements ControllerInterface { /** - * @var UserRepository + * @var \Flarum\User\UserRepository */ protected $users; diff --git a/src/Api/Controller/UpdateUserController.php b/src/Api/Controller/UpdateUserController.php index 78c009012..818e4d941 100644 --- a/src/Api/Controller/UpdateUserController.php +++ b/src/Api/Controller/UpdateUserController.php @@ -12,7 +12,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Command\EditUser; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/ExceptionHandler/InvalidConfirmationTokenExceptionHandler.php b/src/Api/ExceptionHandler/InvalidConfirmationTokenExceptionHandler.php index 7c2465dce..541b620f7 100644 --- a/src/Api/ExceptionHandler/InvalidConfirmationTokenExceptionHandler.php +++ b/src/Api/ExceptionHandler/InvalidConfirmationTokenExceptionHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Api\ExceptionHandler; use Exception; -use Flarum\Core\Exception\InvalidConfirmationTokenException; +use Flarum\User\Exception\InvalidConfirmationTokenException; use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface; use Tobscure\JsonApi\Exception\Handler\ResponseBag; diff --git a/src/Api/ExceptionHandler/PermissionDeniedExceptionHandler.php b/src/Api/ExceptionHandler/PermissionDeniedExceptionHandler.php index 059c9369d..a4b4f9d53 100644 --- a/src/Api/ExceptionHandler/PermissionDeniedExceptionHandler.php +++ b/src/Api/ExceptionHandler/PermissionDeniedExceptionHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Api\ExceptionHandler; use Exception; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface; use Tobscure\JsonApi\Exception\Handler\ResponseBag; diff --git a/src/Api/Serializer/AbstractSerializer.php b/src/Api/Serializer/AbstractSerializer.php index 3f7b245e2..a11c9e28a 100644 --- a/src/Api/Serializer/AbstractSerializer.php +++ b/src/Api/Serializer/AbstractSerializer.php @@ -13,9 +13,9 @@ namespace Flarum\Api\Serializer; use Closure; use DateTime; -use Flarum\Core\User; use Flarum\Event\GetApiRelationship; use Flarum\Event\PrepareApiAttributes; +use Flarum\User\User; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Events\Dispatcher; use InvalidArgumentException; diff --git a/src/Api/Serializer/BasicUserSerializer.php b/src/Api/Serializer/BasicUserSerializer.php index 1d854c330..91348e471 100644 --- a/src/Api/Serializer/BasicUserSerializer.php +++ b/src/Api/Serializer/BasicUserSerializer.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Serializer; -use Flarum\Core\User; +use Flarum\User\User; use InvalidArgumentException; class BasicUserSerializer extends AbstractSerializer diff --git a/src/Api/Serializer/DiscussionSerializer.php b/src/Api/Serializer/DiscussionSerializer.php index e26f8929b..96704df22 100644 --- a/src/Api/Serializer/DiscussionSerializer.php +++ b/src/Api/Serializer/DiscussionSerializer.php @@ -11,18 +11,18 @@ namespace Flarum\Api\Serializer; -use Flarum\Core\Access\Gate; +use Flarum\User\Gate; use Flarum\Core\Discussion; class DiscussionSerializer extends BasicDiscussionSerializer { /** - * @var Gate + * @var \Flarum\User\Gate */ protected $gate; /** - * @param \Flarum\Core\Access\Gate $gate + * @param \Flarum\User\Gate $gate */ public function __construct(Gate $gate) { diff --git a/src/Api/Serializer/PostSerializer.php b/src/Api/Serializer/PostSerializer.php index bb584dd3e..e385b3533 100644 --- a/src/Api/Serializer/PostSerializer.php +++ b/src/Api/Serializer/PostSerializer.php @@ -11,18 +11,18 @@ namespace Flarum\Api\Serializer; -use Flarum\Core\Access\Gate; +use Flarum\User\Gate; use Flarum\Core\Post\CommentPost; class PostSerializer extends BasicPostSerializer { /** - * @var \Flarum\Core\Access\Gate + * @var \Flarum\User\Gate */ protected $gate; /** - * @param \Flarum\Core\Access\Gate $gate + * @param \Flarum\User\Gate $gate */ public function __construct(Gate $gate) { diff --git a/src/Api/Serializer/UserSerializer.php b/src/Api/Serializer/UserSerializer.php index 7bf6f62b2..b39801843 100644 --- a/src/Api/Serializer/UserSerializer.php +++ b/src/Api/Serializer/UserSerializer.php @@ -11,12 +11,12 @@ namespace Flarum\Api\Serializer; -use Flarum\Core\Access\Gate; +use Flarum\User\Gate; class UserSerializer extends BasicUserSerializer { /** - * @var Gate + * @var \Flarum\User\Gate */ protected $gate; diff --git a/src/Core/Access/AssertPermissionTrait.php b/src/Core/Access/AssertPermissionTrait.php index cb2d9aff3..647ca9fac 100644 --- a/src/Core/Access/AssertPermissionTrait.php +++ b/src/Core/Access/AssertPermissionTrait.php @@ -11,8 +11,8 @@ namespace Flarum\Core\Access; -use Flarum\Core\Exception\PermissionDeniedException; -use Flarum\Core\User; +use Flarum\User\Exception\PermissionDeniedException; +use Flarum\User\User; trait AssertPermissionTrait { @@ -40,7 +40,7 @@ trait AssertPermissionTrait /** * @param User $actor - * @throws PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ protected function assertGuest(User $actor) { diff --git a/src/Core/Access/DiscussionPolicy.php b/src/Core/Access/DiscussionPolicy.php index 3abefa824..50f00a387 100644 --- a/src/Core/Access/DiscussionPolicy.php +++ b/src/Core/Access/DiscussionPolicy.php @@ -13,10 +13,12 @@ namespace Flarum\Core\Access; use Carbon\Carbon; use Flarum\Core\Discussion; -use Flarum\Core\User; use Flarum\Event\ScopeHiddenDiscussionVisibility; use Flarum\Event\ScopePrivateDiscussionVisibility; use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\User\AbstractPolicy; +use Flarum\User\Gate; +use Flarum\User\User; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Eloquent\Builder; diff --git a/src/Core/Access/GroupPolicy.php b/src/Core/Access/GroupPolicy.php index 097077335..ff9861a07 100644 --- a/src/Core/Access/GroupPolicy.php +++ b/src/Core/Access/GroupPolicy.php @@ -12,7 +12,8 @@ namespace Flarum\Core\Access; use Flarum\Core\Group; -use Flarum\Core\User; +use Flarum\User\AbstractPolicy; +use Flarum\User\User; class GroupPolicy extends AbstractPolicy { diff --git a/src/Core/Access/PostPolicy.php b/src/Core/Access/PostPolicy.php index afc0addb5..9e6f5829b 100644 --- a/src/Core/Access/PostPolicy.php +++ b/src/Core/Access/PostPolicy.php @@ -13,10 +13,11 @@ namespace Flarum\Core\Access; use Carbon\Carbon; use Flarum\Core\Post; -use Flarum\Core\User; use Flarum\Event\ScopePostVisibility; use Flarum\Event\ScopePrivatePostVisibility; use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\User\AbstractPolicy; +use Flarum\User\User; use Illuminate\Contracts\Events\Dispatcher; class PostPolicy extends AbstractPolicy diff --git a/src/Core/Command/ConfirmEmailHandler.php b/src/Core/Command/ConfirmEmailHandler.php index 5ee4d5190..f8415792d 100644 --- a/src/Core/Command/ConfirmEmailHandler.php +++ b/src/Core/Command/ConfirmEmailHandler.php @@ -11,8 +11,8 @@ namespace Flarum\Core\Command; -use Flarum\Core\EmailToken; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\EmailToken; +use Flarum\User\UserRepository; use Flarum\Core\Support\DispatchEventsTrait; use Illuminate\Contracts\Events\Dispatcher; @@ -21,12 +21,12 @@ class ConfirmEmailHandler use DispatchEventsTrait; /** - * @var UserRepository + * @var \Flarum\User\UserRepository */ protected $users; /** - * @param UserRepository $users + * @param \Flarum\User\UserRepository $users */ public function __construct(Dispatcher $events, UserRepository $users) { @@ -36,7 +36,7 @@ class ConfirmEmailHandler /** * @param ConfirmEmail $command - * @return \Flarum\Core\User + * @return \Flarum\User\User */ public function handle(ConfirmEmail $command) { diff --git a/src/Core/Command/CreateGroup.php b/src/Core/Command/CreateGroup.php index 9ed912ce7..e67eefea6 100644 --- a/src/Core/Command/CreateGroup.php +++ b/src/Core/Command/CreateGroup.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class CreateGroup { diff --git a/src/Core/Command/CreateGroupHandler.php b/src/Core/Command/CreateGroupHandler.php index fce5fd598..54d8c3d8c 100644 --- a/src/Core/Command/CreateGroupHandler.php +++ b/src/Core/Command/CreateGroupHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Group; use Flarum\Core\Support\DispatchEventsTrait; use Flarum\Core\Validator\GroupValidator; @@ -42,7 +42,7 @@ class CreateGroupHandler /** * @param CreateGroup $command * @return Group - * @throws PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(CreateGroup $command) { diff --git a/src/Core/Command/DeleteAvatar.php b/src/Core/Command/DeleteAvatar.php index 9503d00e5..a8f757c14 100644 --- a/src/Core/Command/DeleteAvatar.php +++ b/src/Core/Command/DeleteAvatar.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class DeleteAvatar { diff --git a/src/Core/Command/DeleteAvatarHandler.php b/src/Core/Command/DeleteAvatarHandler.php index 8efd972c7..aabbe4ddc 100644 --- a/src/Core/Command/DeleteAvatarHandler.php +++ b/src/Core/Command/DeleteAvatarHandler.php @@ -12,8 +12,8 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Exception\PermissionDeniedException; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\Exception\PermissionDeniedException; +use Flarum\User\UserRepository; use Flarum\Core\Support\DispatchEventsTrait; use Flarum\Event\AvatarWillBeDeleted; use Illuminate\Contracts\Events\Dispatcher; @@ -48,8 +48,8 @@ class DeleteAvatarHandler /** * @param DeleteAvatar $command - * @return \Flarum\Core\User - * @throws PermissionDeniedException + * @return \Flarum\User\User + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(DeleteAvatar $command) { diff --git a/src/Core/Command/DeleteDiscussion.php b/src/Core/Command/DeleteDiscussion.php index 550ae5e17..3c4d1219b 100644 --- a/src/Core/Command/DeleteDiscussion.php +++ b/src/Core/Command/DeleteDiscussion.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class DeleteDiscussion { diff --git a/src/Core/Command/DeleteDiscussionHandler.php b/src/Core/Command/DeleteDiscussionHandler.php index 5f383f60d..a02e4609b 100644 --- a/src/Core/Command/DeleteDiscussionHandler.php +++ b/src/Core/Command/DeleteDiscussionHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Repository\DiscussionRepository; use Flarum\Core\Support\DispatchEventsTrait; use Flarum\Event\DiscussionWillBeDeleted; diff --git a/src/Core/Command/DeleteGroup.php b/src/Core/Command/DeleteGroup.php index 2f9c6a574..b57bc7c33 100644 --- a/src/Core/Command/DeleteGroup.php +++ b/src/Core/Command/DeleteGroup.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class DeleteGroup { diff --git a/src/Core/Command/DeleteGroupHandler.php b/src/Core/Command/DeleteGroupHandler.php index 7592eb97b..ed849a5be 100644 --- a/src/Core/Command/DeleteGroupHandler.php +++ b/src/Core/Command/DeleteGroupHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Repository\GroupRepository; use Flarum\Core\Support\DispatchEventsTrait; use Flarum\Event\GroupWillBeDeleted; diff --git a/src/Core/Command/DeletePost.php b/src/Core/Command/DeletePost.php index 3e363e245..e2c2e897b 100644 --- a/src/Core/Command/DeletePost.php +++ b/src/Core/Command/DeletePost.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class DeletePost { diff --git a/src/Core/Command/DeletePostHandler.php b/src/Core/Command/DeletePostHandler.php index a5010cf6d..e7697e622 100644 --- a/src/Core/Command/DeletePostHandler.php +++ b/src/Core/Command/DeletePostHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Repository\PostRepository; use Flarum\Core\Support\DispatchEventsTrait; use Flarum\Event\PostWillBeDeleted; @@ -41,7 +41,7 @@ class DeletePostHandler /** * @param DeletePost $command * @return \Flarum\Core\Post - * @throws PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(DeletePost $command) { diff --git a/src/Core/Command/DeleteUser.php b/src/Core/Command/DeleteUser.php index 16cd44cf9..2aa0f3edb 100644 --- a/src/Core/Command/DeleteUser.php +++ b/src/Core/Command/DeleteUser.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class DeleteUser { diff --git a/src/Core/Command/DeleteUserHandler.php b/src/Core/Command/DeleteUserHandler.php index a4058465d..e4503a53d 100644 --- a/src/Core/Command/DeleteUserHandler.php +++ b/src/Core/Command/DeleteUserHandler.php @@ -12,10 +12,10 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Exception\PermissionDeniedException; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\Exception\PermissionDeniedException; +use Flarum\User\UserRepository; use Flarum\Core\Support\DispatchEventsTrait; -use Flarum\Event\UserWillBeDeleted; +use Flarum\User\Event\Deleting; use Illuminate\Contracts\Events\Dispatcher; class DeleteUserHandler @@ -40,7 +40,7 @@ class DeleteUserHandler /** * @param DeleteUser $command - * @return \Flarum\Core\User + * @return \Flarum\User\User * @throws PermissionDeniedException */ public function handle(DeleteUser $command) @@ -51,7 +51,7 @@ class DeleteUserHandler $this->assertCan($actor, 'delete', $user); $this->events->fire( - new UserWillBeDeleted($user, $actor, $command->data) + new Deleting($user, $actor, $command->data) ); $user->delete(); diff --git a/src/Core/Command/EditDiscussion.php b/src/Core/Command/EditDiscussion.php index 23cb5e707..4ae77a276 100644 --- a/src/Core/Command/EditDiscussion.php +++ b/src/Core/Command/EditDiscussion.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class EditDiscussion { @@ -25,7 +25,7 @@ class EditDiscussion /** * The user performing the action. * - * @var \Flarum\Core\User + * @var \Flarum\User\User */ public $actor; @@ -38,7 +38,7 @@ class EditDiscussion /** * @param int $discussionId The ID of the discussion to edit. - * @param \Flarum\Core\User $actor The user performing the action. + * @param \Flarum\User\User $actor The user performing the action. * @param array $data The attributes to update on the discussion. */ public function __construct($discussionId, User $actor, array $data) diff --git a/src/Core/Command/EditDiscussionHandler.php b/src/Core/Command/EditDiscussionHandler.php index 151f66d4f..b8866bf1f 100644 --- a/src/Core/Command/EditDiscussionHandler.php +++ b/src/Core/Command/EditDiscussionHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Repository\DiscussionRepository; use Flarum\Core\Support\DispatchEventsTrait; use Flarum\Core\Validator\DiscussionValidator; @@ -49,7 +49,7 @@ class EditDiscussionHandler /** * @param EditDiscussion $command * @return \Flarum\Core\Discussion - * @throws PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(EditDiscussion $command) { diff --git a/src/Core/Command/EditGroup.php b/src/Core/Command/EditGroup.php index 233843a8c..f05dc26cd 100644 --- a/src/Core/Command/EditGroup.php +++ b/src/Core/Command/EditGroup.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class EditGroup { diff --git a/src/Core/Command/EditGroupHandler.php b/src/Core/Command/EditGroupHandler.php index 0f2ad59af..6d1d8ad4f 100644 --- a/src/Core/Command/EditGroupHandler.php +++ b/src/Core/Command/EditGroupHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Group; use Flarum\Core\Repository\GroupRepository; use Flarum\Core\Support\DispatchEventsTrait; diff --git a/src/Core/Command/EditPost.php b/src/Core/Command/EditPost.php index 6a576a130..25390c890 100644 --- a/src/Core/Command/EditPost.php +++ b/src/Core/Command/EditPost.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class EditPost { diff --git a/src/Core/Command/EditPostHandler.php b/src/Core/Command/EditPostHandler.php index f49e4443a..32e607b5b 100644 --- a/src/Core/Command/EditPostHandler.php +++ b/src/Core/Command/EditPostHandler.php @@ -49,7 +49,7 @@ class EditPostHandler /** * @param EditPost $command * @return \Flarum\Core\Post - * @throws \Flarum\Core\Exception\PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(EditPost $command) { diff --git a/src/Core/Command/EditUser.php b/src/Core/Command/EditUser.php index 200fad5cb..fa758483f 100644 --- a/src/Core/Command/EditUser.php +++ b/src/Core/Command/EditUser.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class EditUser { diff --git a/src/Core/Command/EditUserHandler.php b/src/Core/Command/EditUserHandler.php index d42acdfc9..4ba4a4bff 100644 --- a/src/Core/Command/EditUserHandler.php +++ b/src/Core/Command/EditUserHandler.php @@ -12,12 +12,12 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\UserRepository; use Flarum\Core\Support\DispatchEventsTrait; -use Flarum\Core\User; -use Flarum\Core\Validator\UserValidator; -use Flarum\Event\UserGroupsWereChanged; -use Flarum\Event\UserWillBeSaved; +use Flarum\User\User; +use Flarum\User\UserValidator; +use Flarum\User\Event\GroupsChanged; +use Flarum\User\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class EditUserHandler @@ -26,7 +26,7 @@ class EditUserHandler use AssertPermissionTrait; /** - * @var UserRepository + * @var \Flarum\User\UserRepository */ protected $users; @@ -37,7 +37,7 @@ class EditUserHandler /** * @param Dispatcher $events - * @param UserRepository $users + * @param \Flarum\User\UserRepository $users * @param UserValidator $validator */ public function __construct(Dispatcher $events, UserRepository $users, UserValidator $validator) @@ -50,7 +50,7 @@ class EditUserHandler /** * @param EditUser $command * @return User - * @throws \Flarum\Core\Exception\PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(EditUser $command) { @@ -127,7 +127,7 @@ class EditUserHandler } $user->raise( - new UserGroupsWereChanged($user, $user->groups()->get()->all()) + new GroupsChanged($user, $user->groups()->get()->all()) ); $user->afterSave(function (User $user) use ($newGroupIds) { @@ -136,7 +136,7 @@ class EditUserHandler } $this->events->fire( - new UserWillBeSaved($user, $actor, $data) + new Saving($user, $actor, $data) ); $this->validator->setUser($user); diff --git a/src/Core/Command/PostReply.php b/src/Core/Command/PostReply.php index a9518f00e..4877b3045 100644 --- a/src/Core/Command/PostReply.php +++ b/src/Core/Command/PostReply.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class PostReply { diff --git a/src/Core/Command/PostReplyHandler.php b/src/Core/Command/PostReplyHandler.php index fb84877a9..06837011b 100644 --- a/src/Core/Command/PostReplyHandler.php +++ b/src/Core/Command/PostReplyHandler.php @@ -62,7 +62,7 @@ class PostReplyHandler /** * @param PostReply $command * @return CommentPost - * @throws \Flarum\Core\Exception\PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(PostReply $command) { diff --git a/src/Core/Command/ReadAllNotifications.php b/src/Core/Command/ReadAllNotifications.php index bbf6b2252..d231153ce 100644 --- a/src/Core/Command/ReadAllNotifications.php +++ b/src/Core/Command/ReadAllNotifications.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class ReadAllNotifications { diff --git a/src/Core/Command/ReadAllNotificationsHandler.php b/src/Core/Command/ReadAllNotificationsHandler.php index 56f04f217..023568f9b 100644 --- a/src/Core/Command/ReadAllNotificationsHandler.php +++ b/src/Core/Command/ReadAllNotificationsHandler.php @@ -33,7 +33,7 @@ class ReadAllNotificationsHandler /** * @param ReadAllNotifications $command - * @throws \Flarum\Core\Exception\PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(ReadAllNotifications $command) { diff --git a/src/Core/Command/ReadDiscussion.php b/src/Core/Command/ReadDiscussion.php index 00bb1a1db..4a0c8ebd4 100644 --- a/src/Core/Command/ReadDiscussion.php +++ b/src/Core/Command/ReadDiscussion.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class ReadDiscussion { diff --git a/src/Core/Command/ReadDiscussionHandler.php b/src/Core/Command/ReadDiscussionHandler.php index ed7a2d21b..9630100a1 100644 --- a/src/Core/Command/ReadDiscussionHandler.php +++ b/src/Core/Command/ReadDiscussionHandler.php @@ -40,7 +40,7 @@ class ReadDiscussionHandler /** * @param ReadDiscussion $command * @return \Flarum\Core\DiscussionState - * @throws \Flarum\Core\Exception\PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(ReadDiscussion $command) { diff --git a/src/Core/Command/ReadNotification.php b/src/Core/Command/ReadNotification.php index bbeddee96..f525299b7 100644 --- a/src/Core/Command/ReadNotification.php +++ b/src/Core/Command/ReadNotification.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class ReadNotification { diff --git a/src/Core/Command/ReadNotificationHandler.php b/src/Core/Command/ReadNotificationHandler.php index 7adbf6039..b7da93198 100644 --- a/src/Core/Command/ReadNotificationHandler.php +++ b/src/Core/Command/ReadNotificationHandler.php @@ -21,7 +21,7 @@ class ReadNotificationHandler /** * @param ReadNotification $command * @return \Flarum\Core\Notification - * @throws \Flarum\Core\Exception\PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(ReadNotification $command) { diff --git a/src/Core/Command/RegisterUser.php b/src/Core/Command/RegisterUser.php index 57230324f..1d9a32b70 100644 --- a/src/Core/Command/RegisterUser.php +++ b/src/Core/Command/RegisterUser.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class RegisterUser { diff --git a/src/Core/Command/RegisterUserHandler.php b/src/Core/Command/RegisterUserHandler.php index c7daf38fa..2e3a1b158 100644 --- a/src/Core/Command/RegisterUserHandler.php +++ b/src/Core/Command/RegisterUserHandler.php @@ -13,12 +13,12 @@ namespace Flarum\Core\Command; use Exception; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\AuthToken; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\AuthToken; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Support\DispatchEventsTrait; -use Flarum\Core\User; -use Flarum\Core\Validator\UserValidator; -use Flarum\Event\UserWillBeSaved; +use Flarum\User\User; +use Flarum\User\UserValidator; +use Flarum\User\Event\Saving; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; @@ -83,7 +83,7 @@ class RegisterUserHandler * @param RegisterUser $command * @throws PermissionDeniedException if signup is closed and the actor is * not an administrator. - * @throws \Flarum\Core\Exception\InvalidConfirmationTokenException if an + * @throws \Flarum\User\Exception\InvalidConfirmationTokenException if an * email confirmation token is provided but is invalid. * @return User */ @@ -131,7 +131,7 @@ class RegisterUserHandler } $this->events->fire( - new UserWillBeSaved($user, $actor, $data) + new Saving($user, $actor, $data) ); $this->validator->assertValid(array_merge($user->getAttributes(), compact('password'))); diff --git a/src/Core/Command/RequestPasswordResetHandler.php b/src/Core/Command/RequestPasswordResetHandler.php index fb484fbda..4647bc004 100644 --- a/src/Core/Command/RequestPasswordResetHandler.php +++ b/src/Core/Command/RequestPasswordResetHandler.php @@ -12,8 +12,8 @@ namespace Flarum\Core\Command; use Flarum\Core; -use Flarum\Core\PasswordToken; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\PasswordToken; +use Flarum\User\UserRepository; use Flarum\Forum\UrlGenerator; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Mail\Mailer; @@ -56,7 +56,7 @@ class RequestPasswordResetHandler protected $validatorFactory; /** - * @param UserRepository $users + * @param \Flarum\User\UserRepository $users * @param SettingsRepositoryInterface $settings * @param Mailer $mailer * @param UrlGenerator $url @@ -81,7 +81,7 @@ class RequestPasswordResetHandler /** * @param RequestPasswordReset $command - * @return \Flarum\Core\User + * @return \Flarum\User\User * @throws ModelNotFoundException */ public function handle(RequestPasswordReset $command) diff --git a/src/Core/Command/StartDiscussion.php b/src/Core/Command/StartDiscussion.php index 1840f9c0c..9bc0cab10 100644 --- a/src/Core/Command/StartDiscussion.php +++ b/src/Core/Command/StartDiscussion.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; class StartDiscussion { diff --git a/src/Core/Command/UploadAvatar.php b/src/Core/Command/UploadAvatar.php index 988ecc26d..ac34220e5 100644 --- a/src/Core/Command/UploadAvatar.php +++ b/src/Core/Command/UploadAvatar.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\User; +use Flarum\User\User; use Psr\Http\Message\UploadedFileInterface; class UploadAvatar diff --git a/src/Core/Command/UploadAvatarHandler.php b/src/Core/Command/UploadAvatarHandler.php index de451a074..61fa05601 100644 --- a/src/Core/Command/UploadAvatarHandler.php +++ b/src/Core/Command/UploadAvatarHandler.php @@ -13,9 +13,9 @@ namespace Flarum\Core\Command; use Exception; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\UserRepository; use Flarum\Core\Support\DispatchEventsTrait; -use Flarum\Core\Validator\AvatarValidator; +use Flarum\User\AvatarValidator; use Flarum\Event\AvatarWillBeSaved; use Flarum\Foundation\Application; use Illuminate\Contracts\Events\Dispatcher; @@ -33,7 +33,7 @@ class UploadAvatarHandler use AssertPermissionTrait; /** - * @var UserRepository + * @var \Flarum\User\UserRepository */ protected $users; @@ -48,7 +48,7 @@ class UploadAvatarHandler protected $app; /** - * @var AvatarValidator + * @var \Flarum\User\AvatarValidator */ protected $validator; @@ -57,7 +57,7 @@ class UploadAvatarHandler * @param UserRepository $users * @param FilesystemInterface $uploadDir * @param Application $app - * @param AvatarValidator $validator + * @param \Flarum\User\AvatarValidator $validator */ public function __construct(Dispatcher $events, UserRepository $users, FilesystemInterface $uploadDir, Application $app, AvatarValidator $validator) { @@ -70,8 +70,8 @@ class UploadAvatarHandler /** * @param UploadAvatar $command - * @return \Flarum\Core\User - * @throws \Flarum\Core\Exception\PermissionDeniedException + * @return \Flarum\User\User + * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(UploadAvatar $command) { diff --git a/src/Core/CoreServiceProvider.php b/src/Core/CoreServiceProvider.php index 551cdcfda..d697aba1c 100644 --- a/src/Core/CoreServiceProvider.php +++ b/src/Core/CoreServiceProvider.php @@ -11,12 +11,13 @@ namespace Flarum\Core; -use Flarum\Core\Access\Gate; use Flarum\Core\Post\CommentPost; use Flarum\Event\ConfigurePostTypes; use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\GetPermission; use Flarum\Foundation\AbstractServiceProvider; +use Flarum\User\Gate; +use Flarum\User\User; use Illuminate\Contracts\Container\Container; use RuntimeException; @@ -34,7 +35,7 @@ class CoreServiceProvider extends AbstractServiceProvider }); $this->app->alias('flarum.gate', 'Illuminate\Contracts\Auth\Access\Gate'); - $this->app->alias('flarum.gate', 'Flarum\Core\Access\Gate'); + $this->app->alias('flarum.gate', 'Flarum\User\Gate'); $this->registerAvatarsFilesystem(); @@ -106,15 +107,15 @@ class CoreServiceProvider extends AbstractServiceProvider $events->subscribe('Flarum\Core\Listener\SelfDemotionGuard'); $events->subscribe('Flarum\Core\Listener\DiscussionMetadataUpdater'); - $events->subscribe('Flarum\Core\Listener\UserMetadataUpdater'); + $events->subscribe('Flarum\User\UserMetadataUpdater'); $events->subscribe('Flarum\Core\Listener\ExtensionValidator'); - $events->subscribe('Flarum\Core\Listener\EmailConfirmationMailer'); + $events->subscribe('Flarum\User\EmailConfirmationMailer'); $events->subscribe('Flarum\Core\Listener\DiscussionRenamedNotifier'); $events->subscribe('Flarum\Core\Access\DiscussionPolicy'); $events->subscribe('Flarum\Core\Access\GroupPolicy'); $events->subscribe('Flarum\Core\Access\PostPolicy'); - $events->subscribe('Flarum\Core\Access\UserPolicy'); + $events->subscribe('Flarum\User\UserPolicy'); $events->listen(ConfigureUserPreferences::class, [$this, 'configureUserPreferences']); } diff --git a/src/Core/Discussion.php b/src/Core/Discussion.php index 2d510ede5..39c97bf6d 100644 --- a/src/Core/Discussion.php +++ b/src/Core/Discussion.php @@ -22,6 +22,8 @@ use Flarum\Event\DiscussionWasRestored; use Flarum\Event\DiscussionWasStarted; use Flarum\Event\PostWasDeleted; use Flarum\Event\ScopePostVisibility; +use Flarum\User\Guest; +use Flarum\User\User; use Flarum\Util\Str; /** @@ -363,7 +365,7 @@ class Discussion extends AbstractModel */ public function startUser() { - return $this->belongsTo('Flarum\Core\User', 'start_user_id'); + return $this->belongsTo('Flarum\User\User', 'start_user_id'); } /** @@ -383,7 +385,7 @@ class Discussion extends AbstractModel */ public function lastUser() { - return $this->belongsTo('Flarum\Core\User', 'last_user_id'); + return $this->belongsTo('Flarum\User\User', 'last_user_id'); } /** @@ -393,7 +395,7 @@ class Discussion extends AbstractModel */ public function readers() { - return $this->belongsToMany('Flarum\Core\User', 'users_discussions'); + return $this->belongsToMany('Flarum\User\User', 'users_discussions'); } /** diff --git a/src/Core/DiscussionState.php b/src/Core/DiscussionState.php index 2208a8ff4..e32e120b4 100644 --- a/src/Core/DiscussionState.php +++ b/src/Core/DiscussionState.php @@ -28,7 +28,7 @@ use Illuminate\Database\Eloquent\Builder; * @property \Carbon\Carbon|null $read_time * @property int|null $read_number * @property Discussion $discussion - * @property \Flarum\Core\User $user + * @property \Flarum\User\User $user */ class DiscussionState extends AbstractModel { @@ -80,7 +80,7 @@ class DiscussionState extends AbstractModel */ public function user() { - return $this->belongsTo('Flarum\Core\User', 'user_id'); + return $this->belongsTo('Flarum\User\User', 'user_id'); } /** diff --git a/src/Core/Group.php b/src/Core/Group.php index db081ffe5..eb05daa5c 100755 --- a/src/Core/Group.php +++ b/src/Core/Group.php @@ -120,7 +120,7 @@ class Group extends AbstractModel */ public function users() { - return $this->belongsToMany('Flarum\Core\User', 'users_groups'); + return $this->belongsToMany('Flarum\User\User', 'users_groups'); } /** diff --git a/src/Core/Notification.php b/src/Core/Notification.php index 78b2dbf98..0d429998b 100644 --- a/src/Core/Notification.php +++ b/src/Core/Notification.php @@ -36,8 +36,8 @@ use Flarum\Database\AbstractModel; * @property \Carbon\Carbon $time * @property bool $is_read * @property bool $is_deleted - * @property \Flarum\Core\User|null $user - * @property \Flarum\Core\User|null $sender + * @property \Flarum\User\User|null $user + * @property \Flarum\User\User|null $sender * @property \Flarum\Database\AbstractModel|null $subject */ class Notification extends AbstractModel @@ -113,7 +113,7 @@ class Notification extends AbstractModel */ public function user() { - return $this->belongsTo('Flarum\Core\User', 'user_id'); + return $this->belongsTo('Flarum\User\User', 'user_id'); } /** @@ -123,7 +123,7 @@ class Notification extends AbstractModel */ public function sender() { - return $this->belongsTo('Flarum\Core\User', 'sender_id'); + return $this->belongsTo('Flarum\User\User', 'sender_id'); } /** diff --git a/src/Core/Notification/BlueprintInterface.php b/src/Core/Notification/BlueprintInterface.php index 93f33f8c4..67bcc31ff 100644 --- a/src/Core/Notification/BlueprintInterface.php +++ b/src/Core/Notification/BlueprintInterface.php @@ -21,7 +21,7 @@ interface BlueprintInterface /** * Get the user that sent the notification. * - * @return \Flarum\Core\User|null + * @return \Flarum\User\User|null */ public function getSender(); diff --git a/src/Core/Notification/NotificationMailer.php b/src/Core/Notification/NotificationMailer.php index 691e3e7d6..327f0252e 100644 --- a/src/Core/Notification/NotificationMailer.php +++ b/src/Core/Notification/NotificationMailer.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Notification; -use Flarum\Core\User; +use Flarum\User\User; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Mail\Message; diff --git a/src/Core/Notification/NotificationServiceProvider.php b/src/Core/Notification/NotificationServiceProvider.php index 54a9b0dd1..d8cf09474 100644 --- a/src/Core/Notification/NotificationServiceProvider.php +++ b/src/Core/Notification/NotificationServiceProvider.php @@ -12,9 +12,9 @@ namespace Flarum\Core\Notification; use Flarum\Core\Notification; -use Flarum\Core\User; use Flarum\Event\ConfigureNotificationTypes; use Flarum\Foundation\AbstractServiceProvider; +use Flarum\User\User; use ReflectionClass; class NotificationServiceProvider extends AbstractServiceProvider diff --git a/src/Core/Notification/NotificationSyncer.php b/src/Core/Notification/NotificationSyncer.php index 5b56ad9d5..aab276b5b 100644 --- a/src/Core/Notification/NotificationSyncer.php +++ b/src/Core/Notification/NotificationSyncer.php @@ -14,8 +14,8 @@ namespace Flarum\Core\Notification; use Carbon\Carbon; use Flarum\Core\Notification; use Flarum\Core\Repository\NotificationRepository; -use Flarum\Core\User; use Flarum\Event\NotificationWillBeSent; +use Flarum\User\User; /** * The Notification Syncer commits notification blueprints to the database, and diff --git a/src/Core/Post.php b/src/Core/Post.php index 6d4ad5620..f85563965 100755 --- a/src/Core/Post.php +++ b/src/Core/Post.php @@ -139,7 +139,7 @@ class Post extends AbstractModel */ public function user() { - return $this->belongsTo('Flarum\Core\User', 'user_id'); + return $this->belongsTo('Flarum\User\User', 'user_id'); } /** @@ -149,7 +149,7 @@ class Post extends AbstractModel */ public function editUser() { - return $this->belongsTo('Flarum\Core\User', 'edit_user_id'); + return $this->belongsTo('Flarum\User\User', 'edit_user_id'); } /** @@ -159,7 +159,7 @@ class Post extends AbstractModel */ public function hideUser() { - return $this->belongsTo('Flarum\Core\User', 'hide_user_id'); + return $this->belongsTo('Flarum\User\User', 'hide_user_id'); } /** diff --git a/src/Core/Post/CommentPost.php b/src/Core/Post/CommentPost.php index 492088552..a8016cbb2 100755 --- a/src/Core/Post/CommentPost.php +++ b/src/Core/Post/CommentPost.php @@ -12,12 +12,12 @@ namespace Flarum\Core\Post; use Flarum\Core\Post; -use Flarum\Core\User; use Flarum\Event\PostWasHidden; use Flarum\Event\PostWasPosted; use Flarum\Event\PostWasRestored; use Flarum\Event\PostWasRevised; use Flarum\Formatter\Formatter; +use Flarum\User\User; /** * A standard comment in a discussion. diff --git a/src/Core/Post/Floodgate.php b/src/Core/Post/Floodgate.php index ff735cb5a..a62811fb1 100644 --- a/src/Core/Post/Floodgate.php +++ b/src/Core/Post/Floodgate.php @@ -14,7 +14,7 @@ namespace Flarum\Core\Post; use DateTime; use Flarum\Core\Exception\FloodingException; use Flarum\Core\Post; -use Flarum\Core\User; +use Flarum\User\User; class Floodgate { diff --git a/src/Core/Repository/DiscussionRepository.php b/src/Core/Repository/DiscussionRepository.php index f76af650e..add4f2b30 100644 --- a/src/Core/Repository/DiscussionRepository.php +++ b/src/Core/Repository/DiscussionRepository.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Repository; use Flarum\Core\Discussion; -use Flarum\Core\User; +use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Query\Expression; diff --git a/src/Core/Repository/GroupRepository.php b/src/Core/Repository/GroupRepository.php index 658c3739b..f6cfe3d82 100644 --- a/src/Core/Repository/GroupRepository.php +++ b/src/Core/Repository/GroupRepository.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Repository; use Flarum\Core\Group; -use Flarum\Core\User; +use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; class GroupRepository diff --git a/src/Core/Repository/NotificationRepository.php b/src/Core/Repository/NotificationRepository.php index 3d1e5f6a0..1b9fe63fb 100644 --- a/src/Core/Repository/NotificationRepository.php +++ b/src/Core/Repository/NotificationRepository.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Repository; use Flarum\Core\Notification; -use Flarum\Core\User; +use Flarum\User\User; class NotificationRepository { diff --git a/src/Core/Repository/PostRepository.php b/src/Core/Repository/PostRepository.php index 7ce6b0906..df296e358 100644 --- a/src/Core/Repository/PostRepository.php +++ b/src/Core/Repository/PostRepository.php @@ -13,8 +13,8 @@ namespace Flarum\Core\Repository; use Flarum\Core\Discussion; use Flarum\Core\Post; -use Flarum\Core\User; use Flarum\Event\ScopePostVisibility; +use Flarum\User\User; use Illuminate\Database\Eloquent\ModelNotFoundException; class PostRepository @@ -34,7 +34,7 @@ class PostRepository * user, or throw an exception. * * @param int $id - * @param \Flarum\Core\User $actor + * @param \Flarum\User\User $actor * @return \Flarum\Core\Post * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException @@ -55,7 +55,7 @@ class PostRepository * are visible to a certain user, and/or using other criteria. * * @param array $where - * @param \Flarum\Core\User|null $actor + * @param \Flarum\User\User|null $actor * @param array $sort * @param int $count * @param int $start @@ -81,7 +81,7 @@ class PostRepository * certain user. * * @param array $ids - * @param \Flarum\Core\User|null $actor + * @param \Flarum\User\User|null $actor * @return \Illuminate\Database\Eloquent\Collection */ public function findByIds(array $ids, User $actor = null) @@ -122,7 +122,7 @@ class PostRepository * * @param int $discussionId * @param int $number - * @param \Flarum\Core\User|null $actor + * @param \Flarum\User\User|null $actor * @return int */ public function getIndexForNumber($discussionId, $number, User $actor = null) diff --git a/src/Core/Search/AbstractSearch.php b/src/Core/Search/AbstractSearch.php index 581afdf95..c4f54250d 100644 --- a/src/Core/Search/AbstractSearch.php +++ b/src/Core/Search/AbstractSearch.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Search; -use Flarum\Core\User; +use Flarum\User\User; use Illuminate\Database\Query\Builder; /** diff --git a/src/Core/Search/Discussion/Gambit/AuthorGambit.php b/src/Core/Search/Discussion/Gambit/AuthorGambit.php index 914fb6684..d1336efec 100644 --- a/src/Core/Search/Discussion/Gambit/AuthorGambit.php +++ b/src/Core/Search/Discussion/Gambit/AuthorGambit.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Search\Discussion\Gambit; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\UserRepository; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; use Flarum\Core\Search\Discussion\DiscussionSearch; @@ -25,12 +25,12 @@ class AuthorGambit extends AbstractRegexGambit protected $pattern = 'author:(.+)'; /** - * @var UserRepository + * @var \Flarum\User\UserRepository */ protected $users; /** - * @param \Flarum\Core\Repository\UserRepository $users + * @param \Flarum\User\UserRepository $users */ public function __construct(UserRepository $users) { diff --git a/src/Core/Search/SearchCriteria.php b/src/Core/Search/SearchCriteria.php index 2bacfb2c3..567155d8b 100644 --- a/src/Core/Search/SearchCriteria.php +++ b/src/Core/Search/SearchCriteria.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Search; -use Flarum\Core\User; +use Flarum\User\User; /** * Represents the criteria that will determine the entire result set of a diff --git a/src/Core/Search/SearchServiceProvider.php b/src/Core/Search/SearchServiceProvider.php index 3f5a80065..82172abb4 100644 --- a/src/Core/Search/SearchServiceProvider.php +++ b/src/Core/Search/SearchServiceProvider.php @@ -37,14 +37,14 @@ class SearchServiceProvider extends AbstractServiceProvider public function registerUserGambits() { - $this->app->when('Flarum\Core\Search\User\UserSearcher') + $this->app->when('Flarum\Core\User\Search\UserSearcher') ->needs('Flarum\Core\Search\GambitManager') ->give(function (Container $app) { $gambits = new GambitManager($app); - $gambits->setFulltextGambit('Flarum\Core\Search\User\Gambit\FulltextGambit'); - $gambits->add('Flarum\Core\Search\User\Gambit\EmailGambit'); - $gambits->add('Flarum\Core\Search\User\Gambit\GroupGambit'); + $gambits->setFulltextGambit('Flarum\Core\User\Search\Gambit\FulltextGambit'); + $gambits->add('Flarum\Core\User\Search\Gambit\EmailGambit'); + $gambits->add('Flarum\Core\User\Search\Gambit\GroupGambit'); $app->make('events')->fire( new ConfigureUserGambits($gambits) diff --git a/src/Core/Support/DispatchEventsTrait.php b/src/Core/Support/DispatchEventsTrait.php index 39266d1bc..c145a8c3d 100644 --- a/src/Core/Support/DispatchEventsTrait.php +++ b/src/Core/Support/DispatchEventsTrait.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Support; -use Flarum\Core\User; +use Flarum\User\User; use Illuminate\Contracts\Events\Dispatcher; trait DispatchEventsTrait diff --git a/src/Database/ScopeVisibilityTrait.php b/src/Database/ScopeVisibilityTrait.php index 0cfe43fc3..276f6a39d 100644 --- a/src/Database/ScopeVisibilityTrait.php +++ b/src/Database/ScopeVisibilityTrait.php @@ -11,7 +11,7 @@ namespace Flarum\Database; -use Flarum\Core\User; +use Flarum\User\User; use Flarum\Event\ScopeModelVisibility; use Illuminate\Database\Eloquent\Builder; diff --git a/src/Event/AvatarWillBeDeleted.php b/src/Event/AvatarWillBeDeleted.php index 9828fa674..df862684a 100644 --- a/src/Event/AvatarWillBeDeleted.php +++ b/src/Event/AvatarWillBeDeleted.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\User; +use Flarum\User\User; class AvatarWillBeDeleted { diff --git a/src/Event/AvatarWillBeSaved.php b/src/Event/AvatarWillBeSaved.php index f4e52bb65..3737bb350 100644 --- a/src/Event/AvatarWillBeSaved.php +++ b/src/Event/AvatarWillBeSaved.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\User; +use Flarum\User\User; class AvatarWillBeSaved { diff --git a/src/Event/CheckUserPassword.php b/src/Event/CheckUserPassword.php index ee86252c6..fa9ef2277 100644 --- a/src/Event/CheckUserPassword.php +++ b/src/Event/CheckUserPassword.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\User; +use Flarum\User\User; class CheckUserPassword { diff --git a/src/Event/ConfigureUserPreferences.php b/src/Event/ConfigureUserPreferences.php index dbc18cdb1..db9e9d0c8 100644 --- a/src/Event/ConfigureUserPreferences.php +++ b/src/Event/ConfigureUserPreferences.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\User; +use Flarum\User\User; class ConfigureUserPreferences { diff --git a/src/Event/ConfigureUserSearch.php b/src/Event/ConfigureUserSearch.php index fec2e6820..d32670705 100644 --- a/src/Event/ConfigureUserSearch.php +++ b/src/Event/ConfigureUserSearch.php @@ -12,12 +12,12 @@ namespace Flarum\Event; use Flarum\Core\Search\SearchCriteria; -use Flarum\Core\Search\User\UserSearch; +use Flarum\Core\User\Search\UserSearch; class ConfigureUserSearch { /** - * @var UserSearch + * @var \Flarum\Core\User\Search\UserSearch */ public $search; diff --git a/src/Event/DiscussionWasDeleted.php b/src/Event/DiscussionWasDeleted.php index 62dee388c..f57193918 100644 --- a/src/Event/DiscussionWasDeleted.php +++ b/src/Event/DiscussionWasDeleted.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Discussion; -use Flarum\Core\User; +use Flarum\User\User; class DiscussionWasDeleted { diff --git a/src/Event/DiscussionWasHidden.php b/src/Event/DiscussionWasHidden.php index bcd6cc93b..b99b3e03b 100644 --- a/src/Event/DiscussionWasHidden.php +++ b/src/Event/DiscussionWasHidden.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Discussion; -use Flarum\Core\User; +use Flarum\User\User; class DiscussionWasHidden { diff --git a/src/Event/DiscussionWasRenamed.php b/src/Event/DiscussionWasRenamed.php index c17656396..7d71a20ed 100644 --- a/src/Event/DiscussionWasRenamed.php +++ b/src/Event/DiscussionWasRenamed.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Discussion; -use Flarum\Core\User; +use Flarum\User\User; class DiscussionWasRenamed { diff --git a/src/Event/DiscussionWasRestored.php b/src/Event/DiscussionWasRestored.php index b9ead6384..22135b6ee 100644 --- a/src/Event/DiscussionWasRestored.php +++ b/src/Event/DiscussionWasRestored.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Discussion; -use Flarum\Core\User; +use Flarum\User\User; class DiscussionWasRestored { diff --git a/src/Event/DiscussionWasStarted.php b/src/Event/DiscussionWasStarted.php index 7a83e9f6f..b35ed7851 100644 --- a/src/Event/DiscussionWasStarted.php +++ b/src/Event/DiscussionWasStarted.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Discussion; -use Flarum\Core\User; +use Flarum\User\User; class DiscussionWasStarted { diff --git a/src/Event/DiscussionWillBeDeleted.php b/src/Event/DiscussionWillBeDeleted.php index 6508d1591..d70e399fe 100644 --- a/src/Event/DiscussionWillBeDeleted.php +++ b/src/Event/DiscussionWillBeDeleted.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Discussion; -use Flarum\Core\User; +use Flarum\User\User; class DiscussionWillBeDeleted { diff --git a/src/Event/DiscussionWillBeSaved.php b/src/Event/DiscussionWillBeSaved.php index 6a1d31f36..3d15ff4cc 100644 --- a/src/Event/DiscussionWillBeSaved.php +++ b/src/Event/DiscussionWillBeSaved.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Discussion; -use Flarum\Core\User; +use Flarum\User\User; class DiscussionWillBeSaved { diff --git a/src/Event/GetPermission.php b/src/Event/GetPermission.php index 78c93c83e..e18cb7ee8 100644 --- a/src/Event/GetPermission.php +++ b/src/Event/GetPermission.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\User; +use Flarum\User\User; class GetPermission { diff --git a/src/Event/GroupWasCreated.php b/src/Event/GroupWasCreated.php index a4e5f7536..2e4962809 100644 --- a/src/Event/GroupWasCreated.php +++ b/src/Event/GroupWasCreated.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Group; -use Flarum\Core\User; +use Flarum\User\User; class GroupWasCreated { diff --git a/src/Event/GroupWasDeleted.php b/src/Event/GroupWasDeleted.php index 21600c175..1d2290b7b 100644 --- a/src/Event/GroupWasDeleted.php +++ b/src/Event/GroupWasDeleted.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Group; -use Flarum\Core\User; +use Flarum\User\User; class GroupWasDeleted { diff --git a/src/Event/GroupWasRenamed.php b/src/Event/GroupWasRenamed.php index 30034f2be..ded05ce98 100644 --- a/src/Event/GroupWasRenamed.php +++ b/src/Event/GroupWasRenamed.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Group; -use Flarum\Core\User; +use Flarum\User\User; class GroupWasRenamed { diff --git a/src/Event/GroupWillBeDeleted.php b/src/Event/GroupWillBeDeleted.php index 3b8955a83..ac0d5b406 100644 --- a/src/Event/GroupWillBeDeleted.php +++ b/src/Event/GroupWillBeDeleted.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Group; -use Flarum\Core\User; +use Flarum\User\User; class GroupWillBeDeleted { diff --git a/src/Event/GroupWillBeSaved.php b/src/Event/GroupWillBeSaved.php index 51df92592..feeaac887 100644 --- a/src/Event/GroupWillBeSaved.php +++ b/src/Event/GroupWillBeSaved.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Group; -use Flarum\Core\User; +use Flarum\User\User; class GroupWillBeSaved { diff --git a/src/Event/NotificationWillBeSent.php b/src/Event/NotificationWillBeSent.php index fc428ae40..12a90ea9d 100644 --- a/src/Event/NotificationWillBeSent.php +++ b/src/Event/NotificationWillBeSent.php @@ -31,7 +31,7 @@ class NotificationWillBeSent /** * @param BlueprintInterface $blueprint - * @param \Flarum\Core\User[] $users + * @param \Flarum\User\User[] $users */ public function __construct(BlueprintInterface $blueprint, array &$users) { diff --git a/src/Event/PostWasDeleted.php b/src/Event/PostWasDeleted.php index 994ef0915..c98fdb373 100644 --- a/src/Event/PostWasDeleted.php +++ b/src/Event/PostWasDeleted.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Post; -use Flarum\Core\User; +use Flarum\User\User; class PostWasDeleted { diff --git a/src/Event/PostWasHidden.php b/src/Event/PostWasHidden.php index 4c7841c90..e41a6a7b3 100644 --- a/src/Event/PostWasHidden.php +++ b/src/Event/PostWasHidden.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Post\CommentPost; -use Flarum\Core\User; +use Flarum\User\User; class PostWasHidden { diff --git a/src/Event/PostWasPosted.php b/src/Event/PostWasPosted.php index 5b944778a..e59bcc0dc 100644 --- a/src/Event/PostWasPosted.php +++ b/src/Event/PostWasPosted.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Post; -use Flarum\Core\User; +use Flarum\User\User; class PostWasPosted { diff --git a/src/Event/PostWasRestored.php b/src/Event/PostWasRestored.php index bfc9fc801..581a6b601 100644 --- a/src/Event/PostWasRestored.php +++ b/src/Event/PostWasRestored.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Post\CommentPost; -use Flarum\Core\User; +use Flarum\User\User; class PostWasRestored { diff --git a/src/Event/PostWasRevised.php b/src/Event/PostWasRevised.php index cbffc9322..ddfd2afa0 100644 --- a/src/Event/PostWasRevised.php +++ b/src/Event/PostWasRevised.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Post\CommentPost; -use Flarum\Core\User; +use Flarum\User\User; class PostWasRevised { diff --git a/src/Event/PostWillBeDeleted.php b/src/Event/PostWillBeDeleted.php index f2875a54f..d5b32cae6 100644 --- a/src/Event/PostWillBeDeleted.php +++ b/src/Event/PostWillBeDeleted.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Post; -use Flarum\Core\User; +use Flarum\User\User; class PostWillBeDeleted { diff --git a/src/Event/PostWillBeSaved.php b/src/Event/PostWillBeSaved.php index 0dfb282c7..fb1736ab0 100644 --- a/src/Event/PostWillBeSaved.php +++ b/src/Event/PostWillBeSaved.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Post; -use Flarum\Core\User; +use Flarum\User\User; class PostWillBeSaved { diff --git a/src/Event/PrepareApiAttributes.php b/src/Event/PrepareApiAttributes.php index 533bef507..c97ad794e 100644 --- a/src/Event/PrepareApiAttributes.php +++ b/src/Event/PrepareApiAttributes.php @@ -44,7 +44,7 @@ class PrepareApiAttributes public $attributes; /** - * @var \Flarum\Core\User + * @var \Flarum\User\User */ public $actor; diff --git a/src/Event/PrepareApiData.php b/src/Event/PrepareApiData.php index c39f0894f..6d9b8f547 100644 --- a/src/Event/PrepareApiData.php +++ b/src/Event/PrepareApiData.php @@ -38,7 +38,7 @@ class PrepareApiData public $document; /** - * @var \Flarum\Core\User + * @var \Flarum\User\User */ public $actor; diff --git a/src/Event/PrepareUserGroups.php b/src/Event/PrepareUserGroups.php index d7e2ee868..fa03eb66a 100644 --- a/src/Event/PrepareUserGroups.php +++ b/src/Event/PrepareUserGroups.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\User; +use Flarum\User\User; /** * The `PrepareUserGroups` event. diff --git a/src/Event/ScopeHiddenDiscussionVisibility.php b/src/Event/ScopeHiddenDiscussionVisibility.php index 28235061e..411b89be6 100644 --- a/src/Event/ScopeHiddenDiscussionVisibility.php +++ b/src/Event/ScopeHiddenDiscussionVisibility.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\User; +use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; /** diff --git a/src/Event/ScopeModelVisibility.php b/src/Event/ScopeModelVisibility.php index ecf79e7d2..9eb5de654 100644 --- a/src/Event/ScopeModelVisibility.php +++ b/src/Event/ScopeModelVisibility.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\User; +use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; diff --git a/src/Event/ScopePostVisibility.php b/src/Event/ScopePostVisibility.php index a83ea20b1..16c488903 100644 --- a/src/Event/ScopePostVisibility.php +++ b/src/Event/ScopePostVisibility.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Discussion; -use Flarum\Core\User; +use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; /** diff --git a/src/Event/ScopePrivateDiscussionVisibility.php b/src/Event/ScopePrivateDiscussionVisibility.php index 2e6782b9f..c0b2758fc 100644 --- a/src/Event/ScopePrivateDiscussionVisibility.php +++ b/src/Event/ScopePrivateDiscussionVisibility.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\User; +use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; /** diff --git a/src/Event/ScopePrivatePostVisibility.php b/src/Event/ScopePrivatePostVisibility.php index bd67deb06..1339e5f27 100644 --- a/src/Event/ScopePrivatePostVisibility.php +++ b/src/Event/ScopePrivatePostVisibility.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Core\Discussion; -use Flarum\Core\User; +use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; /** diff --git a/src/Event/UserEmailWasChanged.php b/src/Event/UserEmailWasChanged.php deleted file mode 100644 index 91117b840..000000000 --- a/src/Event/UserEmailWasChanged.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Event; - -use Flarum\Core\User; - -class UserEmailWasChanged -{ - /** - * @var User - */ - public $user; - - /** - * @var User - */ - public $actor; - - /** - * @param User $user - * @param User $actor - */ - public function __construct(User $user, User $actor = null) - { - $this->user = $user; - $this->actor = $actor; - } -} diff --git a/src/Event/UserPasswordWasChanged.php b/src/Event/UserPasswordWasChanged.php deleted file mode 100644 index 0798c3f58..000000000 --- a/src/Event/UserPasswordWasChanged.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Event; - -use Flarum\Core\User; - -class UserPasswordWasChanged -{ - /** - * @var User - */ - public $user; - - /** - * @var User - */ - public $actor; - - /** - * @param User $user - * @param User $actor - */ - public function __construct(User $user, User $actor = null) - { - $this->user = $user; - $this->actor = $actor; - } -} diff --git a/src/Forum/AuthenticationResponseFactory.php b/src/Forum/AuthenticationResponseFactory.php index 17cc1497f..90efc1771 100644 --- a/src/Forum/AuthenticationResponseFactory.php +++ b/src/Forum/AuthenticationResponseFactory.php @@ -11,10 +11,10 @@ namespace Flarum\Forum; -use Flarum\Core\AuthToken; -use Flarum\Core\User; use Flarum\Http\Rememberer; use Flarum\Http\SessionAuthenticator; +use Flarum\User\AuthToken; +use Flarum\User\User; use Psr\Http\Message\ServerRequestInterface as Request; use Zend\Diactoros\Response\HtmlResponse; diff --git a/src/Forum/Controller/AuthorizedWebAppController.php b/src/Forum/Controller/AuthorizedWebAppController.php index 05a5baf96..7f1a4890c 100644 --- a/src/Forum/Controller/AuthorizedWebAppController.php +++ b/src/Forum/Controller/AuthorizedWebAppController.php @@ -11,7 +11,7 @@ namespace Flarum\Forum\Controller; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface as Request; class AuthorizedWebAppController extends FrontendController diff --git a/src/Forum/Controller/ConfirmEmailController.php b/src/Forum/Controller/ConfirmEmailController.php index 64727c693..0284674ed 100644 --- a/src/Forum/Controller/ConfirmEmailController.php +++ b/src/Forum/Controller/ConfirmEmailController.php @@ -12,7 +12,7 @@ namespace Flarum\Forum\Controller; use Flarum\Core\Command\ConfirmEmail; -use Flarum\Core\Exception\InvalidConfirmationTokenException; +use Flarum\User\Exception\InvalidConfirmationTokenException; use Flarum\Foundation\Application; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\SessionAuthenticator; diff --git a/src/Forum/Controller/DiscussionController.php b/src/Forum/Controller/DiscussionController.php index f12b1092e..4b60ecc84 100644 --- a/src/Forum/Controller/DiscussionController.php +++ b/src/Forum/Controller/DiscussionController.php @@ -12,10 +12,10 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; -use Flarum\Core\User; use Flarum\Forum\UrlGenerator; use Flarum\Forum\Frontend; use Flarum\Http\Exception\RouteNotFoundException; +use Flarum\User\User; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; diff --git a/src/Forum/Controller/IndexController.php b/src/Forum/Controller/IndexController.php index 8deeb7867..278710aab 100644 --- a/src/Forum/Controller/IndexController.php +++ b/src/Forum/Controller/IndexController.php @@ -12,7 +12,7 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client as ApiClient; -use Flarum\Core\User; +use Flarum\User\User; use Flarum\Forum\Frontend; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; diff --git a/src/Forum/Controller/LogInController.php b/src/Forum/Controller/LogInController.php index f131150f9..5cabd47dd 100644 --- a/src/Forum/Controller/LogInController.php +++ b/src/Forum/Controller/LogInController.php @@ -13,8 +13,8 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; use Flarum\Api\Controller\TokenController; -use Flarum\Core\Repository\UserRepository; -use Flarum\Event\UserLoggedIn; +use Flarum\User\UserRepository; +use Flarum\User\Event\LoggedIn; use Flarum\Http\AccessToken; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Rememberer; @@ -26,7 +26,7 @@ use Zend\Diactoros\Response\JsonResponse; class LogInController implements ControllerInterface { /** - * @var \Flarum\Core\Repository\UserRepository + * @var \Flarum\User\UserRepository */ protected $users; @@ -46,7 +46,7 @@ class LogInController implements ControllerInterface protected $rememberer; /** - * @param \Flarum\Core\Repository\UserRepository $users + * @param \Flarum\User\UserRepository $users * @param Client $apiClient * @param SessionAuthenticator $authenticator * @param Rememberer $rememberer @@ -79,7 +79,7 @@ class LogInController implements ControllerInterface $token = AccessToken::find($data->token); - event(new UserLoggedIn($this->users->findOrFail($data->userId), $token)); + event(new LoggedIn($this->users->findOrFail($data->userId), $token)); $response = $this->rememberer->remember($response, $token, ! array_get($body, 'remember')); } diff --git a/src/Forum/Controller/LogOutController.php b/src/Forum/Controller/LogOutController.php index 1aef40efb..c83601268 100644 --- a/src/Forum/Controller/LogOutController.php +++ b/src/Forum/Controller/LogOutController.php @@ -12,7 +12,7 @@ namespace Flarum\Forum\Controller; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Event\UserLoggedOut; +use Flarum\User\Event\LoggedOut; use Flarum\Foundation\Application; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Exception\TokenMismatchException; @@ -85,7 +85,7 @@ class LogOutController implements ControllerInterface $actor->accessTokens()->delete(); - $this->events->fire(new UserLoggedOut($actor)); + $this->events->fire(new LoggedOut($actor)); return $this->rememberer->forget($response); } diff --git a/src/Forum/Controller/ResetPasswordController.php b/src/Forum/Controller/ResetPasswordController.php index 42a47b288..36e313a2e 100644 --- a/src/Forum/Controller/ResetPasswordController.php +++ b/src/Forum/Controller/ResetPasswordController.php @@ -12,8 +12,8 @@ namespace Flarum\Forum\Controller; use DateTime; -use Flarum\Core\Exception\InvalidConfirmationTokenException; -use Flarum\Core\PasswordToken; +use Flarum\User\Exception\InvalidConfirmationTokenException; +use Flarum\User\PasswordToken; use Flarum\Http\Controller\AbstractHtmlController; use Illuminate\Contracts\View\Factory; use Psr\Http\Message\ServerRequestInterface as Request; @@ -43,7 +43,7 @@ class ResetPasswordController extends AbstractHtmlController /** * @param Request $request * @return \Illuminate\Contracts\View\View - * @throws InvalidConfirmationTokenException + * @throws \Flarum\User\Exception\InvalidConfirmationTokenException */ public function render(Request $request) { diff --git a/src/Forum/Controller/SavePasswordController.php b/src/Forum/Controller/SavePasswordController.php index 0b36f9779..20623cf8f 100644 --- a/src/Forum/Controller/SavePasswordController.php +++ b/src/Forum/Controller/SavePasswordController.php @@ -11,8 +11,8 @@ namespace Flarum\Forum\Controller; -use Flarum\Core\PasswordToken; -use Flarum\Core\Validator\UserValidator; +use Flarum\User\PasswordToken; +use Flarum\User\UserValidator; use Flarum\Forum\UrlGenerator; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\SessionAuthenticator; @@ -29,7 +29,7 @@ class SavePasswordController implements ControllerInterface protected $url; /** - * @var UserValidator + * @var \Flarum\User\UserValidator */ protected $validator; diff --git a/src/Http/AbstractServer.php b/src/Http/AbstractServer.php index ae676755a..de6f923c2 100644 --- a/src/Http/AbstractServer.php +++ b/src/Http/AbstractServer.php @@ -11,9 +11,9 @@ namespace Flarum\Http; -use Flarum\Core\AuthToken; -use Flarum\Core\EmailToken; -use Flarum\Core\PasswordToken; +use Flarum\User\AuthToken; +use Flarum\User\EmailToken; +use Flarum\User\PasswordToken; use Flarum\Foundation\AbstractServer as BaseAbstractServer; use Flarum\Foundation\Application; use Psr\Http\Message\ResponseInterface; diff --git a/src/Http/AccessToken.php b/src/Http/AccessToken.php index 45557f3c8..dad24ae3b 100644 --- a/src/Http/AccessToken.php +++ b/src/Http/AccessToken.php @@ -18,7 +18,7 @@ use Flarum\Database\AbstractModel; * @property int $user_id * @property int $last_activity * @property int $lifetime - * @property \Flarum\Core\User|null $user + * @property \Flarum\User\User|null $user */ class AccessToken extends AbstractModel { @@ -67,6 +67,6 @@ class AccessToken extends AbstractModel */ public function user() { - return $this->belongsTo('Flarum\Core\User'); + return $this->belongsTo('Flarum\User\User'); } } diff --git a/src/Http/Middleware/AuthenticateWithHeader.php b/src/Http/Middleware/AuthenticateWithHeader.php index 9b34b11dc..c13313754 100644 --- a/src/Http/Middleware/AuthenticateWithHeader.php +++ b/src/Http/Middleware/AuthenticateWithHeader.php @@ -12,7 +12,7 @@ namespace Flarum\Http\Middleware; use Flarum\Api\ApiKey; -use Flarum\Core\User; +use Flarum\User\User; use Flarum\Http\AccessToken; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; diff --git a/src/Http/Middleware/AuthenticateWithSession.php b/src/Http/Middleware/AuthenticateWithSession.php index d4d0ac624..e9aee0698 100644 --- a/src/Http/Middleware/AuthenticateWithSession.php +++ b/src/Http/Middleware/AuthenticateWithSession.php @@ -11,8 +11,8 @@ namespace Flarum\Http\Middleware; -use Flarum\Core\Guest; -use Flarum\Core\User; +use Flarum\User\Guest; +use Flarum\User\User; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Symfony\Component\HttpFoundation\Session\SessionInterface; diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index 1a7317830..acf67997d 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -15,7 +15,7 @@ use Exception; use Flarum\Console\AbstractCommand; use Flarum\Core\Group; use Flarum\Core\Permission; -use Flarum\Core\User; +use Flarum\User\User; use Flarum\Database\AbstractModel; use Illuminate\Contracts\Foundation\Application; use Illuminate\Filesystem\Filesystem; diff --git a/src/Core/Access/AbstractPolicy.php b/src/User/AbstractPolicy.php similarity index 98% rename from src/Core/Access/AbstractPolicy.php rename to src/User/AbstractPolicy.php index d9b8f457f..745b6642b 100644 --- a/src/Core/Access/AbstractPolicy.php +++ b/src/User/AbstractPolicy.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Access; +namespace Flarum\User; use Flarum\Event\GetPermission; use Flarum\Event\ScopeModelVisibility; diff --git a/src/Core/AuthToken.php b/src/User/AuthToken.php similarity index 92% rename from src/Core/AuthToken.php rename to src/User/AuthToken.php index 57dd83c28..dd785b72a 100644 --- a/src/Core/AuthToken.php +++ b/src/User/AuthToken.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\User; use DateTime; -use Flarum\Core\Exception\InvalidConfirmationTokenException; +use Flarum\User\Exception\InvalidConfirmationTokenException; use Flarum\Database\AbstractModel; /** @@ -82,7 +82,7 @@ class AuthToken extends AbstractModel * @param \Illuminate\Database\Eloquent\Builder $query * @param string $id * - * @throws InvalidConfirmationTokenException + * @throws \Flarum\User\Exception\InvalidConfirmationTokenException * * @return static */ diff --git a/src/Core/Validator/AvatarValidator.php b/src/User/AvatarValidator.php similarity index 86% rename from src/Core/Validator/AvatarValidator.php rename to src/User/AvatarValidator.php index 4546cfed0..b4adcb321 100644 --- a/src/Core/Validator/AvatarValidator.php +++ b/src/User/AvatarValidator.php @@ -9,7 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Validator; +namespace Flarum\User; + +use Flarum\Core\Validator\AbstractValidator; class AvatarValidator extends AbstractValidator { diff --git a/src/Core/Listener/EmailConfirmationMailer.php b/src/User/EmailConfirmationMailer.php similarity index 82% rename from src/Core/Listener/EmailConfirmationMailer.php rename to src/User/EmailConfirmationMailer.php index 295d45d7c..b02c3f037 100755 --- a/src/Core/Listener/EmailConfirmationMailer.php +++ b/src/User/EmailConfirmationMailer.php @@ -9,13 +9,10 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Listener; +namespace Flarum\User; -use Flarum\Core; -use Flarum\Core\EmailToken; -use Flarum\Core\User; -use Flarum\Event\UserEmailChangeWasRequested; -use Flarum\Event\UserWasRegistered; +use Flarum\User\Event\EmailChangeRequested; +use Flarum\User\Event\Registered; use Flarum\Forum\UrlGenerator; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; @@ -64,14 +61,14 @@ class EmailConfirmationMailer */ public function subscribe(Dispatcher $events) { - $events->listen(UserWasRegistered::class, [$this, 'whenUserWasRegistered']); - $events->listen(UserEmailChangeWasRequested::class, [$this, 'whenUserEmailChangeWasRequested']); + $events->listen(Registered::class, [$this, 'whenUserWasRegistered']); + $events->listen(EmailChangeRequested::class, [$this, 'whenUserEmailChangeWasRequested']); } /** - * @param \Flarum\Event\UserWasRegistered $event + * @param \Flarum\User\Event\Registered $event */ - public function whenUserWasRegistered(UserWasRegistered $event) + public function whenUserWasRegistered(Registered $event) { $user = $event->user; @@ -90,9 +87,9 @@ class EmailConfirmationMailer } /** - * @param \Flarum\Event\UserEmailChangeWasRequested $event + * @param \Flarum\User\Event\EmailChangeRequested $event */ - public function whenUserEmailChangeWasRequested(UserEmailChangeWasRequested $event) + public function whenUserEmailChangeWasRequested(EmailChangeRequested $event) { $email = $event->email; $data = $this->getEmailData($event->user, $email); diff --git a/src/Core/EmailToken.php b/src/User/EmailToken.php similarity index 95% rename from src/Core/EmailToken.php rename to src/User/EmailToken.php index 257d62211..e0383f2ff 100644 --- a/src/Core/EmailToken.php +++ b/src/User/EmailToken.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\User; use DateTime; -use Flarum\Core\Exception\InvalidConfirmationTokenException; +use Flarum\User\Exception\InvalidConfirmationTokenException; use Flarum\Database\AbstractModel; /** diff --git a/src/Event/UserWasDeleted.php b/src/User/Event/Activated.php similarity index 88% rename from src/Event/UserWasDeleted.php rename to src/User/Event/Activated.php index 5f041b284..d4ad87dff 100644 --- a/src/Event/UserWasDeleted.php +++ b/src/User/Event/Activated.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserWasDeleted +class Activated { /** * @var User diff --git a/src/User/Event/AvatarChanged.php b/src/User/Event/AvatarChanged.php new file mode 100644 index 000000000..1754d0538 --- /dev/null +++ b/src/User/Event/AvatarChanged.php @@ -0,0 +1,37 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\User\Event; + +use Flarum\User\User; + +class AvatarChanged +{ + /** + * @var User + */ + public $user; + + /** + * @var User + */ + public $actor; + + /** + * @param User $user + * @param User $actor + */ + public function __construct(User $user, User $actor = null) + { + $this->user = $user; + $this->actor = $actor; + } +} diff --git a/src/Event/UserWasActivated.php b/src/User/Event/BioChanged.php similarity index 88% rename from src/Event/UserWasActivated.php rename to src/User/Event/BioChanged.php index 2245caed4..2751516f6 100644 --- a/src/Event/UserWasActivated.php +++ b/src/User/Event/BioChanged.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserWasActivated +class BioChanged { /** * @var User diff --git a/src/Event/UserWasRenamed.php b/src/User/Event/Deleted.php similarity index 88% rename from src/Event/UserWasRenamed.php rename to src/User/Event/Deleted.php index 671e64080..0b3a574ef 100644 --- a/src/Event/UserWasRenamed.php +++ b/src/User/Event/Deleted.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserWasRenamed +class Deleted { /** * @var User diff --git a/src/Event/UserWillBeDeleted.php b/src/User/Event/Deleting.php similarity index 92% rename from src/Event/UserWillBeDeleted.php rename to src/User/Event/Deleting.php index 5ecc8685a..1ff7766f5 100644 --- a/src/Event/UserWillBeDeleted.php +++ b/src/User/Event/Deleting.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserWillBeDeleted +class Deleting { /** * The user who will be deleted. diff --git a/src/Event/UserEmailChangeWasRequested.php b/src/User/Event/EmailChangeRequested.php similarity index 89% rename from src/Event/UserEmailChangeWasRequested.php rename to src/User/Event/EmailChangeRequested.php index 1b4498699..0a237c1c6 100644 --- a/src/Event/UserEmailChangeWasRequested.php +++ b/src/User/Event/EmailChangeRequested.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserEmailChangeWasRequested +class EmailChangeRequested { /** * The user who requested the email change. diff --git a/src/Event/UserBioWasChanged.php b/src/User/Event/EmailChanged.php similarity index 88% rename from src/Event/UserBioWasChanged.php rename to src/User/Event/EmailChanged.php index dfde182b0..fa1bf7759 100644 --- a/src/Event/UserBioWasChanged.php +++ b/src/User/Event/EmailChanged.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserBioWasChanged +class EmailChanged { /** * @var User diff --git a/src/Event/UserGroupsWereChanged.php b/src/User/Event/GroupsChanged.php similarity index 91% rename from src/Event/UserGroupsWereChanged.php rename to src/User/Event/GroupsChanged.php index 91822f158..feb6484d7 100644 --- a/src/Event/UserGroupsWereChanged.php +++ b/src/User/Event/GroupsChanged.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserGroupsWereChanged +class GroupsChanged { /** * The user whose groups were changed. diff --git a/src/Event/UserLoggedIn.php b/src/User/Event/LoggedIn.php similarity index 86% rename from src/Event/UserLoggedIn.php rename to src/User/Event/LoggedIn.php index 175994a71..32d17b695 100644 --- a/src/Event/UserLoggedIn.php +++ b/src/User/Event/LoggedIn.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; use Flarum\Http\AccessToken; -class UserLoggedIn +class LoggedIn { public $user; diff --git a/src/Event/UserLoggedOut.php b/src/User/Event/LoggedOut.php similarity index 83% rename from src/Event/UserLoggedOut.php rename to src/User/Event/LoggedOut.php index 9e4680c16..103026983 100644 --- a/src/Event/UserLoggedOut.php +++ b/src/User/Event/LoggedOut.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserLoggedOut +class LoggedOut { public $user; diff --git a/src/Event/UserAvatarWasChanged.php b/src/User/Event/PasswordChanged.php similarity index 88% rename from src/Event/UserAvatarWasChanged.php rename to src/User/Event/PasswordChanged.php index a328bdd00..855348676 100644 --- a/src/Event/UserAvatarWasChanged.php +++ b/src/User/Event/PasswordChanged.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserAvatarWasChanged +class PasswordChanged { /** * @var User diff --git a/src/Event/UserWasRegistered.php b/src/User/Event/Registered.php similarity index 88% rename from src/Event/UserWasRegistered.php rename to src/User/Event/Registered.php index 2cc82ce5b..5deedfc5d 100644 --- a/src/Event/UserWasRegistered.php +++ b/src/User/Event/Registered.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserWasRegistered +class Registered { /** * @var User diff --git a/src/User/Event/Renamed.php b/src/User/Event/Renamed.php new file mode 100644 index 000000000..1e453d64a --- /dev/null +++ b/src/User/Event/Renamed.php @@ -0,0 +1,37 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\User\Event; + +use Flarum\User\User; + +class Renamed +{ + /** + * @var User + */ + public $user; + + /** + * @var User + */ + public $actor; + + /** + * @param User $user + * @param User $actor + */ + public function __construct(User $user, User $actor = null) + { + $this->user = $user; + $this->actor = $actor; + } +} diff --git a/src/Event/UserWillBeSaved.php b/src/User/Event/Saving.php similarity index 93% rename from src/Event/UserWillBeSaved.php rename to src/User/Event/Saving.php index 5b0d39b80..b8f09f371 100644 --- a/src/Event/UserWillBeSaved.php +++ b/src/User/Event/Saving.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; -use Flarum\Core\User; +use Flarum\User\User; -class UserWillBeSaved +class Saving { /** * The user that will be saved. diff --git a/src/Core/Exception/InvalidConfirmationTokenException.php b/src/User/Exception/InvalidConfirmationTokenException.php similarity index 90% rename from src/Core/Exception/InvalidConfirmationTokenException.php rename to src/User/Exception/InvalidConfirmationTokenException.php index c3bb44091..c8e9240b2 100644 --- a/src/Core/Exception/InvalidConfirmationTokenException.php +++ b/src/User/Exception/InvalidConfirmationTokenException.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Exception; +namespace Flarum\User\Exception; use Exception; diff --git a/src/Core/Exception/PermissionDeniedException.php b/src/User/Exception/PermissionDeniedException.php similarity index 93% rename from src/Core/Exception/PermissionDeniedException.php rename to src/User/Exception/PermissionDeniedException.php index a80289fdc..1bbeb766c 100644 --- a/src/Core/Exception/PermissionDeniedException.php +++ b/src/User/Exception/PermissionDeniedException.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Exception; +namespace Flarum\User\Exception; use Exception; diff --git a/src/Core/Access/Gate.php b/src/User/Gate.php similarity index 99% rename from src/Core/Access/Gate.php rename to src/User/Gate.php index f6eba5078..9a9e91a27 100644 --- a/src/Core/Access/Gate.php +++ b/src/User/Gate.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Access; +namespace Flarum\User; use Illuminate\Contracts\Auth\Access\Gate as GateContract; use Illuminate\Contracts\Container\Container; diff --git a/src/Core/Guest.php b/src/User/Guest.php similarity index 94% rename from src/Core/Guest.php rename to src/User/Guest.php index 0fbf00748..e62b8c695 100755 --- a/src/Core/Guest.php +++ b/src/User/Guest.php @@ -9,7 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\User; + +use Flarum\Core\Group; class Guest extends User { diff --git a/src/Core/PasswordToken.php b/src/User/PasswordToken.php similarity index 98% rename from src/Core/PasswordToken.php rename to src/User/PasswordToken.php index 5d08e3867..190d1d27a 100644 --- a/src/Core/PasswordToken.php +++ b/src/User/PasswordToken.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\User; use Flarum\Database\AbstractModel; diff --git a/src/Core/Search/User/Gambit/EmailGambit.php b/src/User/Search/Gambit/EmailGambit.php similarity index 85% rename from src/Core/Search/User/Gambit/EmailGambit.php rename to src/User/Search/Gambit/EmailGambit.php index 8d14fd921..11b0b793a 100644 --- a/src/Core/Search/User/Gambit/EmailGambit.php +++ b/src/User/Search/Gambit/EmailGambit.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\User\Gambit; +namespace Flarum\Core\User\Search\Gambit; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\UserRepository; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; -use Flarum\Core\Search\User\UserSearch; +use Flarum\Core\User\Search\UserSearch; use LogicException; class EmailGambit extends AbstractRegexGambit @@ -25,12 +25,12 @@ class EmailGambit extends AbstractRegexGambit protected $pattern = 'email:(.+)'; /** - * @var UserRepository + * @var \Flarum\User\UserRepository */ protected $users; /** - * @param \Flarum\Core\Repository\UserRepository $users + * @param \Flarum\User\UserRepository $users */ public function __construct(UserRepository $users) { diff --git a/src/Core/Search/User/Gambit/FulltextGambit.php b/src/User/Search/Gambit/FulltextGambit.php similarity index 87% rename from src/Core/Search/User/Gambit/FulltextGambit.php rename to src/User/Search/Gambit/FulltextGambit.php index 2f7c4c4c3..c8349d740 100644 --- a/src/Core/Search/User/Gambit/FulltextGambit.php +++ b/src/User/Search/Gambit/FulltextGambit.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\User\Gambit; +namespace Flarum\Core\User\Search\Gambit; -use Flarum\Core\Repository\UserRepository; +use Flarum\User\UserRepository; use Flarum\Core\Search\AbstractSearch; use Flarum\Core\Search\GambitInterface; @@ -23,7 +23,7 @@ class FulltextGambit implements GambitInterface protected $users; /** - * @param UserRepository $users + * @param \Flarum\User\UserRepository $users */ public function __construct(UserRepository $users) { diff --git a/src/Core/Search/User/Gambit/GroupGambit.php b/src/User/Search/Gambit/GroupGambit.php similarity index 95% rename from src/Core/Search/User/Gambit/GroupGambit.php rename to src/User/Search/Gambit/GroupGambit.php index 4f020904d..abe1ad984 100644 --- a/src/Core/Search/User/Gambit/GroupGambit.php +++ b/src/User/Search/Gambit/GroupGambit.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\User\Gambit; +namespace Flarum\Core\User\Search\Gambit; use Flarum\Core\Repository\GroupRepository; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; -use Flarum\Core\Search\User\UserSearch; +use Flarum\Core\User\Search\UserSearch; use LogicException; class GroupGambit extends AbstractRegexGambit diff --git a/src/Core/Search/User/UserSearch.php b/src/User/Search/UserSearch.php similarity index 89% rename from src/Core/Search/User/UserSearch.php rename to src/User/Search/UserSearch.php index dc3554499..9223dbd04 100644 --- a/src/Core/Search/User/UserSearch.php +++ b/src/User/Search/UserSearch.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\User; +namespace Flarum\Core\User\Search; use Flarum\Core\Search\AbstractSearch; diff --git a/src/Core/Search/User/UserSearcher.php b/src/User/Search/UserSearcher.php similarity index 93% rename from src/Core/Search/User/UserSearcher.php rename to src/User/Search/UserSearcher.php index 855726dfd..0043deb1d 100644 --- a/src/Core/Search/User/UserSearcher.php +++ b/src/User/Search/UserSearcher.php @@ -9,9 +9,10 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\User; +namespace Flarum\Core\User\Search; -use Flarum\Core\Repository\UserRepository; +use Flarum\Core\User\Search\UserSearch; +use Flarum\User\UserRepository; use Flarum\Core\Search\ApplySearchParametersTrait; use Flarum\Core\Search\GambitManager; use Flarum\Core\Search\SearchCriteria; @@ -38,7 +39,7 @@ class UserSearcher /** * @param GambitManager $gambits - * @param UserRepository $users + * @param \Flarum\User\UserRepository $users */ public function __construct(GambitManager $gambits, UserRepository $users) { diff --git a/src/Core/User.php b/src/User/User.php similarity index 94% rename from src/Core/User.php rename to src/User/User.php index fd175c998..9e4917fc5 100755 --- a/src/Core/User.php +++ b/src/User/User.php @@ -9,10 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\User; use DomainException; -use Flarum\Core\Access\Gate; +use Flarum\User\Gate; +use Flarum\Core\Group; +use Flarum\Core\Notification; +use Flarum\Core\Permission; use Flarum\Core\Support\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; @@ -20,15 +23,15 @@ use Flarum\Event\CheckUserPassword; use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\PostWasDeleted; use Flarum\Event\PrepareUserGroups; -use Flarum\Event\UserAvatarWasChanged; -use Flarum\Event\UserBioWasChanged; -use Flarum\Event\UserEmailChangeWasRequested; -use Flarum\Event\UserEmailWasChanged; -use Flarum\Event\UserPasswordWasChanged; -use Flarum\Event\UserWasActivated; -use Flarum\Event\UserWasDeleted; -use Flarum\Event\UserWasRegistered; -use Flarum\Event\UserWasRenamed; +use Flarum\User\Event\AvatarChanged; +use Flarum\User\Event\BioChanged; +use Flarum\User\Event\EmailChangeRequested; +use Flarum\User\Event\EmailChanged; +use Flarum\User\Event\PasswordChanged; +use Flarum\User\Event\Activated; +use Flarum\User\Event\Deleted; +use Flarum\User\Event\Registered; +use Flarum\User\Event\Renamed; use Flarum\Foundation\Application; use Illuminate\Contracts\Hashing\Hasher; use Symfony\Component\HttpFoundation\Session\SessionInterface; @@ -125,7 +128,7 @@ class User extends AbstractModel }); static::deleted(function (User $user) { - $user->raise(new UserWasDeleted($user)); + $user->raise(new Deleted($user)); // Delete all of the posts by the user. Before we delete them // in a big batch query, we will loop through them and raise a @@ -166,7 +169,7 @@ class User extends AbstractModel $user->password = $password; $user->join_time = time(); - $user->raise(new UserWasRegistered($user)); + $user->raise(new Registered($user)); return $user; } @@ -198,7 +201,7 @@ class User extends AbstractModel if ($username !== $this->username) { $this->username = $username; - $this->raise(new UserWasRenamed($this)); + $this->raise(new Renamed($this)); } return $this; @@ -215,7 +218,7 @@ class User extends AbstractModel if ($email !== $this->email) { $this->email = $email; - $this->raise(new UserEmailWasChanged($this)); + $this->raise(new EmailChanged($this)); } return $this; @@ -230,7 +233,7 @@ class User extends AbstractModel public function requestEmailChange($email) { if ($email !== $this->email) { - $this->raise(new UserEmailChangeWasRequested($this, $email)); + $this->raise(new EmailChangeRequested($this, $email)); } return $this; @@ -246,7 +249,7 @@ class User extends AbstractModel { $this->password = $password; - $this->raise(new UserPasswordWasChanged($this)); + $this->raise(new PasswordChanged($this)); return $this; } @@ -271,7 +274,7 @@ class User extends AbstractModel { $this->bio = $bio; - $this->raise(new UserBioWasChanged($this)); + $this->raise(new BioChanged($this)); return $this; } @@ -310,7 +313,7 @@ class User extends AbstractModel { $this->avatar_path = $path; - $this->raise(new UserAvatarWasChanged($this)); + $this->raise(new AvatarChanged($this)); return $this; } @@ -367,7 +370,7 @@ class User extends AbstractModel if ($this->is_activated !== true) { $this->is_activated = true; - $this->raise(new UserWasActivated($this)); + $this->raise(new Activated($this)); } return $this; diff --git a/src/Core/Listener/UserMetadataUpdater.php b/src/User/UserMetadataUpdater.php similarity index 97% rename from src/Core/Listener/UserMetadataUpdater.php rename to src/User/UserMetadataUpdater.php index 2e85c2d5c..3d5e9ad5b 100755 --- a/src/Core/Listener/UserMetadataUpdater.php +++ b/src/User/UserMetadataUpdater.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Listener; +namespace Flarum\User; use Flarum\Core\Discussion; use Flarum\Core\Post; @@ -69,7 +69,7 @@ class UserMetadataUpdater } /** - * @param \Flarum\Events\DiscussionWasStarted $event + * @param \Flarum\Event\DiscussionWasStarted $event */ public function whenDiscussionWasStarted(DiscussionWasStarted $event) { diff --git a/src/Core/Access/UserPolicy.php b/src/User/UserPolicy.php similarity index 94% rename from src/Core/Access/UserPolicy.php rename to src/User/UserPolicy.php index 24b95e25a..3a52fcaf0 100644 --- a/src/Core/Access/UserPolicy.php +++ b/src/User/UserPolicy.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Access; +namespace Flarum\User; -use Flarum\Core\User; +use Flarum\User\AbstractPolicy; use Illuminate\Database\Eloquent\Builder; class UserPolicy extends AbstractPolicy diff --git a/src/Core/Repository/UserRepository.php b/src/User/UserRepository.php similarity index 98% rename from src/Core/Repository/UserRepository.php rename to src/User/UserRepository.php index a350f9f10..bea76c55d 100644 --- a/src/Core/Repository/UserRepository.php +++ b/src/User/UserRepository.php @@ -9,9 +9,8 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Repository; +namespace Flarum\User; -use Flarum\Core\User; use Illuminate\Database\Eloquent\Builder; class UserRepository diff --git a/src/Core/Validator/UserValidator.php b/src/User/UserValidator.php similarity index 95% rename from src/Core/Validator/UserValidator.php rename to src/User/UserValidator.php index f58d9d42b..79d0a08c1 100644 --- a/src/Core/Validator/UserValidator.php +++ b/src/User/UserValidator.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Validator; +namespace Flarum\User; -use Flarum\Core\User; +use Flarum\Core\Validator\AbstractValidator; class UserValidator extends AbstractValidator { diff --git a/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php b/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php index 6591fff1f..19b918d2c 100644 --- a/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php @@ -13,7 +13,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; use Flarum\Api\ExceptionHandler\InvalidConfirmationTokenExceptionHandler; -use Flarum\Core\Exception\InvalidConfirmationTokenException; +use Flarum\User\Exception\InvalidConfirmationTokenException; use Tests\Test\TestCase; class InvalidConfirmationTokenExceptionHandlerTest extends TestCase diff --git a/tests/Flarum/Api/Handler/PermissionDeniedExceptionHandlerTest.php b/tests/Flarum/Api/Handler/PermissionDeniedExceptionHandlerTest.php index 10d52b19f..0494f6240 100644 --- a/tests/Flarum/Api/Handler/PermissionDeniedExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/PermissionDeniedExceptionHandlerTest.php @@ -13,7 +13,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; use Flarum\Api\ExceptionHandler\PermissionDeniedExceptionHandler; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Tests\Test\TestCase; class PermissionDeniedExceptionHandlerTest extends TestCase From 551e76f29691626c1d162995a1d4de94a4d88420 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 13:16:02 +0200 Subject: [PATCH 15/86] Move events to Flarum\Settings\Event namespace --- src/Admin/AdminServiceProvider.php | 4 ++-- src/Admin/Controller/FrontendController.php | 4 ++-- src/Api/Controller/SetSettingsController.php | 8 ++++---- src/Forum/ForumServiceProvider.php | 4 ++-- .../Event/Deserializing.php} | 4 ++-- src/{Event/SettingWasSet.php => Settings/Event/Saved.php} | 4 ++-- .../Event/Serializing.php} | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) rename src/{Event/PrepareUnserializedSettings.php => Settings/Event/Deserializing.php} (92%) rename src/{Event/SettingWasSet.php => Settings/Event/Saved.php} (93%) rename src/{Event/PrepareSerializedSetting.php => Settings/Event/Serializing.php} (92%) diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index 2cbd60a78..87e784816 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -13,7 +13,7 @@ namespace Flarum\Admin; use Flarum\Event\ExtensionWasDisabled; use Flarum\Event\ExtensionWasEnabled; -use Flarum\Event\SettingWasSet; +use Flarum\Settings\Event\Saved; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Http\Handler\RouteHandlerFactory; use Flarum\Http\RouteCollection; @@ -63,7 +63,7 @@ class AdminServiceProvider extends AbstractServiceProvider protected function flushWebAppAssetsWhenThemeChanged() { - $this->app->make('events')->listen(SettingWasSet::class, function (SettingWasSet $event) { + $this->app->make('events')->listen(Saved::class, function (Saved $event) { if (preg_match('/^theme_|^custom_less$/i', $event->key)) { $this->getWebAppAssets()->flushCss(); } diff --git a/src/Admin/Controller/FrontendController.php b/src/Admin/Controller/FrontendController.php index eb691f88f..d1b18d2ba 100644 --- a/src/Admin/Controller/FrontendController.php +++ b/src/Admin/Controller/FrontendController.php @@ -13,7 +13,7 @@ namespace Flarum\Admin\Controller; use Flarum\Admin\Frontend; use Flarum\Core\Permission; -use Flarum\Event\PrepareUnserializedSettings; +use Flarum\Settings\Event\Deserializing; use Flarum\Extension\ExtensionManager; use Flarum\Frontend\AbstractFrontendController; use Flarum\Settings\SettingsRepositoryInterface; @@ -56,7 +56,7 @@ class FrontendController extends AbstractFrontendController $settings = $this->settings->all(); $this->events->fire( - new PrepareUnserializedSettings($settings) + new Deserializing($settings) ); $view->setVariable('settings', $settings); diff --git a/src/Api/Controller/SetSettingsController.php b/src/Api/Controller/SetSettingsController.php index d714ab165..09f23c6eb 100644 --- a/src/Api/Controller/SetSettingsController.php +++ b/src/Api/Controller/SetSettingsController.php @@ -12,8 +12,8 @@ namespace Flarum\Api\Controller; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Event\PrepareSerializedSetting; -use Flarum\Event\SettingWasSet; +use Flarum\Settings\Event\Serializing; +use Flarum\Settings\Event\Saved; use Flarum\Http\Controller\ControllerInterface; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; @@ -53,11 +53,11 @@ class SetSettingsController implements ControllerInterface $settings = $request->getParsedBody(); foreach ($settings as $k => $v) { - $this->dispatcher->fire(new PrepareSerializedSetting($k, $v)); + $this->dispatcher->fire(new Serializing($k, $v)); $this->settings->set($k, $v); - $this->dispatcher->fire(new SettingWasSet($k, $v)); + $this->dispatcher->fire(new Saved($k, $v)); } return new EmptyResponse(204); diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 86ef67d31..4504443b4 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -14,7 +14,7 @@ namespace Flarum\Forum; use Flarum\Event\ConfigureForumRoutes; use Flarum\Event\ExtensionWasDisabled; use Flarum\Event\ExtensionWasEnabled; -use Flarum\Event\SettingWasSet; +use Flarum\Settings\Event\Saved; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Http\Handler\RouteHandlerFactory; use Flarum\Http\RouteCollection; @@ -82,7 +82,7 @@ class ForumServiceProvider extends AbstractServiceProvider protected function flushWebAppAssetsWhenThemeChanged() { - $this->app->make('events')->listen(SettingWasSet::class, function (SettingWasSet $event) { + $this->app->make('events')->listen(Saved::class, function (Saved $event) { if (preg_match('/^theme_|^custom_less$/i', $event->key)) { $this->getWebAppAssets()->flushCss(); } diff --git a/src/Event/PrepareUnserializedSettings.php b/src/Settings/Event/Deserializing.php similarity index 92% rename from src/Event/PrepareUnserializedSettings.php rename to src/Settings/Event/Deserializing.php index f75e27f66..d07bae483 100644 --- a/src/Event/PrepareUnserializedSettings.php +++ b/src/Settings/Event/Deserializing.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Settings\Event; /** * Prepare settings for display in the client. @@ -17,7 +17,7 @@ namespace Flarum\Event; * This event is fired when settings have been retrieved from the database and * are being unserialized for display in the client. */ -class PrepareUnserializedSettings +class Deserializing { /** * The settings array to be unserialized. diff --git a/src/Event/SettingWasSet.php b/src/Settings/Event/Saved.php similarity index 93% rename from src/Event/SettingWasSet.php rename to src/Settings/Event/Saved.php index 7210e2599..216a68411 100644 --- a/src/Event/SettingWasSet.php +++ b/src/Settings/Event/Saved.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Settings\Event; -class SettingWasSet +class Saved { /** * The setting key that was set. diff --git a/src/Event/PrepareSerializedSetting.php b/src/Settings/Event/Serializing.php similarity index 92% rename from src/Event/PrepareSerializedSetting.php rename to src/Settings/Event/Serializing.php index 620ccb404..40643ced1 100644 --- a/src/Event/PrepareSerializedSetting.php +++ b/src/Settings/Event/Serializing.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Settings\Event; -class PrepareSerializedSetting +class Serializing { /** * The settings key being saved. From 33e3d757c3e0a4b05160a46156156c7fcb290296 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 13:19:56 +0200 Subject: [PATCH 16/86] Flatten Flarum\Http namespace --- src/Admin/AdminServiceProvider.php | 2 +- src/Admin/routes.php | 2 +- src/Api/ApiServiceProvider.php | 2 +- src/Api/routes.php | 2 +- src/Event/AbstractConfigureRoutes.php | 4 ++-- src/Forum/ForumServiceProvider.php | 2 +- src/Forum/routes.php | 2 +- src/Http/{Handler => }/ControllerRouteHandler.php | 2 +- src/Http/{Handler => }/RouteHandlerFactory.php | 2 +- src/Install/InstallServiceProvider.php | 2 +- src/Update/UpdateServiceProvider.php | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) rename src/Http/{Handler => }/ControllerRouteHandler.php (98%) rename src/Http/{Handler => }/RouteHandlerFactory.php (95%) diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index 87e784816..8d9b0cda1 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -15,7 +15,7 @@ use Flarum\Event\ExtensionWasDisabled; use Flarum\Event\ExtensionWasEnabled; use Flarum\Settings\Event\Saved; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; class AdminServiceProvider extends AbstractServiceProvider diff --git a/src/Admin/routes.php b/src/Admin/routes.php index 76f1aad4a..f2a04f74b 100644 --- a/src/Admin/routes.php +++ b/src/Admin/routes.php @@ -10,7 +10,7 @@ */ use Flarum\Admin\Controller; -use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; return function (RouteCollection $map, RouteHandlerFactory $route) { diff --git a/src/Api/ApiServiceProvider.php b/src/Api/ApiServiceProvider.php index 24020af42..8e524324f 100644 --- a/src/Api/ApiServiceProvider.php +++ b/src/Api/ApiServiceProvider.php @@ -17,7 +17,7 @@ use Flarum\Api\Serializer\NotificationSerializer; use Flarum\Event\ConfigureApiRoutes; use Flarum\Event\ConfigureNotificationTypes; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; use Tobscure\JsonApi\ErrorHandler; use Tobscure\JsonApi\Exception\Handler\FallbackExceptionHandler; diff --git a/src/Api/routes.php b/src/Api/routes.php index 0203b6131..f394141a7 100644 --- a/src/Api/routes.php +++ b/src/Api/routes.php @@ -10,7 +10,7 @@ */ use Flarum\Api\Controller; -use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; return function (RouteCollection $map, RouteHandlerFactory $route) { diff --git a/src/Event/AbstractConfigureRoutes.php b/src/Event/AbstractConfigureRoutes.php index fbd8d175c..fec628648 100644 --- a/src/Event/AbstractConfigureRoutes.php +++ b/src/Event/AbstractConfigureRoutes.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; abstract class AbstractConfigureRoutes @@ -28,7 +28,7 @@ abstract class AbstractConfigureRoutes /** * @param RouteCollection $routes - * @param RouteHandlerFactory $route + * @param \Flarum\Http\RouteHandlerFactory $route */ public function __construct(RouteCollection $routes, RouteHandlerFactory $route) { diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 4504443b4..69e684c22 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -16,7 +16,7 @@ use Flarum\Event\ExtensionWasDisabled; use Flarum\Event\ExtensionWasEnabled; use Flarum\Settings\Event\Saved; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; class ForumServiceProvider extends AbstractServiceProvider diff --git a/src/Forum/routes.php b/src/Forum/routes.php index 96e26dc3a..028fe37dd 100644 --- a/src/Forum/routes.php +++ b/src/Forum/routes.php @@ -10,7 +10,7 @@ */ use Flarum\Forum\Controller; -use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; return function (RouteCollection $map, RouteHandlerFactory $route) { diff --git a/src/Http/Handler/ControllerRouteHandler.php b/src/Http/ControllerRouteHandler.php similarity index 98% rename from src/Http/Handler/ControllerRouteHandler.php rename to src/Http/ControllerRouteHandler.php index 6e2f4855a..b65e106de 100644 --- a/src/Http/Handler/ControllerRouteHandler.php +++ b/src/Http/ControllerRouteHandler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Http\Handler; +namespace Flarum\Http; use Flarum\Http\Controller\ControllerInterface; use Illuminate\Contracts\Container\Container; diff --git a/src/Http/Handler/RouteHandlerFactory.php b/src/Http/RouteHandlerFactory.php similarity index 95% rename from src/Http/Handler/RouteHandlerFactory.php rename to src/Http/RouteHandlerFactory.php index a225fc2ac..4831bb39c 100644 --- a/src/Http/Handler/RouteHandlerFactory.php +++ b/src/Http/RouteHandlerFactory.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Http\Handler; +namespace Flarum\Http; use Illuminate\Contracts\Container\Container; diff --git a/src/Install/InstallServiceProvider.php b/src/Install/InstallServiceProvider.php index e796f3895..26c089c06 100644 --- a/src/Install/InstallServiceProvider.php +++ b/src/Install/InstallServiceProvider.php @@ -12,7 +12,7 @@ namespace Flarum\Install; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; use Flarum\Install\Prerequisite\Composite; use Flarum\Install\Prerequisite\PhpExtensions; diff --git a/src/Update/UpdateServiceProvider.php b/src/Update/UpdateServiceProvider.php index 17b225f35..f45364230 100644 --- a/src/Update/UpdateServiceProvider.php +++ b/src/Update/UpdateServiceProvider.php @@ -12,7 +12,7 @@ namespace Flarum\Update; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Http\Handler\RouteHandlerFactory; +use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; class UpdateServiceProvider extends AbstractServiceProvider From 6c9ff72efbdd322e64565acbd2008c3bfdba35fe Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 13:25:49 +0200 Subject: [PATCH 17/86] Finalize Flarum\Foundation namespace --- .../ExceptionHandler/ValidationExceptionHandler.php | 2 +- src/Core/Command/ConfirmEmailHandler.php | 4 ++-- src/Core/Command/CreateGroupHandler.php | 4 ++-- src/Core/Command/DeleteAvatarHandler.php | 4 ++-- src/Core/Command/DeleteDiscussionHandler.php | 4 ++-- src/Core/Command/DeleteGroupHandler.php | 4 ++-- src/Core/Command/DeletePostHandler.php | 4 ++-- src/Core/Command/DeleteUserHandler.php | 4 ++-- src/Core/Command/EditDiscussionHandler.php | 4 ++-- src/Core/Command/EditGroupHandler.php | 4 ++-- src/Core/Command/EditPostHandler.php | 4 ++-- src/Core/Command/EditUserHandler.php | 4 ++-- src/Core/Command/PostReplyHandler.php | 4 ++-- src/Core/Command/ReadDiscussionHandler.php | 4 ++-- src/Core/Command/RegisterUserHandler.php | 4 ++-- src/Core/Command/StartDiscussionHandler.php | 4 ++-- src/Core/Command/UploadAvatarHandler.php | 4 ++-- src/Core/Discussion.php | 4 ++-- src/Core/DiscussionState.php | 4 ++-- src/Core/Group.php | 4 ++-- src/Core/Post.php | 4 ++-- src/Core/Validator/DiscussionValidator.php | 2 ++ src/Core/Validator/GroupValidator.php | 2 ++ src/Core/Validator/PostValidator.php | 2 ++ .../Validator => Foundation}/AbstractValidator.php | 6 +++--- .../Support => Foundation}/DispatchEventsTrait.php | 2 +- .../Event/Validating.php} | 10 +++++----- .../Support => Foundation}/EventGeneratorTrait.php | 2 +- .../Exception => Foundation}/ValidationException.php | 2 +- src/User/AvatarValidator.php | 2 +- src/User/User.php | 4 ++-- src/User/UserValidator.php | 2 +- .../Api/Handler/ValidationExceptionHandlerTest.php | 2 +- 33 files changed, 63 insertions(+), 57 deletions(-) rename src/{Core/Validator => Foundation}/AbstractValidator.php (94%) rename src/{Core/Support => Foundation}/DispatchEventsTrait.php (95%) rename src/{Event/ConfigureValidator.php => Foundation/Event/Validating.php} (78%) rename src/{Core/Support => Foundation}/EventGeneratorTrait.php (95%) rename src/{Core/Exception => Foundation}/ValidationException.php (96%) diff --git a/src/Api/ExceptionHandler/ValidationExceptionHandler.php b/src/Api/ExceptionHandler/ValidationExceptionHandler.php index 9a1f77ec1..f36b253fd 100644 --- a/src/Api/ExceptionHandler/ValidationExceptionHandler.php +++ b/src/Api/ExceptionHandler/ValidationExceptionHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Api\ExceptionHandler; use Exception; -use Flarum\Core\Exception\ValidationException; +use Flarum\Foundation\ValidationException; use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface; use Tobscure\JsonApi\Exception\Handler\ResponseBag; diff --git a/src/Core/Command/ConfirmEmailHandler.php b/src/Core/Command/ConfirmEmailHandler.php index f8415792d..b657f1972 100644 --- a/src/Core/Command/ConfirmEmailHandler.php +++ b/src/Core/Command/ConfirmEmailHandler.php @@ -13,12 +13,12 @@ namespace Flarum\Core\Command; use Flarum\User\EmailToken; use Flarum\User\UserRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Illuminate\Contracts\Events\Dispatcher; class ConfirmEmailHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; /** * @var \Flarum\User\UserRepository diff --git a/src/Core/Command/CreateGroupHandler.php b/src/Core/Command/CreateGroupHandler.php index 54d8c3d8c..6c3be8830 100644 --- a/src/Core/Command/CreateGroupHandler.php +++ b/src/Core/Command/CreateGroupHandler.php @@ -14,14 +14,14 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Group; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Core\Validator\GroupValidator; use Flarum\Event\GroupWillBeSaved; use Illuminate\Contracts\Events\Dispatcher; class CreateGroupHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/DeleteAvatarHandler.php b/src/Core/Command/DeleteAvatarHandler.php index aabbe4ddc..00961f741 100644 --- a/src/Core/Command/DeleteAvatarHandler.php +++ b/src/Core/Command/DeleteAvatarHandler.php @@ -14,14 +14,14 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\UserRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Event\AvatarWillBeDeleted; use Illuminate\Contracts\Events\Dispatcher; use League\Flysystem\FilesystemInterface; class DeleteAvatarHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/DeleteDiscussionHandler.php b/src/Core/Command/DeleteDiscussionHandler.php index a02e4609b..459432041 100644 --- a/src/Core/Command/DeleteDiscussionHandler.php +++ b/src/Core/Command/DeleteDiscussionHandler.php @@ -14,13 +14,13 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Repository\DiscussionRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Event\DiscussionWillBeDeleted; use Illuminate\Contracts\Events\Dispatcher; class DeleteDiscussionHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/DeleteGroupHandler.php b/src/Core/Command/DeleteGroupHandler.php index ed849a5be..e3ee47543 100644 --- a/src/Core/Command/DeleteGroupHandler.php +++ b/src/Core/Command/DeleteGroupHandler.php @@ -14,13 +14,13 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Repository\GroupRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Event\GroupWillBeDeleted; use Illuminate\Contracts\Events\Dispatcher; class DeleteGroupHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/DeletePostHandler.php b/src/Core/Command/DeletePostHandler.php index e7697e622..a616dbcc5 100644 --- a/src/Core/Command/DeletePostHandler.php +++ b/src/Core/Command/DeletePostHandler.php @@ -14,13 +14,13 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Repository\PostRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Event\PostWillBeDeleted; use Illuminate\Contracts\Events\Dispatcher; class DeletePostHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/DeleteUserHandler.php b/src/Core/Command/DeleteUserHandler.php index e4503a53d..d5ed6c15f 100644 --- a/src/Core/Command/DeleteUserHandler.php +++ b/src/Core/Command/DeleteUserHandler.php @@ -14,13 +14,13 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\UserRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\Event\Deleting; use Illuminate\Contracts\Events\Dispatcher; class DeleteUserHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/EditDiscussionHandler.php b/src/Core/Command/EditDiscussionHandler.php index b8866bf1f..6f8e7bada 100644 --- a/src/Core/Command/EditDiscussionHandler.php +++ b/src/Core/Command/EditDiscussionHandler.php @@ -14,14 +14,14 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Repository\DiscussionRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Core\Validator\DiscussionValidator; use Flarum\Event\DiscussionWillBeSaved; use Illuminate\Contracts\Events\Dispatcher; class EditDiscussionHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/EditGroupHandler.php b/src/Core/Command/EditGroupHandler.php index 6d1d8ad4f..42fe0e0a7 100644 --- a/src/Core/Command/EditGroupHandler.php +++ b/src/Core/Command/EditGroupHandler.php @@ -15,14 +15,14 @@ use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Group; use Flarum\Core\Repository\GroupRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Core\Validator\GroupValidator; use Flarum\Event\GroupWillBeSaved; use Illuminate\Contracts\Events\Dispatcher; class EditGroupHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/EditPostHandler.php b/src/Core/Command/EditPostHandler.php index 32e607b5b..65707e301 100644 --- a/src/Core/Command/EditPostHandler.php +++ b/src/Core/Command/EditPostHandler.php @@ -14,14 +14,14 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Post\CommentPost; use Flarum\Core\Repository\PostRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Core\Validator\PostValidator; use Flarum\Event\PostWillBeSaved; use Illuminate\Contracts\Events\Dispatcher; class EditPostHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/EditUserHandler.php b/src/Core/Command/EditUserHandler.php index 4ba4a4bff..6071fa1ad 100644 --- a/src/Core/Command/EditUserHandler.php +++ b/src/Core/Command/EditUserHandler.php @@ -13,7 +13,7 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\UserRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\User; use Flarum\User\UserValidator; use Flarum\User\Event\GroupsChanged; @@ -22,7 +22,7 @@ use Illuminate\Contracts\Events\Dispatcher; class EditUserHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/PostReplyHandler.php b/src/Core/Command/PostReplyHandler.php index 06837011b..260116bca 100644 --- a/src/Core/Command/PostReplyHandler.php +++ b/src/Core/Command/PostReplyHandler.php @@ -16,14 +16,14 @@ use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Notification\NotificationSyncer; use Flarum\Core\Post\CommentPost; use Flarum\Core\Repository\DiscussionRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Core\Validator\PostValidator; use Flarum\Event\PostWillBeSaved; use Illuminate\Contracts\Events\Dispatcher; class PostReplyHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/ReadDiscussionHandler.php b/src/Core/Command/ReadDiscussionHandler.php index 9630100a1..0166b1439 100644 --- a/src/Core/Command/ReadDiscussionHandler.php +++ b/src/Core/Command/ReadDiscussionHandler.php @@ -13,13 +13,13 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Repository\DiscussionRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Event\DiscussionStateWillBeSaved; use Illuminate\Contracts\Events\Dispatcher; class ReadDiscussionHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/RegisterUserHandler.php b/src/Core/Command/RegisterUserHandler.php index 2e3a1b158..2c3bdb931 100644 --- a/src/Core/Command/RegisterUserHandler.php +++ b/src/Core/Command/RegisterUserHandler.php @@ -15,7 +15,7 @@ use Exception; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\AuthToken; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\User; use Flarum\User\UserValidator; use Flarum\User\Event\Saving; @@ -33,7 +33,7 @@ use League\Flysystem\MountManager; class RegisterUserHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/StartDiscussionHandler.php b/src/Core/Command/StartDiscussionHandler.php index fa1950259..e3f916f61 100644 --- a/src/Core/Command/StartDiscussionHandler.php +++ b/src/Core/Command/StartDiscussionHandler.php @@ -14,7 +14,7 @@ namespace Flarum\Core\Command; use Exception; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Discussion; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\Core\Validator\DiscussionValidator; use Flarum\Event\DiscussionWillBeSaved; use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher; @@ -22,7 +22,7 @@ use Illuminate\Contracts\Events\Dispatcher as EventDispatcher; class StartDiscussionHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/UploadAvatarHandler.php b/src/Core/Command/UploadAvatarHandler.php index 61fa05601..791090e58 100644 --- a/src/Core/Command/UploadAvatarHandler.php +++ b/src/Core/Command/UploadAvatarHandler.php @@ -14,7 +14,7 @@ namespace Flarum\Core\Command; use Exception; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\UserRepository; -use Flarum\Core\Support\DispatchEventsTrait; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AvatarValidator; use Flarum\Event\AvatarWillBeSaved; use Flarum\Foundation\Application; @@ -29,7 +29,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; class UploadAvatarHandler { - use DispatchEventsTrait; + use Flarum\Foundation\DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Discussion.php b/src/Core/Discussion.php index 39c97bf6d..d22910469 100644 --- a/src/Core/Discussion.php +++ b/src/Core/Discussion.php @@ -12,7 +12,7 @@ namespace Flarum\Core; use Flarum\Core\Post\MergeableInterface; -use Flarum\Core\Support\EventGeneratorTrait; +use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\DiscussionWasDeleted; @@ -55,7 +55,7 @@ use Flarum\Util\Str; */ class Discussion extends AbstractModel { - use EventGeneratorTrait; + use Flarum\Foundation\EventGeneratorTrait; use ScopeVisibilityTrait; /** diff --git a/src/Core/DiscussionState.php b/src/Core/DiscussionState.php index e32e120b4..39ea0e974 100644 --- a/src/Core/DiscussionState.php +++ b/src/Core/DiscussionState.php @@ -11,7 +11,7 @@ namespace Flarum\Core; -use Flarum\Core\Support\EventGeneratorTrait; +use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\AbstractModel; use Flarum\Event\DiscussionWasRead; use Illuminate\Database\Eloquent\Builder; @@ -32,7 +32,7 @@ use Illuminate\Database\Eloquent\Builder; */ class DiscussionState extends AbstractModel { - use EventGeneratorTrait; + use Flarum\Foundation\EventGeneratorTrait; /** * {@inheritdoc} diff --git a/src/Core/Group.php b/src/Core/Group.php index eb05daa5c..f25459f12 100755 --- a/src/Core/Group.php +++ b/src/Core/Group.php @@ -11,7 +11,7 @@ namespace Flarum\Core; -use Flarum\Core\Support\EventGeneratorTrait; +use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\GroupWasCreated; @@ -29,7 +29,7 @@ use Flarum\Event\GroupWasRenamed; */ class Group extends AbstractModel { - use EventGeneratorTrait; + use Flarum\Foundation\EventGeneratorTrait; use ScopeVisibilityTrait; /** diff --git a/src/Core/Post.php b/src/Core/Post.php index f85563965..36d7c5124 100755 --- a/src/Core/Post.php +++ b/src/Core/Post.php @@ -12,7 +12,7 @@ namespace Flarum\Core; use Flarum\Core\Post\RegisteredTypesScope; -use Flarum\Core\Support\EventGeneratorTrait; +use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\PostWasDeleted; @@ -39,7 +39,7 @@ use Illuminate\Database\Eloquent\Builder; */ class Post extends AbstractModel { - use EventGeneratorTrait; + use Flarum\Foundation\EventGeneratorTrait; use ScopeVisibilityTrait; /** diff --git a/src/Core/Validator/DiscussionValidator.php b/src/Core/Validator/DiscussionValidator.php index 7d67fd0a4..2c2a90818 100644 --- a/src/Core/Validator/DiscussionValidator.php +++ b/src/Core/Validator/DiscussionValidator.php @@ -11,6 +11,8 @@ namespace Flarum\Core\Validator; +use Flarum\Foundation\AbstractValidator; + class DiscussionValidator extends AbstractValidator { protected $rules = [ diff --git a/src/Core/Validator/GroupValidator.php b/src/Core/Validator/GroupValidator.php index a66f52dd4..506163f6f 100644 --- a/src/Core/Validator/GroupValidator.php +++ b/src/Core/Validator/GroupValidator.php @@ -11,6 +11,8 @@ namespace Flarum\Core\Validator; +use Flarum\Foundation\AbstractValidator; + class GroupValidator extends AbstractValidator { protected $rules = [ diff --git a/src/Core/Validator/PostValidator.php b/src/Core/Validator/PostValidator.php index 3fe573845..87142c9fd 100644 --- a/src/Core/Validator/PostValidator.php +++ b/src/Core/Validator/PostValidator.php @@ -11,6 +11,8 @@ namespace Flarum\Core\Validator; +use Flarum\Foundation\AbstractValidator; + class PostValidator extends AbstractValidator { protected $rules = [ diff --git a/src/Core/Validator/AbstractValidator.php b/src/Foundation/AbstractValidator.php similarity index 94% rename from src/Core/Validator/AbstractValidator.php rename to src/Foundation/AbstractValidator.php index e1c138ecb..ee1062af5 100644 --- a/src/Core/Validator/AbstractValidator.php +++ b/src/Foundation/AbstractValidator.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Validator; +namespace Flarum\Foundation; -use Flarum\Event\ConfigureValidator; +use Flarum\Foundation\Event\Validating; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Validation\ValidationException; use Illuminate\Validation\Factory; @@ -94,7 +94,7 @@ abstract class AbstractValidator $validator = $this->validator->make($attributes, $rules, $this->getMessages()); $this->events->fire( - new ConfigureValidator($this, $validator) + new Validating($this, $validator) ); return $validator; diff --git a/src/Core/Support/DispatchEventsTrait.php b/src/Foundation/DispatchEventsTrait.php similarity index 95% rename from src/Core/Support/DispatchEventsTrait.php rename to src/Foundation/DispatchEventsTrait.php index c145a8c3d..081bfc64b 100644 --- a/src/Core/Support/DispatchEventsTrait.php +++ b/src/Foundation/DispatchEventsTrait.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Support; +namespace Flarum\Foundation; use Flarum\User\User; use Illuminate\Contracts\Events\Dispatcher; diff --git a/src/Event/ConfigureValidator.php b/src/Foundation/Event/Validating.php similarity index 78% rename from src/Event/ConfigureValidator.php rename to src/Foundation/Event/Validating.php index c9343f761..fc231abc9 100644 --- a/src/Event/ConfigureValidator.php +++ b/src/Foundation/Event/Validating.php @@ -9,20 +9,20 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Foundation\Event; -use Flarum\Core\Validator\AbstractValidator; +use Flarum\Foundation\AbstractValidator; use Illuminate\Validation\Validator; /** - * The `ConfigureModelValidator` event is called when a validator instance for a + * The `Validating` event is called when a validator instance for a * model is being built. This event can be used to add custom rules/extensions * to the validator for when validation takes place. */ -class ConfigureValidator +class Validating { /** - * @var AbstractValidator + * @var \Flarum\Foundation\AbstractValidator */ public $type; diff --git a/src/Core/Support/EventGeneratorTrait.php b/src/Foundation/EventGeneratorTrait.php similarity index 95% rename from src/Core/Support/EventGeneratorTrait.php rename to src/Foundation/EventGeneratorTrait.php index c12402ba5..e24ceda13 100644 --- a/src/Core/Support/EventGeneratorTrait.php +++ b/src/Foundation/EventGeneratorTrait.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Support; +namespace Flarum\Foundation; trait EventGeneratorTrait { diff --git a/src/Core/Exception/ValidationException.php b/src/Foundation/ValidationException.php similarity index 96% rename from src/Core/Exception/ValidationException.php rename to src/Foundation/ValidationException.php index 51c33f653..84cf53084 100644 --- a/src/Core/Exception/ValidationException.php +++ b/src/Foundation/ValidationException.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Exception; +namespace Flarum\Foundation; use Exception; diff --git a/src/User/AvatarValidator.php b/src/User/AvatarValidator.php index b4adcb321..e40ca45f1 100644 --- a/src/User/AvatarValidator.php +++ b/src/User/AvatarValidator.php @@ -11,7 +11,7 @@ namespace Flarum\User; -use Flarum\Core\Validator\AbstractValidator; +use Flarum\Foundation\AbstractValidator; class AvatarValidator extends AbstractValidator { diff --git a/src/User/User.php b/src/User/User.php index 9e4917fc5..80792e0c8 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -16,7 +16,7 @@ use Flarum\User\Gate; use Flarum\Core\Group; use Flarum\Core\Notification; use Flarum\Core\Permission; -use Flarum\Core\Support\EventGeneratorTrait; +use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\CheckUserPassword; @@ -56,7 +56,7 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface; */ class User extends AbstractModel { - use EventGeneratorTrait; + use Flarum\Foundation\EventGeneratorTrait; use ScopeVisibilityTrait; /** diff --git a/src/User/UserValidator.php b/src/User/UserValidator.php index 79d0a08c1..a994a999f 100644 --- a/src/User/UserValidator.php +++ b/src/User/UserValidator.php @@ -11,7 +11,7 @@ namespace Flarum\User; -use Flarum\Core\Validator\AbstractValidator; +use Flarum\Foundation\AbstractValidator; class UserValidator extends AbstractValidator { diff --git a/tests/Flarum/Api/Handler/ValidationExceptionHandlerTest.php b/tests/Flarum/Api/Handler/ValidationExceptionHandlerTest.php index 2d2130cf1..d3440f52f 100644 --- a/tests/Flarum/Api/Handler/ValidationExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/ValidationExceptionHandlerTest.php @@ -13,7 +13,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; use Flarum\Api\ExceptionHandler\ValidationExceptionHandler; -use Flarum\Core\Exception\ValidationException; +use Flarum\Foundation\ValidationException; use Tests\Test\TestCase; class ValidationExceptionHandlerTest extends TestCase From 6cd6a7d2605f07168aad26483edd227da0d254a8 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 13:28:22 +0200 Subject: [PATCH 18/86] Move events to Flarum\Formatter\Event namespace --- .../Event/Configuring.php} | 4 ++-- .../Event/Parsing.php} | 4 ++-- .../Event/Rendering.php} | 4 ++-- src/Formatter/Formatter.php | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) rename src/{Event/ConfigureFormatter.php => Formatter/Event/Configuring.php} (90%) rename src/{Event/ConfigureFormatterParser.php => Formatter/Event/Parsing.php} (92%) rename src/{Event/ConfigureFormatterRenderer.php => Formatter/Event/Rendering.php} (92%) diff --git a/src/Event/ConfigureFormatter.php b/src/Formatter/Event/Configuring.php similarity index 90% rename from src/Event/ConfigureFormatter.php rename to src/Formatter/Event/Configuring.php index 1efd761c8..9d0efeb28 100644 --- a/src/Event/ConfigureFormatter.php +++ b/src/Formatter/Event/Configuring.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Formatter\Event; use s9e\TextFormatter\Configurator; -class ConfigureFormatter +class Configuring { /** * @var Configurator diff --git a/src/Event/ConfigureFormatterParser.php b/src/Formatter/Event/Parsing.php similarity index 92% rename from src/Event/ConfigureFormatterParser.php rename to src/Formatter/Event/Parsing.php index 642ab7a0f..e462021b8 100644 --- a/src/Event/ConfigureFormatterParser.php +++ b/src/Formatter/Event/Parsing.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Formatter\Event; use s9e\TextFormatter\Parser; -class ConfigureFormatterParser +class Parsing { /** * @var Parser diff --git a/src/Event/ConfigureFormatterRenderer.php b/src/Formatter/Event/Rendering.php similarity index 92% rename from src/Event/ConfigureFormatterRenderer.php rename to src/Formatter/Event/Rendering.php index 9c2aced54..97ae53687 100644 --- a/src/Event/ConfigureFormatterRenderer.php +++ b/src/Formatter/Event/Rendering.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Formatter\Event; use s9e\TextFormatter\Renderer; -class ConfigureFormatterRenderer +class Rendering { /** * @var Renderer diff --git a/src/Formatter/Formatter.php b/src/Formatter/Formatter.php index 2de082af9..c080dcc08 100644 --- a/src/Formatter/Formatter.php +++ b/src/Formatter/Formatter.php @@ -11,9 +11,9 @@ namespace Flarum\Formatter; -use Flarum\Event\ConfigureFormatter; -use Flarum\Event\ConfigureFormatterParser; -use Flarum\Event\ConfigureFormatterRenderer; +use Flarum\Formatter\Event\Configuring; +use Flarum\Formatter\Event\Parsing; +use Flarum\Formatter\Event\Rendering; use Illuminate\Contracts\Cache\Repository; use Illuminate\Contracts\Events\Dispatcher; use s9e\TextFormatter\Configurator; @@ -59,7 +59,7 @@ class Formatter { $parser = $this->getParser($context); - $this->events->fire(new ConfigureFormatterParser($parser, $context, $text)); + $this->events->fire(new Parsing($parser, $context, $text)); return $parser->parse($text); } @@ -75,7 +75,7 @@ class Formatter { $renderer = $this->getRenderer($context); - $this->events->fire(new ConfigureFormatterRenderer($renderer, $context, $xml)); + $this->events->fire(new Rendering($renderer, $context, $xml)); return $renderer->render($xml); } @@ -117,7 +117,7 @@ class Formatter $configurator->Autolink; $configurator->tags->onDuplicate('replace'); - $this->events->fire(new ConfigureFormatter($configurator)); + $this->events->fire(new Configuring($configurator)); $this->configureExternalLinks($configurator); From 9abc63aaaca7d899ca2c54557cf848297dd7914d Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 13:31:13 +0200 Subject: [PATCH 19/86] Move events to Flarum\Extension\Event namespace --- src/Admin/AdminServiceProvider.php | 8 ++--- src/Event/ExtensionWasUninstalled.php | 30 ------------------- .../Event/Disabled.php} | 4 +-- .../Event/Disabling.php} | 4 +-- .../Event/Enabled.php} | 4 +-- .../Event/Enabling.php} | 4 +-- src/Extension/Event/Uninstalled.php | 30 +++++++++++++++++++ src/Extension/ExtensionManager.php | 20 ++++++------- src/Formatter/FormatterServiceProvider.php | 8 ++--- src/Forum/ForumServiceProvider.php | 8 ++--- 10 files changed, 60 insertions(+), 60 deletions(-) delete mode 100644 src/Event/ExtensionWasUninstalled.php rename src/{Event/ExtensionWasEnabled.php => Extension/Event/Disabled.php} (90%) rename src/{Event/ExtensionWasDisabled.php => Extension/Event/Disabling.php} (90%) rename src/{Event/ExtensionWillBeEnabled.php => Extension/Event/Enabled.php} (90%) rename src/{Event/ExtensionWillBeDisabled.php => Extension/Event/Enabling.php} (89%) create mode 100644 src/Extension/Event/Uninstalled.php diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index 8d9b0cda1..f394637e2 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -11,8 +11,8 @@ namespace Flarum\Admin; -use Flarum\Event\ExtensionWasDisabled; -use Flarum\Event\ExtensionWasEnabled; +use Flarum\Extension\Event\Disabled; +use Flarum\Extension\Event\Enabled; use Flarum\Settings\Event\Saved; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Http\RouteHandlerFactory; @@ -74,8 +74,8 @@ class AdminServiceProvider extends AbstractServiceProvider { $events = $this->app->make('events'); - $events->listen(ExtensionWasEnabled::class, [$this, 'flushWebAppAssets']); - $events->listen(ExtensionWasDisabled::class, [$this, 'flushWebAppAssets']); + $events->listen(Enabled::class, [$this, 'flushWebAppAssets']); + $events->listen(Disabled::class, [$this, 'flushWebAppAssets']); } public function flushWebAppAssets() diff --git a/src/Event/ExtensionWasUninstalled.php b/src/Event/ExtensionWasUninstalled.php deleted file mode 100644 index 4b50c4a64..000000000 --- a/src/Event/ExtensionWasUninstalled.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Event; - -use Flarum\Extension\Extension; - -class ExtensionWasUninstalled -{ - /** - * @var Extension - */ - public $extension; - - /** - * @param Extension $extension - */ - public function __construct(Extension $extension) - { - $this->extension = $extension; - } -} diff --git a/src/Event/ExtensionWasEnabled.php b/src/Extension/Event/Disabled.php similarity index 90% rename from src/Event/ExtensionWasEnabled.php rename to src/Extension/Event/Disabled.php index d593fad42..4dd56fe97 100644 --- a/src/Event/ExtensionWasEnabled.php +++ b/src/Extension/Event/Disabled.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Extension\Event; use Flarum\Extension\Extension; -class ExtensionWasEnabled +class Disabled { /** * @var Extension diff --git a/src/Event/ExtensionWasDisabled.php b/src/Extension/Event/Disabling.php similarity index 90% rename from src/Event/ExtensionWasDisabled.php rename to src/Extension/Event/Disabling.php index a38bab60b..1660c684f 100644 --- a/src/Event/ExtensionWasDisabled.php +++ b/src/Extension/Event/Disabling.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Extension\Event; use Flarum\Extension\Extension; -class ExtensionWasDisabled +class Disabling { /** * @var Extension diff --git a/src/Event/ExtensionWillBeEnabled.php b/src/Extension/Event/Enabled.php similarity index 90% rename from src/Event/ExtensionWillBeEnabled.php rename to src/Extension/Event/Enabled.php index 6bcaed507..d467b82fe 100644 --- a/src/Event/ExtensionWillBeEnabled.php +++ b/src/Extension/Event/Enabled.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Extension\Event; use Flarum\Extension\Extension; -class ExtensionWillBeEnabled +class Enabled { /** * @var Extension diff --git a/src/Event/ExtensionWillBeDisabled.php b/src/Extension/Event/Enabling.php similarity index 89% rename from src/Event/ExtensionWillBeDisabled.php rename to src/Extension/Event/Enabling.php index e1deddba1..656dcd56f 100644 --- a/src/Event/ExtensionWillBeDisabled.php +++ b/src/Extension/Event/Enabling.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Extension\Event; use Flarum\Extension\Extension; -class ExtensionWillBeDisabled +class Enabling { /** * @var Extension diff --git a/src/Extension/Event/Uninstalled.php b/src/Extension/Event/Uninstalled.php new file mode 100644 index 000000000..647269665 --- /dev/null +++ b/src/Extension/Event/Uninstalled.php @@ -0,0 +1,30 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Extension\Event; + +use Flarum\Extension\Extension; + +class Uninstalled +{ + /** + * @var Extension + */ + public $extension; + + /** + * @param Extension $extension + */ + public function __construct(Extension $extension) + { + $this->extension = $extension; + } +} diff --git a/src/Extension/ExtensionManager.php b/src/Extension/ExtensionManager.php index 69ab289d9..724250aec 100644 --- a/src/Extension/ExtensionManager.php +++ b/src/Extension/ExtensionManager.php @@ -12,11 +12,11 @@ namespace Flarum\Extension; use Flarum\Database\Migrator; -use Flarum\Event\ExtensionWasDisabled; -use Flarum\Event\ExtensionWasEnabled; -use Flarum\Event\ExtensionWasUninstalled; -use Flarum\Event\ExtensionWillBeDisabled; -use Flarum\Event\ExtensionWillBeEnabled; +use Flarum\Extension\Event\Disabled; +use Flarum\Extension\Event\Enabled; +use Flarum\Extension\Event\Uninstalled; +use Flarum\Extension\Event\Disabling; +use Flarum\Extension\Event\Enabling; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; @@ -115,7 +115,7 @@ class ExtensionManager if (! $this->isEnabled($name)) { $extension = $this->getExtension($name); - $this->dispatcher->fire(new ExtensionWillBeEnabled($extension)); + $this->dispatcher->fire(new Enabling($extension)); $enabled = $this->getEnabled(); @@ -129,7 +129,7 @@ class ExtensionManager $extension->setEnabled(true); - $this->dispatcher->fire(new ExtensionWasEnabled($extension)); + $this->dispatcher->fire(new Enabled($extension)); } } @@ -145,7 +145,7 @@ class ExtensionManager if (($k = array_search($name, $enabled)) !== false) { $extension = $this->getExtension($name); - $this->dispatcher->fire(new ExtensionWillBeDisabled($extension)); + $this->dispatcher->fire(new Disabling($extension)); unset($enabled[$k]); @@ -153,7 +153,7 @@ class ExtensionManager $extension->setEnabled(false); - $this->dispatcher->fire(new ExtensionWasDisabled($extension)); + $this->dispatcher->fire(new Disabled($extension)); } } @@ -174,7 +174,7 @@ class ExtensionManager $extension->setInstalled(false); - $this->dispatcher->fire(new ExtensionWasUninstalled($extension)); + $this->dispatcher->fire(new Uninstalled($extension)); } /** diff --git a/src/Formatter/FormatterServiceProvider.php b/src/Formatter/FormatterServiceProvider.php index 60f43bc8f..de07468dd 100644 --- a/src/Formatter/FormatterServiceProvider.php +++ b/src/Formatter/FormatterServiceProvider.php @@ -11,8 +11,8 @@ namespace Flarum\Formatter; -use Flarum\Event\ExtensionWasDisabled; -use Flarum\Event\ExtensionWasEnabled; +use Flarum\Extension\Event\Disabled; +use Flarum\Extension\Event\Enabled; use Flarum\Foundation\AbstractServiceProvider; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Events\Dispatcher; @@ -24,8 +24,8 @@ class FormatterServiceProvider extends AbstractServiceProvider */ public function boot(Dispatcher $events) { - $events->listen(ExtensionWasEnabled::class, [$this, 'flushFormatter']); - $events->listen(ExtensionWasDisabled::class, [$this, 'flushFormatter']); + $events->listen(Enabled::class, [$this, 'flushFormatter']); + $events->listen(Disabled::class, [$this, 'flushFormatter']); } /** diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 69e684c22..8b96164a6 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -12,8 +12,8 @@ namespace Flarum\Forum; use Flarum\Event\ConfigureForumRoutes; -use Flarum\Event\ExtensionWasDisabled; -use Flarum\Event\ExtensionWasEnabled; +use Flarum\Extension\Event\Disabled; +use Flarum\Extension\Event\Enabled; use Flarum\Settings\Event\Saved; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Http\RouteHandlerFactory; @@ -93,8 +93,8 @@ class ForumServiceProvider extends AbstractServiceProvider { $events = $this->app->make('events'); - $events->listen(ExtensionWasEnabled::class, [$this, 'flushWebAppAssets']); - $events->listen(ExtensionWasDisabled::class, [$this, 'flushWebAppAssets']); + $events->listen(Enabled::class, [$this, 'flushWebAppAssets']); + $events->listen(Disabled::class, [$this, 'flushWebAppAssets']); } public function flushWebAppAssets() From 34817988756c225686d42d8d3ccbbf6270d51bf8 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 13:33:42 +0200 Subject: [PATCH 20/86] Fix trait imports --- src/Core/Discussion.php | 2 +- src/Core/DiscussionState.php | 2 +- src/Core/Group.php | 2 +- src/Core/Post.php | 2 +- src/User/User.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Core/Discussion.php b/src/Core/Discussion.php index d22910469..f81ade832 100644 --- a/src/Core/Discussion.php +++ b/src/Core/Discussion.php @@ -55,7 +55,7 @@ use Flarum\Util\Str; */ class Discussion extends AbstractModel { - use Flarum\Foundation\EventGeneratorTrait; + use EventGeneratorTrait; use ScopeVisibilityTrait; /** diff --git a/src/Core/DiscussionState.php b/src/Core/DiscussionState.php index 39ea0e974..15b2e2142 100644 --- a/src/Core/DiscussionState.php +++ b/src/Core/DiscussionState.php @@ -32,7 +32,7 @@ use Illuminate\Database\Eloquent\Builder; */ class DiscussionState extends AbstractModel { - use Flarum\Foundation\EventGeneratorTrait; + use EventGeneratorTrait; /** * {@inheritdoc} diff --git a/src/Core/Group.php b/src/Core/Group.php index f25459f12..53d4da36f 100755 --- a/src/Core/Group.php +++ b/src/Core/Group.php @@ -29,7 +29,7 @@ use Flarum\Event\GroupWasRenamed; */ class Group extends AbstractModel { - use Flarum\Foundation\EventGeneratorTrait; + use EventGeneratorTrait; use ScopeVisibilityTrait; /** diff --git a/src/Core/Post.php b/src/Core/Post.php index 36d7c5124..bb5f0e731 100755 --- a/src/Core/Post.php +++ b/src/Core/Post.php @@ -39,7 +39,7 @@ use Illuminate\Database\Eloquent\Builder; */ class Post extends AbstractModel { - use Flarum\Foundation\EventGeneratorTrait; + use EventGeneratorTrait; use ScopeVisibilityTrait; /** diff --git a/src/User/User.php b/src/User/User.php index 80792e0c8..9849b2d88 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -56,7 +56,7 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface; */ class User extends AbstractModel { - use Flarum\Foundation\EventGeneratorTrait; + use EventGeneratorTrait; use ScopeVisibilityTrait; /** From 66abd7ecfdcfacec9d8876d2f9a0e771f4d6f506 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 13:43:33 +0200 Subject: [PATCH 21/86] Extract new Flarum\Post namespace --- .../Controller/CreateDiscussionController.php | 2 +- src/Api/Controller/CreatePostController.php | 6 ++-- src/Api/Controller/ListPostsController.php | 6 ++-- .../Controller/ShowDiscussionController.php | 4 +-- src/Api/Controller/ShowPostController.php | 6 ++-- .../FloodingExceptionHandler.php | 2 +- src/Api/Serializer/BasicPostSerializer.php | 2 +- src/Api/Serializer/PostSerializer.php | 2 +- src/Core/Command/DeletePostHandler.php | 10 +++--- src/Core/Command/EditPostHandler.php | 16 ++++----- src/Core/Command/PostReplyHandler.php | 10 +++--- src/Core/CoreServiceProvider.php | 9 ++--- src/Core/Discussion.php | 15 ++++---- .../Listener/DiscussionMetadataUpdater.php | 34 +++++++++---------- .../Listener/DiscussionRenamedNotifier.php | 2 +- .../DiscussionRenamedBlueprint.php | 4 +-- .../Search/Discussion/DiscussionSearcher.php | 2 +- src/{Core => }/Post/AbstractEventPost.php | 4 +-- src/{Core => }/Post/CommentPost.php | 19 +++++------ src/{Core => }/Post/DiscussionRenamedPost.php | 4 +-- .../Event/Deleted.php} | 10 +++--- .../Event/Deleting.php} | 10 +++--- .../Event/Hidden.php} | 6 ++-- .../Event/Posted.php} | 10 +++--- .../Event/Restored.php} | 10 +++--- .../Event/Revised.php} | 10 +++--- .../Event/Saving.php} | 10 +++--- .../Exception/FloodingException.php | 2 +- src/{Core => }/Post/Floodgate.php | 7 ++-- src/{Core => }/Post/MergeableInterface.php | 6 ++-- src/{Core => Post}/Post.php | 8 ++--- src/{Core/Access => Post}/PostPolicy.php | 5 ++- .../Repository => Post}/PostRepository.php | 3 +- .../Validator => Post}/PostValidator.php | 2 +- src/{Core => }/Post/RegisteredTypesScope.php | 2 +- src/User/User.php | 6 ++-- src/User/UserMetadataUpdater.php | 32 ++++++++--------- .../Handler/FloodingExceptionHandlerTest.php | 2 +- 38 files changed, 146 insertions(+), 154 deletions(-) rename src/{Core => }/Post/AbstractEventPost.php (93%) rename src/{Core => }/Post/CommentPost.php (90%) rename src/{Core => }/Post/DiscussionRenamedPost.php (97%) rename src/{Event/PostWasPosted.php => Post/Event/Deleted.php} (78%) rename src/{Event/PostWillBeDeleted.php => Post/Event/Deleting.php} (85%) rename src/{Event/PostWasHidden.php => Post/Event/Hidden.php} (87%) rename src/{Event/PostWasDeleted.php => Post/Event/Posted.php} (78%) rename src/{Event/PostWasRestored.php => Post/Event/Restored.php} (76%) rename src/{Event/PostWasRevised.php => Post/Event/Revised.php} (76%) rename src/{Event/PostWillBeSaved.php => Post/Event/Saving.php} (85%) rename src/{Core => Post}/Exception/FloodingException.php (89%) rename src/{Core => }/Post/Floodgate.php (84%) rename src/{Core => }/Post/MergeableInterface.php (91%) rename src/{Core => Post}/Post.php (97%) rename src/{Core/Access => Post}/PostPolicy.php (97%) rename src/{Core/Repository => Post}/PostRepository.php (98%) rename src/{Core/Validator => Post}/PostValidator.php (92%) rename src/{Core => }/Post/RegisteredTypesScope.php (98%) diff --git a/src/Api/Controller/CreateDiscussionController.php b/src/Api/Controller/CreateDiscussionController.php index 6c3c005e7..ab6eb9cde 100644 --- a/src/Api/Controller/CreateDiscussionController.php +++ b/src/Api/Controller/CreateDiscussionController.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Command\ReadDiscussion; use Flarum\Core\Command\StartDiscussion; -use Flarum\Core\Post\Floodgate; +use Flarum\Post\Floodgate; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/CreatePostController.php b/src/Api/Controller/CreatePostController.php index 16ba2a679..a268b7d21 100644 --- a/src/Api/Controller/CreatePostController.php +++ b/src/Api/Controller/CreatePostController.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Command\PostReply; use Flarum\Core\Command\ReadDiscussion; -use Flarum\Core\Post\Floodgate; +use Flarum\Post\Floodgate; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -41,13 +41,13 @@ class CreatePostController extends AbstractCreateController protected $bus; /** - * @var Floodgate + * @var \Flarum\Post\Floodgate */ protected $floodgate; /** * @param Dispatcher $bus - * @param Floodgate $floodgate + * @param \Flarum\Post\Floodgate $floodgate */ public function __construct(Dispatcher $bus, Floodgate $floodgate) { diff --git a/src/Api/Controller/ListPostsController.php b/src/Api/Controller/ListPostsController.php index c50490d07..071dbc41d 100644 --- a/src/Api/Controller/ListPostsController.php +++ b/src/Api/Controller/ListPostsController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\PostRepository; use Flarum\Event\ConfigurePostsQuery; use Illuminate\Database\Eloquent\Builder; use Psr\Http\Message\ServerRequestInterface; @@ -42,12 +42,12 @@ class ListPostsController extends AbstractListController public $sortFields = ['time']; /** - * @var \Flarum\Core\Repository\PostRepository + * @var \Flarum\Post\PostRepository */ protected $posts; /** - * @param \Flarum\Core\Repository\PostRepository $posts + * @param \Flarum\Post\PostRepository $posts */ public function __construct(PostRepository $posts) { diff --git a/src/Api/Controller/ShowDiscussionController.php b/src/Api/Controller/ShowDiscussionController.php index d3417ff8c..171ddc8e4 100644 --- a/src/Api/Controller/ShowDiscussionController.php +++ b/src/Api/Controller/ShowDiscussionController.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Discussion; use Flarum\Core\Repository\DiscussionRepository; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\PostRepository; use Flarum\User\User; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -59,7 +59,7 @@ class ShowDiscussionController extends AbstractShowController /** * @param \Flarum\Core\Repository\DiscussionRepository $discussions - * @param \Flarum\Core\Repository\PostRepository $posts + * @param \Flarum\Post\PostRepository $posts */ public function __construct(DiscussionRepository $discussions, PostRepository $posts) { diff --git a/src/Api/Controller/ShowPostController.php b/src/Api/Controller/ShowPostController.php index 25e2f0e79..49a5f2dec 100644 --- a/src/Api/Controller/ShowPostController.php +++ b/src/Api/Controller/ShowPostController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\PostRepository; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -34,12 +34,12 @@ class ShowPostController extends AbstractShowController ]; /** - * @var \Flarum\Core\Repository\PostRepository + * @var \Flarum\Post\PostRepository */ protected $posts; /** - * @param PostRepository $posts + * @param \Flarum\Post\PostRepository $posts */ public function __construct(PostRepository $posts) { diff --git a/src/Api/ExceptionHandler/FloodingExceptionHandler.php b/src/Api/ExceptionHandler/FloodingExceptionHandler.php index 53b6de082..0a55870dc 100644 --- a/src/Api/ExceptionHandler/FloodingExceptionHandler.php +++ b/src/Api/ExceptionHandler/FloodingExceptionHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Api\ExceptionHandler; use Exception; -use Flarum\Core\Exception\FloodingException; +use Flarum\Post\Exception\FloodingException; use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface; use Tobscure\JsonApi\Exception\Handler\ResponseBag; diff --git a/src/Api/Serializer/BasicPostSerializer.php b/src/Api/Serializer/BasicPostSerializer.php index 2988a6343..2e0a75951 100644 --- a/src/Api/Serializer/BasicPostSerializer.php +++ b/src/Api/Serializer/BasicPostSerializer.php @@ -12,7 +12,7 @@ namespace Flarum\Api\Serializer; use Flarum\Core\Post; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use InvalidArgumentException; class BasicPostSerializer extends AbstractSerializer diff --git a/src/Api/Serializer/PostSerializer.php b/src/Api/Serializer/PostSerializer.php index e385b3533..9f22c5704 100644 --- a/src/Api/Serializer/PostSerializer.php +++ b/src/Api/Serializer/PostSerializer.php @@ -12,7 +12,7 @@ namespace Flarum\Api\Serializer; use Flarum\User\Gate; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; class PostSerializer extends BasicPostSerializer { diff --git a/src/Core/Command/DeletePostHandler.php b/src/Core/Command/DeletePostHandler.php index a616dbcc5..176aa5d3f 100644 --- a/src/Core/Command/DeletePostHandler.php +++ b/src/Core/Command/DeletePostHandler.php @@ -13,9 +13,9 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\PostRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Event\PostWillBeDeleted; +use Flarum\Post\Event\Deleting; use Illuminate\Contracts\Events\Dispatcher; class DeletePostHandler @@ -24,13 +24,13 @@ class DeletePostHandler use AssertPermissionTrait; /** - * @var PostRepository + * @var \Flarum\Post\PostRepository */ protected $posts; /** * @param Dispatcher $events - * @param PostRepository $posts + * @param \Flarum\Post\PostRepository $posts */ public function __construct(Dispatcher $events, PostRepository $posts) { @@ -52,7 +52,7 @@ class DeletePostHandler $this->assertCan($actor, 'delete', $post); $this->events->fire( - new PostWillBeDeleted($post, $actor, $command->data) + new Deleting($post, $actor, $command->data) ); $post->delete(); diff --git a/src/Core/Command/EditPostHandler.php b/src/Core/Command/EditPostHandler.php index 65707e301..af0a52a45 100644 --- a/src/Core/Command/EditPostHandler.php +++ b/src/Core/Command/EditPostHandler.php @@ -12,11 +12,11 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Post\CommentPost; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\CommentPost; +use Flarum\Post\PostRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Core\Validator\PostValidator; -use Flarum\Event\PostWillBeSaved; +use Flarum\Post\PostValidator; +use Flarum\Post\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class EditPostHandler @@ -25,19 +25,19 @@ class EditPostHandler use AssertPermissionTrait; /** - * @var PostRepository + * @var \Flarum\Post\PostRepository */ protected $posts; /** - * @var PostValidator + * @var \Flarum\Post\PostValidator */ protected $validator; /** * @param Dispatcher $events * @param PostRepository $posts - * @param PostValidator $validator + * @param \Flarum\Post\PostValidator $validator */ public function __construct(Dispatcher $events, PostRepository $posts, PostValidator $validator) { @@ -79,7 +79,7 @@ class EditPostHandler } $this->events->fire( - new PostWillBeSaved($post, $actor, $data) + new Saving($post, $actor, $data) ); $this->validator->assertValid($post->getDirty()); diff --git a/src/Core/Command/PostReplyHandler.php b/src/Core/Command/PostReplyHandler.php index 260116bca..a6b327b6d 100644 --- a/src/Core/Command/PostReplyHandler.php +++ b/src/Core/Command/PostReplyHandler.php @@ -14,11 +14,11 @@ namespace Flarum\Core\Command; use DateTime; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Notification\NotificationSyncer; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use Flarum\Core\Repository\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Core\Validator\PostValidator; -use Flarum\Event\PostWillBeSaved; +use Flarum\Post\PostValidator; +use Flarum\Post\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class PostReplyHandler @@ -37,7 +37,7 @@ class PostReplyHandler protected $notifications; /** - * @var PostValidator + * @var \Flarum\Post\PostValidator */ protected $validator; @@ -96,7 +96,7 @@ class PostReplyHandler } $this->events->fire( - new PostWillBeSaved($post, $actor, $command->data) + new Saving($post, $actor, $command->data) ); $this->validator->assertValid($post->getAttributes()); diff --git a/src/Core/CoreServiceProvider.php b/src/Core/CoreServiceProvider.php index d697aba1c..c3234f488 100644 --- a/src/Core/CoreServiceProvider.php +++ b/src/Core/CoreServiceProvider.php @@ -11,11 +11,12 @@ namespace Flarum\Core; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use Flarum\Event\ConfigurePostTypes; use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\GetPermission; use Flarum\Foundation\AbstractServiceProvider; +use Flarum\Post\Post; use Flarum\User\Gate; use Flarum\User\User; use Illuminate\Contracts\Container\Container; @@ -114,7 +115,7 @@ class CoreServiceProvider extends AbstractServiceProvider $events->subscribe('Flarum\Core\Access\DiscussionPolicy'); $events->subscribe('Flarum\Core\Access\GroupPolicy'); - $events->subscribe('Flarum\Core\Access\PostPolicy'); + $events->subscribe('Flarum\Post\PostPolicy'); $events->subscribe('Flarum\User\UserPolicy'); $events->listen(ConfigureUserPreferences::class, [$this, 'configureUserPreferences']); @@ -123,8 +124,8 @@ class CoreServiceProvider extends AbstractServiceProvider public function registerPostTypes() { $models = [ - 'Flarum\Core\Post\CommentPost', - 'Flarum\Core\Post\DiscussionRenamedPost' + 'Flarum\Post\Post\CommentPost', + 'Flarum\Post\Post\DiscussionRenamedPost' ]; $this->app->make('events')->fire( diff --git a/src/Core/Discussion.php b/src/Core/Discussion.php index f81ade832..d185e8440 100644 --- a/src/Core/Discussion.php +++ b/src/Core/Discussion.php @@ -11,7 +11,7 @@ namespace Flarum\Core; -use Flarum\Core\Post\MergeableInterface; +use Flarum\Post\MergeableInterface; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; @@ -20,8 +20,9 @@ use Flarum\Event\DiscussionWasHidden; use Flarum\Event\DiscussionWasRenamed; use Flarum\Event\DiscussionWasRestored; use Flarum\Event\DiscussionWasStarted; -use Flarum\Event\PostWasDeleted; +use Flarum\Post\Event\Deleted; use Flarum\Event\ScopePostVisibility; +use Flarum\Post\Post; use Flarum\User\Guest; use Flarum\User\User; use Flarum\Util\Str; @@ -109,7 +110,7 @@ class Discussion extends AbstractModel $posts = $discussion->posts()->allTypes(); foreach ($posts->get() as $post) { - $discussion->raise(new PostWasDeleted($post)); + $discussion->raise(new Deleted($post)); } $posts->delete(); @@ -272,7 +273,7 @@ class Discussion extends AbstractModel * DiscussionRenamedPost, and delete if the title has been reverted * completely.) * - * @param MergeableInterface $post The post to save. + * @param \Flarum\Post\MergeableInterface $post The post to save. * @return Post The resulting post. It may or may not be the same post as * was originally intended to be saved. It also may not exist, if the * merge logic resulted in deletion. @@ -303,7 +304,7 @@ class Discussion extends AbstractModel */ public function posts() { - return $this->hasMany('Flarum\Core\Post'); + return $this->hasMany('Flarum\Post\Post'); } /** @@ -355,7 +356,7 @@ class Discussion extends AbstractModel */ public function startPost() { - return $this->belongsTo('Flarum\Core\Post', 'start_post_id'); + return $this->belongsTo('Flarum\Post\Post', 'start_post_id'); } /** @@ -375,7 +376,7 @@ class Discussion extends AbstractModel */ public function lastPost() { - return $this->belongsTo('Flarum\Core\Post', 'last_post_id'); + return $this->belongsTo('Flarum\Post\Post', 'last_post_id'); } /** diff --git a/src/Core/Listener/DiscussionMetadataUpdater.php b/src/Core/Listener/DiscussionMetadataUpdater.php index b715e08ae..ea05dba72 100755 --- a/src/Core/Listener/DiscussionMetadataUpdater.php +++ b/src/Core/Listener/DiscussionMetadataUpdater.php @@ -11,11 +11,11 @@ namespace Flarum\Core\Listener; -use Flarum\Core\Post; -use Flarum\Event\PostWasDeleted; -use Flarum\Event\PostWasHidden; -use Flarum\Event\PostWasPosted; -use Flarum\Event\PostWasRestored; +use Flarum\Post\Post; +use Flarum\Post\Event\Deleted; +use Flarum\Post\Event\Hidden; +use Flarum\Post\Event\Posted; +use Flarum\Post\Event\Restored; use Illuminate\Contracts\Events\Dispatcher; class DiscussionMetadataUpdater @@ -25,16 +25,16 @@ class DiscussionMetadataUpdater */ public function subscribe(Dispatcher $events) { - $events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']); - $events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']); - $events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']); - $events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']); + $events->listen(Posted::class, [$this, 'whenPostWasPosted']); + $events->listen(Deleted::class, [$this, 'whenPostWasDeleted']); + $events->listen(Hidden::class, [$this, 'whenPostWasHidden']); + $events->listen(Restored::class, [$this, 'whenPostWasRestored']); } /** - * @param PostWasPosted $event + * @param Posted $event */ - public function whenPostWasPosted(PostWasPosted $event) + public function whenPostWasPosted(Posted $event) { $discussion = $event->post->discussion; @@ -47,9 +47,9 @@ class DiscussionMetadataUpdater } /** - * @param \Flarum\Event\PostWasDeleted $event + * @param \Flarum\Post\Event\Deleted $event */ - public function whenPostWasDeleted(PostWasDeleted $event) + public function whenPostWasDeleted(Deleted $event) { $this->removePost($event->post); @@ -61,17 +61,17 @@ class DiscussionMetadataUpdater } /** - * @param PostWasHidden $event + * @param \Flarum\Post\Event\Hidden $event */ - public function whenPostWasHidden(PostWasHidden $event) + public function whenPostWasHidden(Hidden $event) { $this->removePost($event->post); } /** - * @param PostWasRestored $event + * @param Restored $event */ - public function whenPostWasRestored(PostWasRestored $event) + public function whenPostWasRestored(Restored $event) { $discussion = $event->post->discussion; diff --git a/src/Core/Listener/DiscussionRenamedNotifier.php b/src/Core/Listener/DiscussionRenamedNotifier.php index 61d212d20..1357b1948 100755 --- a/src/Core/Listener/DiscussionRenamedNotifier.php +++ b/src/Core/Listener/DiscussionRenamedNotifier.php @@ -13,7 +13,7 @@ namespace Flarum\Core\Listener; use Flarum\Core\Notification\DiscussionRenamedBlueprint; use Flarum\Core\Notification\NotificationSyncer; -use Flarum\Core\Post\DiscussionRenamedPost; +use Flarum\Post\DiscussionRenamedPost; use Flarum\Event\DiscussionWasRenamed; use Illuminate\Contracts\Events\Dispatcher; diff --git a/src/Core/Notification/DiscussionRenamedBlueprint.php b/src/Core/Notification/DiscussionRenamedBlueprint.php index 5a19d8c7b..b47cac1f9 100644 --- a/src/Core/Notification/DiscussionRenamedBlueprint.php +++ b/src/Core/Notification/DiscussionRenamedBlueprint.php @@ -11,12 +11,12 @@ namespace Flarum\Core\Notification; -use Flarum\Core\Post\DiscussionRenamedPost; +use Flarum\Post\DiscussionRenamedPost; class DiscussionRenamedBlueprint implements BlueprintInterface { /** - * @var DiscussionRenamedPost + * @var \Flarum\Post\DiscussionRenamedPost */ protected $post; diff --git a/src/Core/Search/Discussion/DiscussionSearcher.php b/src/Core/Search/Discussion/DiscussionSearcher.php index b85df3f52..f606d99c2 100644 --- a/src/Core/Search/Discussion/DiscussionSearcher.php +++ b/src/Core/Search/Discussion/DiscussionSearcher.php @@ -13,7 +13,7 @@ namespace Flarum\Core\Search\Discussion; use Flarum\Core\Discussion; use Flarum\Core\Repository\DiscussionRepository; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\PostRepository; use Flarum\Core\Search\ApplySearchParametersTrait; use Flarum\Core\Search\GambitManager; use Flarum\Core\Search\SearchCriteria; diff --git a/src/Core/Post/AbstractEventPost.php b/src/Post/AbstractEventPost.php similarity index 93% rename from src/Core/Post/AbstractEventPost.php rename to src/Post/AbstractEventPost.php index 10d242750..0e949c963 100755 --- a/src/Core/Post/AbstractEventPost.php +++ b/src/Post/AbstractEventPost.php @@ -9,9 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; - -use Flarum\Core\Post; +namespace Flarum\Post; abstract class AbstractEventPost extends Post { diff --git a/src/Core/Post/CommentPost.php b/src/Post/CommentPost.php similarity index 90% rename from src/Core/Post/CommentPost.php rename to src/Post/CommentPost.php index a8016cbb2..e42403b7e 100755 --- a/src/Core/Post/CommentPost.php +++ b/src/Post/CommentPost.php @@ -9,13 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; +namespace Flarum\Post; -use Flarum\Core\Post; -use Flarum\Event\PostWasHidden; -use Flarum\Event\PostWasPosted; -use Flarum\Event\PostWasRestored; -use Flarum\Event\PostWasRevised; +use Flarum\Post\Event\Hidden; +use Flarum\Post\Event\Posted; +use Flarum\Post\Event\Restored; +use Flarum\Post\Event\Revised; use Flarum\Formatter\Formatter; use Flarum\User\User; @@ -61,7 +60,7 @@ class CommentPost extends Post // Set content last, as the parsing may rely on other post attributes. $post->content = $content; - $post->raise(new PostWasPosted($post)); + $post->raise(new Posted($post)); return $post; } @@ -81,7 +80,7 @@ class CommentPost extends Post $this->edit_time = time(); $this->edit_user_id = $actor->id; - $this->raise(new PostWasRevised($this)); + $this->raise(new Revised($this)); } return $this; @@ -99,7 +98,7 @@ class CommentPost extends Post $this->hide_time = time(); $this->hide_user_id = $actor ? $actor->id : null; - $this->raise(new PostWasHidden($this)); + $this->raise(new Hidden($this)); } return $this; @@ -116,7 +115,7 @@ class CommentPost extends Post $this->hide_time = null; $this->hide_user_id = null; - $this->raise(new PostWasRestored($this)); + $this->raise(new Restored($this)); } return $this; diff --git a/src/Core/Post/DiscussionRenamedPost.php b/src/Post/DiscussionRenamedPost.php similarity index 97% rename from src/Core/Post/DiscussionRenamedPost.php rename to src/Post/DiscussionRenamedPost.php index 75cb3f764..21243d902 100755 --- a/src/Core/Post/DiscussionRenamedPost.php +++ b/src/Post/DiscussionRenamedPost.php @@ -9,9 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; - -use Flarum\Core\Post; +namespace Flarum\Post; /** * A post which indicates that a discussion's title was changed. diff --git a/src/Event/PostWasPosted.php b/src/Post/Event/Deleted.php similarity index 78% rename from src/Event/PostWasPosted.php rename to src/Post/Event/Deleted.php index e59bcc0dc..4fba65f8c 100644 --- a/src/Event/PostWasPosted.php +++ b/src/Post/Event/Deleted.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post; +use Flarum\Post\Post; use Flarum\User\User; -class PostWasPosted +class Deleted { /** - * @var \Flarum\Core\Post + * @var \Flarum\Post\Post */ public $post; @@ -27,7 +27,7 @@ class PostWasPosted public $actor; /** - * @param \Flarum\Core\Post $post + * @param \Flarum\Post\Post $post */ public function __construct(Post $post, User $actor = null) { diff --git a/src/Event/PostWillBeDeleted.php b/src/Post/Event/Deleting.php similarity index 85% rename from src/Event/PostWillBeDeleted.php rename to src/Post/Event/Deleting.php index d5b32cae6..899b17997 100644 --- a/src/Event/PostWillBeDeleted.php +++ b/src/Post/Event/Deleting.php @@ -9,17 +9,17 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post; +use Flarum\Post\Post; use Flarum\User\User; -class PostWillBeDeleted +class Deleting { /** * The post that is going to be deleted. * - * @var \Flarum\Core\Post + * @var \Flarum\Post\Post */ public $post; @@ -38,7 +38,7 @@ class PostWillBeDeleted public $data; /** - * @param \Flarum\Core\Post $post + * @param \Flarum\Post\Post $post * @param User $actor * @param array $data */ diff --git a/src/Event/PostWasHidden.php b/src/Post/Event/Hidden.php similarity index 87% rename from src/Event/PostWasHidden.php rename to src/Post/Event/Hidden.php index e41a6a7b3..aeeb104e3 100644 --- a/src/Event/PostWasHidden.php +++ b/src/Post/Event/Hidden.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use Flarum\User\User; -class PostWasHidden +class Hidden { /** * @var CommentPost diff --git a/src/Event/PostWasDeleted.php b/src/Post/Event/Posted.php similarity index 78% rename from src/Event/PostWasDeleted.php rename to src/Post/Event/Posted.php index c98fdb373..9b6ab19c8 100644 --- a/src/Event/PostWasDeleted.php +++ b/src/Post/Event/Posted.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post; +use Flarum\Post\Post; use Flarum\User\User; -class PostWasDeleted +class Posted { /** - * @var \Flarum\Core\Post + * @var \Flarum\Post\Post */ public $post; @@ -27,7 +27,7 @@ class PostWasDeleted public $actor; /** - * @param \Flarum\Core\Post $post + * @param \Flarum\Post\Post $post */ public function __construct(Post $post, User $actor = null) { diff --git a/src/Event/PostWasRestored.php b/src/Post/Event/Restored.php similarity index 76% rename from src/Event/PostWasRestored.php rename to src/Post/Event/Restored.php index 581a6b601..fdd5dc4ae 100644 --- a/src/Event/PostWasRestored.php +++ b/src/Post/Event/Restored.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use Flarum\User\User; -class PostWasRestored +class Restored { /** - * @var CommentPost + * @var \Flarum\Post\CommentPost */ public $post; @@ -27,7 +27,7 @@ class PostWasRestored public $actor; /** - * @param CommentPost $post + * @param \Flarum\Post\CommentPost $post */ public function __construct(CommentPost $post, User $actor = null) { diff --git a/src/Event/PostWasRevised.php b/src/Post/Event/Revised.php similarity index 76% rename from src/Event/PostWasRevised.php rename to src/Post/Event/Revised.php index ddfd2afa0..62d602e0e 100644 --- a/src/Event/PostWasRevised.php +++ b/src/Post/Event/Revised.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use Flarum\User\User; -class PostWasRevised +class Revised { /** - * @var CommentPost + * @var \Flarum\Post\CommentPost */ public $post; @@ -27,7 +27,7 @@ class PostWasRevised public $actor; /** - * @param CommentPost $post + * @param \Flarum\Post\CommentPost $post */ public function __construct(CommentPost $post, User $actor = null) { diff --git a/src/Event/PostWillBeSaved.php b/src/Post/Event/Saving.php similarity index 85% rename from src/Event/PostWillBeSaved.php rename to src/Post/Event/Saving.php index fb1736ab0..f9d2092ea 100644 --- a/src/Event/PostWillBeSaved.php +++ b/src/Post/Event/Saving.php @@ -9,17 +9,17 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post; +use Flarum\Post\Post; use Flarum\User\User; -class PostWillBeSaved +class Saving { /** * The post that will be saved. * - * @var \Flarum\Core\Post + * @var \Flarum\Post\Post */ public $post; @@ -38,7 +38,7 @@ class PostWillBeSaved public $data; /** - * @param \Flarum\Core\Post $post + * @param \Flarum\Post\Post $post * @param User $actor * @param array $data */ diff --git a/src/Core/Exception/FloodingException.php b/src/Post/Exception/FloodingException.php similarity index 89% rename from src/Core/Exception/FloodingException.php rename to src/Post/Exception/FloodingException.php index 9174539b8..f9221b934 100644 --- a/src/Core/Exception/FloodingException.php +++ b/src/Post/Exception/FloodingException.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Exception; +namespace Flarum\Post\Exception; use Exception; diff --git a/src/Core/Post/Floodgate.php b/src/Post/Floodgate.php similarity index 84% rename from src/Core/Post/Floodgate.php rename to src/Post/Floodgate.php index a62811fb1..94cc66d79 100644 --- a/src/Core/Post/Floodgate.php +++ b/src/Post/Floodgate.php @@ -9,18 +9,17 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; +namespace Flarum\Post; use DateTime; -use Flarum\Core\Exception\FloodingException; -use Flarum\Core\Post; +use Flarum\Post\Exception\FloodingException; use Flarum\User\User; class Floodgate { /** * @param User $actor - * @throws FloodingException + * @throws \Flarum\Post\Exception\FloodingException */ public function assertNotFlooding(User $actor) { diff --git a/src/Core/Post/MergeableInterface.php b/src/Post/MergeableInterface.php similarity index 91% rename from src/Core/Post/MergeableInterface.php rename to src/Post/MergeableInterface.php index e1932522e..ea85bca29 100644 --- a/src/Core/Post/MergeableInterface.php +++ b/src/Post/MergeableInterface.php @@ -9,9 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; - -use Flarum\Core\Post; +namespace Flarum\Post; /** * A post that has the ability to be merged into an adjacent post. @@ -26,7 +24,7 @@ interface MergeableInterface * Save the model, given that it is going to appear immediately after the * passed model. * - * @param Post|null $previous + * @param \Flarum\Post\Post|null $previous * @return Post The model resulting after the merge. If the merge is * unsuccessful, this should be the current model instance. Otherwise, * it should be the model that was merged into. diff --git a/src/Core/Post.php b/src/Post/Post.php similarity index 97% rename from src/Core/Post.php rename to src/Post/Post.php index bb5f0e731..ab081b6a6 100755 --- a/src/Core/Post.php +++ b/src/Post/Post.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\Post; -use Flarum\Core\Post\RegisteredTypesScope; +use Flarum\Core\User; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; -use Flarum\Event\PostWasDeleted; +use Flarum\Post\Event\Deleted; use Illuminate\Database\Eloquent\Builder; /** @@ -97,7 +97,7 @@ class Post extends AbstractModel }); static::deleted(function (Post $post) { - $post->raise(new PostWasDeleted($post)); + $post->raise(new Deleted($post)); }); static::addGlobalScope(new RegisteredTypesScope); diff --git a/src/Core/Access/PostPolicy.php b/src/Post/PostPolicy.php similarity index 97% rename from src/Core/Access/PostPolicy.php rename to src/Post/PostPolicy.php index 9e6f5829b..bc63b7ebc 100644 --- a/src/Core/Access/PostPolicy.php +++ b/src/Post/PostPolicy.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Access; +namespace Flarum\Post; use Carbon\Carbon; -use Flarum\Core\Post; use Flarum\Event\ScopePostVisibility; use Flarum\Event\ScopePrivatePostVisibility; use Flarum\Settings\SettingsRepositoryInterface; @@ -58,7 +57,7 @@ class PostPolicy extends AbstractPolicy /** * @param User $actor * @param string $ability - * @param Post $post + * @param \Flarum\Post\Post $post * @return bool|null */ public function after(User $actor, $ability, Post $post) diff --git a/src/Core/Repository/PostRepository.php b/src/Post/PostRepository.php similarity index 98% rename from src/Core/Repository/PostRepository.php rename to src/Post/PostRepository.php index df296e358..b9560be91 100644 --- a/src/Core/Repository/PostRepository.php +++ b/src/Post/PostRepository.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Repository; +namespace Flarum\Post; use Flarum\Core\Discussion; -use Flarum\Core\Post; use Flarum\Event\ScopePostVisibility; use Flarum\User\User; use Illuminate\Database\Eloquent\ModelNotFoundException; diff --git a/src/Core/Validator/PostValidator.php b/src/Post/PostValidator.php similarity index 92% rename from src/Core/Validator/PostValidator.php rename to src/Post/PostValidator.php index 87142c9fd..0306b592f 100644 --- a/src/Core/Validator/PostValidator.php +++ b/src/Post/PostValidator.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Validator; +namespace Flarum\Post; use Flarum\Foundation\AbstractValidator; diff --git a/src/Core/Post/RegisteredTypesScope.php b/src/Post/RegisteredTypesScope.php similarity index 98% rename from src/Core/Post/RegisteredTypesScope.php rename to src/Post/RegisteredTypesScope.php index 35dd977e8..e18945259 100644 --- a/src/Core/Post/RegisteredTypesScope.php +++ b/src/Post/RegisteredTypesScope.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; +namespace Flarum\Post; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; diff --git a/src/User/User.php b/src/User/User.php index 9849b2d88..dfb81d60d 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -21,7 +21,7 @@ use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\CheckUserPassword; use Flarum\Event\ConfigureUserPreferences; -use Flarum\Event\PostWasDeleted; +use Flarum\Post\Event\Deleted; use Flarum\Event\PrepareUserGroups; use Flarum\User\Event\AvatarChanged; use Flarum\User\Event\BioChanged; @@ -136,7 +136,7 @@ class User extends AbstractModel $posts = $user->posts()->allTypes(); foreach ($posts->get() as $post) { - $user->raise(new PostWasDeleted($post)); + $user->raise(new Deleted($post)); } $posts->delete(); @@ -603,7 +603,7 @@ class User extends AbstractModel */ public function posts() { - return $this->hasMany('Flarum\Core\Post'); + return $this->hasMany('Flarum\Post\Post'); } /** diff --git a/src/User/UserMetadataUpdater.php b/src/User/UserMetadataUpdater.php index 3d5e9ad5b..3e8af5404 100755 --- a/src/User/UserMetadataUpdater.php +++ b/src/User/UserMetadataUpdater.php @@ -15,10 +15,10 @@ use Flarum\Core\Discussion; use Flarum\Core\Post; use Flarum\Event\DiscussionWasDeleted; use Flarum\Event\DiscussionWasStarted; -use Flarum\Event\PostWasDeleted; -use Flarum\Event\PostWasHidden; -use Flarum\Event\PostWasPosted; -use Flarum\Event\PostWasRestored; +use Flarum\Post\Event\Deleted; +use Flarum\Post\Event\Hidden; +use Flarum\Post\Event\Posted; +use Flarum\Post\Event\Restored; use Illuminate\Contracts\Events\Dispatcher; class UserMetadataUpdater @@ -28,42 +28,42 @@ class UserMetadataUpdater */ public function subscribe(Dispatcher $events) { - $events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']); - $events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']); - $events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']); - $events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']); + $events->listen(Posted::class, [$this, 'whenPostWasPosted']); + $events->listen(Deleted::class, [$this, 'whenPostWasDeleted']); + $events->listen(Hidden::class, [$this, 'whenPostWasHidden']); + $events->listen(Restored::class, [$this, 'whenPostWasRestored']); $events->listen(DiscussionWasStarted::class, [$this, 'whenDiscussionWasStarted']); $events->listen(DiscussionWasDeleted::class, [$this, 'whenDiscussionWasDeleted']); } /** - * @param PostWasPosted $event + * @param \Flarum\Post\Event\Posted $event */ - public function whenPostWasPosted(PostWasPosted $event) + public function whenPostWasPosted(Posted $event) { $this->updateCommentsCount($event->post, 1); } /** - * @param \Flarum\Event\PostWasDeleted $event + * @param \Flarum\Post\Event\Deleted $event */ - public function whenPostWasDeleted(PostWasDeleted $event) + public function whenPostWasDeleted(Deleted $event) { $this->updateCommentsCount($event->post, -1); } /** - * @param PostWasHidden $event + * @param \Flarum\Post\Event\Hidden $event */ - public function whenPostWasHidden(PostWasHidden $event) + public function whenPostWasHidden(Hidden $event) { $this->updateCommentsCount($event->post, -1); } /** - * @param \Flarum\Event\PostWasRestored $event + * @param \Flarum\Post\Event\Restored $event */ - public function whenPostWasRestored(PostWasRestored $event) + public function whenPostWasRestored(Restored $event) { $this->updateCommentsCount($event->post, 1); } diff --git a/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php b/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php index 6a70a96bc..3abfbeade 100644 --- a/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php @@ -13,7 +13,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; use Flarum\Api\ExceptionHandler\FloodingExceptionHandler; -use Flarum\Core\Exception\FloodingException; +use Flarum\Post\Exception\FloodingException; use Tests\Test\TestCase; class FloodingExceptionHandlerTest extends TestCase From 4fb38d645851f55a99bad265e243db2f7ba31261 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 13:48:04 +0200 Subject: [PATCH 22/86] Extract new Flarum\Discussion namespace --- .../Controller/ListDiscussionsController.php | 2 +- .../ListNotificationsController.php | 2 +- .../Controller/ShowDiscussionController.php | 8 +++---- .../Serializer/BasicDiscussionSerializer.php | 2 +- src/Api/Serializer/DiscussionSerializer.php | 2 +- src/Core/Command/DeleteDiscussionHandler.php | 10 ++++---- src/Core/Command/EditDiscussionHandler.php | 10 ++++---- src/Core/Command/PostReplyHandler.php | 2 +- src/Core/Command/ReadDiscussionHandler.php | 6 ++--- src/Core/Command/StartDiscussionHandler.php | 12 +++++----- src/Core/CoreServiceProvider.php | 6 ++--- src/Core/DiscussionState.php | 7 +++--- src/Core/Notification.php | 2 +- .../DiscussionRenamedBlueprint.php | 2 +- src/Core/Search/SearchServiceProvider.php | 16 ++++++------- src/{Core => Discussion}/Discussion.php | 23 ++++++++++--------- .../DiscussionMetadataUpdater.php | 2 +- .../DiscussionPolicy.php | 8 +++---- .../DiscussionRenamedNotifier.php | 10 ++++---- .../DiscussionRepository.php | 5 ++-- .../DiscussionValidator.php | 2 +- .../Event/Deleted.php} | 10 ++++---- .../Event/Deleting.php} | 6 ++--- .../Event/Hidden.php} | 10 ++++---- .../Event/Renamed.php} | 8 +++---- .../Event/Restored.php} | 10 ++++---- .../Event/Saving.php} | 10 ++++---- .../Event/Started.php} | 10 ++++---- .../Event/UserDataSaving.php} | 4 ++-- .../Event/UserRead.php} | 4 ++-- .../Search}/DiscussionSearch.php | 2 +- .../Search}/DiscussionSearcher.php | 7 +++--- .../Search}/Fulltext/DriverInterface.php | 2 +- .../Search}/Fulltext/MySqlFulltextDriver.php | 2 +- .../Search}/Gambit/AuthorGambit.php | 4 ++-- .../Search}/Gambit/CreatedGambit.php | 4 ++-- .../Search}/Gambit/FulltextGambit.php | 10 ++++---- .../Search}/Gambit/HiddenGambit.php | 4 ++-- .../Search}/Gambit/UnreadGambit.php | 10 ++++---- src/Event/ConfigureDiscussionSearch.php | 2 +- src/Event/ScopePostVisibility.php | 4 ++-- src/Event/ScopePrivatePostVisibility.php | 6 ++--- src/Post/Post.php | 4 ++-- src/Post/PostRepository.php | 2 +- src/User/User.php | 2 +- src/User/UserMetadataUpdater.php | 20 ++++++++-------- 46 files changed, 149 insertions(+), 147 deletions(-) rename src/{Core => Discussion}/Discussion.php (95%) rename src/{Core/Listener => Discussion}/DiscussionMetadataUpdater.php (98%) rename src/{Core/Access => Discussion}/DiscussionPolicy.php (94%) rename src/{Core/Listener => Discussion}/DiscussionRenamedNotifier.php (83%) rename src/{Core/Repository => Discussion}/DiscussionRepository.php (94%) rename src/{Core/Validator => Discussion}/DiscussionValidator.php (93%) rename src/{Event/DiscussionWasDeleted.php => Discussion/Event/Deleted.php} (75%) rename src/{Event/DiscussionWillBeDeleted.php => Discussion/Event/Deleting.php} (91%) rename src/{Event/DiscussionWasStarted.php => Discussion/Event/Hidden.php} (75%) rename src/{Event/DiscussionWasRenamed.php => Discussion/Event/Renamed.php} (83%) rename src/{Event/DiscussionWasRestored.php => Discussion/Event/Restored.php} (75%) rename src/{Event/DiscussionWillBeSaved.php => Discussion/Event/Saving.php} (82%) rename src/{Event/DiscussionWasHidden.php => Discussion/Event/Started.php} (75%) rename src/{Event/DiscussionStateWillBeSaved.php => Discussion/Event/UserDataSaving.php} (89%) rename src/{Event/DiscussionWasRead.php => Discussion/Event/UserRead.php} (90%) rename src/{Core/Search/Discussion => Discussion/Search}/DiscussionSearch.php (96%) rename src/{Core/Search/Discussion => Discussion/Search}/DiscussionSearcher.php (96%) rename src/{Core/Search/Discussion => Discussion/Search}/Fulltext/DriverInterface.php (90%) rename src/{Core/Search/Discussion => Discussion/Search}/Fulltext/MySqlFulltextDriver.php (94%) rename src/{Core/Search/Discussion => Discussion/Search}/Gambit/AuthorGambit.php (93%) rename src/{Core/Search/Discussion => Discussion/Search}/Gambit/CreatedGambit.php (93%) rename src/{Core/Search/Discussion => Discussion/Search}/Gambit/FulltextGambit.php (79%) rename src/{Core/Search/Discussion => Discussion/Search}/Gambit/HiddenGambit.php (91%) rename src/{Core/Search/Discussion => Discussion/Search}/Gambit/UnreadGambit.php (85%) diff --git a/src/Api/Controller/ListDiscussionsController.php b/src/Api/Controller/ListDiscussionsController.php index c39d2d6a4..a1acdb651 100644 --- a/src/Api/Controller/ListDiscussionsController.php +++ b/src/Api/Controller/ListDiscussionsController.php @@ -12,7 +12,7 @@ namespace Flarum\Api\Controller; use Flarum\Api\UrlGenerator; -use Flarum\Core\Search\Discussion\DiscussionSearcher; +use Flarum\Discussion\Search\DiscussionSearcher; use Flarum\Core\Search\SearchCriteria; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/ListNotificationsController.php b/src/Api/Controller/ListNotificationsController.php index c1681d645..c167498fe 100644 --- a/src/Api/Controller/ListNotificationsController.php +++ b/src/Api/Controller/ListNotificationsController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Core\Repository\NotificationRepository; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/ShowDiscussionController.php b/src/Api/Controller/ShowDiscussionController.php index 171ddc8e4..4ee73d225 100644 --- a/src/Api/Controller/ShowDiscussionController.php +++ b/src/Api/Controller/ShowDiscussionController.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Discussion; -use Flarum\Core\Repository\DiscussionRepository; +use Flarum\Discussion\Discussion; +use Flarum\Discussion\DiscussionRepository; use Flarum\Post\PostRepository; use Flarum\User\User; use Psr\Http\Message\ServerRequestInterface; @@ -21,7 +21,7 @@ use Tobscure\JsonApi\Document; class ShowDiscussionController extends AbstractShowController { /** - * @var DiscussionRepository + * @var \Flarum\Discussion\DiscussionRepository */ protected $discussions; @@ -58,7 +58,7 @@ class ShowDiscussionController extends AbstractShowController ]; /** - * @param \Flarum\Core\Repository\DiscussionRepository $discussions + * @param \Flarum\Discussion\DiscussionRepository $discussions * @param \Flarum\Post\PostRepository $posts */ public function __construct(DiscussionRepository $discussions, PostRepository $posts) diff --git a/src/Api/Serializer/BasicDiscussionSerializer.php b/src/Api/Serializer/BasicDiscussionSerializer.php index 1fb175601..a82c9c7b7 100644 --- a/src/Api/Serializer/BasicDiscussionSerializer.php +++ b/src/Api/Serializer/BasicDiscussionSerializer.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Serializer; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use InvalidArgumentException; class BasicDiscussionSerializer extends AbstractSerializer diff --git a/src/Api/Serializer/DiscussionSerializer.php b/src/Api/Serializer/DiscussionSerializer.php index 96704df22..17c43e970 100644 --- a/src/Api/Serializer/DiscussionSerializer.php +++ b/src/Api/Serializer/DiscussionSerializer.php @@ -12,7 +12,7 @@ namespace Flarum\Api\Serializer; use Flarum\User\Gate; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; class DiscussionSerializer extends BasicDiscussionSerializer { diff --git a/src/Core/Command/DeleteDiscussionHandler.php b/src/Core/Command/DeleteDiscussionHandler.php index 459432041..4665db213 100644 --- a/src/Core/Command/DeleteDiscussionHandler.php +++ b/src/Core/Command/DeleteDiscussionHandler.php @@ -13,9 +13,9 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Core\Repository\DiscussionRepository; +use Flarum\Discussion\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Event\DiscussionWillBeDeleted; +use Flarum\Discussion\Event\Deleting; use Illuminate\Contracts\Events\Dispatcher; class DeleteDiscussionHandler @@ -24,7 +24,7 @@ class DeleteDiscussionHandler use AssertPermissionTrait; /** - * @var DiscussionRepository + * @var \Flarum\Discussion\DiscussionRepository */ protected $discussions; @@ -40,7 +40,7 @@ class DeleteDiscussionHandler /** * @param DeleteDiscussion $command - * @return \Flarum\Core\Discussion + * @return \Flarum\Discussion\Discussion * @throws PermissionDeniedException */ public function handle(DeleteDiscussion $command) @@ -52,7 +52,7 @@ class DeleteDiscussionHandler $this->assertCan($actor, 'delete', $discussion); $this->events->fire( - new DiscussionWillBeDeleted($discussion, $actor, $command->data) + new Deleting($discussion, $actor, $command->data) ); $discussion->delete(); diff --git a/src/Core/Command/EditDiscussionHandler.php b/src/Core/Command/EditDiscussionHandler.php index 6f8e7bada..bce27933e 100644 --- a/src/Core/Command/EditDiscussionHandler.php +++ b/src/Core/Command/EditDiscussionHandler.php @@ -13,10 +13,10 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Core\Repository\DiscussionRepository; +use Flarum\Discussion\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Core\Validator\DiscussionValidator; -use Flarum\Event\DiscussionWillBeSaved; +use Flarum\Discussion\DiscussionValidator; +use Flarum\Discussion\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class EditDiscussionHandler @@ -48,7 +48,7 @@ class EditDiscussionHandler /** * @param EditDiscussion $command - * @return \Flarum\Core\Discussion + * @return \Flarum\Discussion\Discussion * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(EditDiscussion $command) @@ -76,7 +76,7 @@ class EditDiscussionHandler } $this->events->fire( - new DiscussionWillBeSaved($discussion, $actor, $data) + new Saving($discussion, $actor, $data) ); $this->validator->assertValid($discussion->getDirty()); diff --git a/src/Core/Command/PostReplyHandler.php b/src/Core/Command/PostReplyHandler.php index a6b327b6d..cb51c4fda 100644 --- a/src/Core/Command/PostReplyHandler.php +++ b/src/Core/Command/PostReplyHandler.php @@ -15,7 +15,7 @@ use DateTime; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Notification\NotificationSyncer; use Flarum\Post\CommentPost; -use Flarum\Core\Repository\DiscussionRepository; +use Flarum\Discussion\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; use Flarum\Post\PostValidator; use Flarum\Post\Event\Saving; diff --git a/src/Core/Command/ReadDiscussionHandler.php b/src/Core/Command/ReadDiscussionHandler.php index 0166b1439..42e4722ea 100644 --- a/src/Core/Command/ReadDiscussionHandler.php +++ b/src/Core/Command/ReadDiscussionHandler.php @@ -12,9 +12,9 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Repository\DiscussionRepository; +use Flarum\Discussion\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Event\DiscussionStateWillBeSaved; +use Flarum\Discussion\Event\UserDataSaving; use Illuminate\Contracts\Events\Dispatcher; class ReadDiscussionHandler @@ -54,7 +54,7 @@ class ReadDiscussionHandler $state->read($command->readNumber); $this->events->fire( - new DiscussionStateWillBeSaved($state) + new UserDataSaving($state) ); $state->save(); diff --git a/src/Core/Command/StartDiscussionHandler.php b/src/Core/Command/StartDiscussionHandler.php index e3f916f61..bad252625 100644 --- a/src/Core/Command/StartDiscussionHandler.php +++ b/src/Core/Command/StartDiscussionHandler.php @@ -13,10 +13,10 @@ namespace Flarum\Core\Command; use Exception; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Core\Validator\DiscussionValidator; -use Flarum\Event\DiscussionWillBeSaved; +use Flarum\Discussion\DiscussionValidator; +use Flarum\Discussion\Event\Saving; use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher; use Illuminate\Contracts\Events\Dispatcher as EventDispatcher; @@ -31,14 +31,14 @@ class StartDiscussionHandler protected $bus; /** - * @var DiscussionValidator + * @var \Flarum\Discussion\DiscussionValidator */ protected $validator; /** * @param EventDispatcher $events * @param BusDispatcher $bus - * @param DiscussionValidator $validator + * @param \Flarum\Discussion\DiscussionValidator $validator */ public function __construct(EventDispatcher $events, BusDispatcher $bus, DiscussionValidator $validator) { @@ -70,7 +70,7 @@ class StartDiscussionHandler ); $this->events->fire( - new DiscussionWillBeSaved($discussion, $actor, $data) + new Saving($discussion, $actor, $data) ); $this->validator->assertValid($discussion->getAttributes()); diff --git a/src/Core/CoreServiceProvider.php b/src/Core/CoreServiceProvider.php index c3234f488..106201d86 100644 --- a/src/Core/CoreServiceProvider.php +++ b/src/Core/CoreServiceProvider.php @@ -107,13 +107,13 @@ class CoreServiceProvider extends AbstractServiceProvider $events = $this->app->make('events'); $events->subscribe('Flarum\Core\Listener\SelfDemotionGuard'); - $events->subscribe('Flarum\Core\Listener\DiscussionMetadataUpdater'); + $events->subscribe('Flarum\Discussion\DiscussionMetadataUpdater'); $events->subscribe('Flarum\User\UserMetadataUpdater'); $events->subscribe('Flarum\Core\Listener\ExtensionValidator'); $events->subscribe('Flarum\User\EmailConfirmationMailer'); - $events->subscribe('Flarum\Core\Listener\DiscussionRenamedNotifier'); + $events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier'); - $events->subscribe('Flarum\Core\Access\DiscussionPolicy'); + $events->subscribe('Flarum\Discussion\DiscussionPolicy'); $events->subscribe('Flarum\Core\Access\GroupPolicy'); $events->subscribe('Flarum\Post\PostPolicy'); $events->subscribe('Flarum\User\UserPolicy'); diff --git a/src/Core/DiscussionState.php b/src/Core/DiscussionState.php index 15b2e2142..be5e246fc 100644 --- a/src/Core/DiscussionState.php +++ b/src/Core/DiscussionState.php @@ -11,9 +11,10 @@ namespace Flarum\Core; +use Flarum\Discussion\Discussion; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\AbstractModel; -use Flarum\Event\DiscussionWasRead; +use Flarum\Discussion\Event\UserRead; use Illuminate\Database\Eloquent\Builder; /** @@ -57,7 +58,7 @@ class DiscussionState extends AbstractModel $this->read_number = $number; $this->read_time = time(); - $this->raise(new DiscussionWasRead($this)); + $this->raise(new UserRead($this)); } return $this; @@ -70,7 +71,7 @@ class DiscussionState extends AbstractModel */ public function discussion() { - return $this->belongsTo('Flarum\Core\Discussion', 'discussion_id'); + return $this->belongsTo('Flarum\Discussion\Discussion', 'discussion_id'); } /** diff --git a/src/Core/Notification.php b/src/Core/Notification.php index 0d429998b..4429cc4b3 100644 --- a/src/Core/Notification.php +++ b/src/Core/Notification.php @@ -56,7 +56,7 @@ class Notification extends AbstractModel * A map of notification types and the model classes to use for their * subjects. For example, the 'discussionRenamed' notification type, which * represents that a user's discussion was renamed, has the subject model - * class 'Flarum\Core\Discussion'. + * class 'Flarum\Discussion\Discussion'. * * @var array */ diff --git a/src/Core/Notification/DiscussionRenamedBlueprint.php b/src/Core/Notification/DiscussionRenamedBlueprint.php index b47cac1f9..b642d82b9 100644 --- a/src/Core/Notification/DiscussionRenamedBlueprint.php +++ b/src/Core/Notification/DiscussionRenamedBlueprint.php @@ -65,6 +65,6 @@ class DiscussionRenamedBlueprint implements BlueprintInterface */ public static function getSubjectModel() { - return 'Flarum\Core\Discussion'; + return 'Flarum\Discussion\Discussion'; } } diff --git a/src/Core/Search/SearchServiceProvider.php b/src/Core/Search/SearchServiceProvider.php index 82172abb4..554a6bd7b 100644 --- a/src/Core/Search/SearchServiceProvider.php +++ b/src/Core/Search/SearchServiceProvider.php @@ -26,8 +26,8 @@ class SearchServiceProvider extends AbstractServiceProvider public function register() { $this->app->bind( - 'Flarum\Core\Search\Discussion\Fulltext\DriverInterface', - 'Flarum\Core\Search\Discussion\Fulltext\MySqlFulltextDriver' + 'Flarum\Discussion\Search\Fulltext\DriverInterface', + 'Flarum\Discussion\Search\Fulltext\MySqlFulltextDriver' ); $this->registerDiscussionGambits(); @@ -56,16 +56,16 @@ class SearchServiceProvider extends AbstractServiceProvider public function registerDiscussionGambits() { - $this->app->when('Flarum\Core\Search\Discussion\DiscussionSearcher') + $this->app->when('Flarum\Discussion\Search\DiscussionSearcher') ->needs('Flarum\Core\Search\GambitManager') ->give(function (Container $app) { $gambits = new GambitManager($app); - $gambits->setFulltextGambit('Flarum\Core\Search\Discussion\Gambit\FulltextGambit'); - $gambits->add('Flarum\Core\Search\Discussion\Gambit\AuthorGambit'); - $gambits->add('Flarum\Core\Search\Discussion\Gambit\CreatedGambit'); - $gambits->add('Flarum\Core\Search\Discussion\Gambit\HiddenGambit'); - $gambits->add('Flarum\Core\Search\Discussion\Gambit\UnreadGambit'); + $gambits->setFulltextGambit('Flarum\Discussion\Search\Gambit\FulltextGambit'); + $gambits->add('Flarum\Discussion\Search\Gambit\AuthorGambit'); + $gambits->add('Flarum\Discussion\Search\Gambit\CreatedGambit'); + $gambits->add('Flarum\Discussion\Search\Gambit\HiddenGambit'); + $gambits->add('Flarum\Discussion\Search\Gambit\UnreadGambit'); $app->make('events')->fire( new ConfigureDiscussionGambits($gambits) diff --git a/src/Core/Discussion.php b/src/Discussion/Discussion.php similarity index 95% rename from src/Core/Discussion.php rename to src/Discussion/Discussion.php index d185e8440..34122fd90 100644 --- a/src/Core/Discussion.php +++ b/src/Discussion/Discussion.php @@ -9,17 +9,18 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\Discussion; +use Flarum\Core\DiscussionState; use Flarum\Post\MergeableInterface; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; -use Flarum\Event\DiscussionWasDeleted; -use Flarum\Event\DiscussionWasHidden; -use Flarum\Event\DiscussionWasRenamed; -use Flarum\Event\DiscussionWasRestored; -use Flarum\Event\DiscussionWasStarted; +use Flarum\Discussion\Event\Deleted; +use Flarum\Discussion\Event\Hidden; +use Flarum\Discussion\Event\Renamed; +use Flarum\Discussion\Event\Restored; +use Flarum\Discussion\Event\Started; use Flarum\Post\Event\Deleted; use Flarum\Event\ScopePostVisibility; use Flarum\Post\Post; @@ -102,7 +103,7 @@ class Discussion extends AbstractModel parent::boot(); static::deleted(function ($discussion) { - $discussion->raise(new DiscussionWasDeleted($discussion)); + $discussion->raise(new Deleted($discussion)); // Delete all of the posts in the discussion. Before we delete them // in a big batch query, we will loop through them and raise a @@ -138,7 +139,7 @@ class Discussion extends AbstractModel $discussion->setRelation('startUser', $user); - $discussion->raise(new DiscussionWasStarted($discussion)); + $discussion->raise(new Started($discussion)); return $discussion; } @@ -155,7 +156,7 @@ class Discussion extends AbstractModel $oldTitle = $this->title; $this->title = $title; - $this->raise(new DiscussionWasRenamed($this, $oldTitle)); + $this->raise(new Renamed($this, $oldTitle)); } return $this; @@ -173,7 +174,7 @@ class Discussion extends AbstractModel $this->hide_time = time(); $this->hide_user_id = $actor ? $actor->id : null; - $this->raise(new DiscussionWasHidden($this)); + $this->raise(new Hidden($this)); } return $this; @@ -190,7 +191,7 @@ class Discussion extends AbstractModel $this->hide_time = null; $this->hide_user_id = null; - $this->raise(new DiscussionWasRestored($this)); + $this->raise(new Restored($this)); } return $this; diff --git a/src/Core/Listener/DiscussionMetadataUpdater.php b/src/Discussion/DiscussionMetadataUpdater.php similarity index 98% rename from src/Core/Listener/DiscussionMetadataUpdater.php rename to src/Discussion/DiscussionMetadataUpdater.php index ea05dba72..123d8d8c0 100755 --- a/src/Core/Listener/DiscussionMetadataUpdater.php +++ b/src/Discussion/DiscussionMetadataUpdater.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Listener; +namespace Flarum\Discussion; use Flarum\Post\Post; use Flarum\Post\Event\Deleted; diff --git a/src/Core/Access/DiscussionPolicy.php b/src/Discussion/DiscussionPolicy.php similarity index 94% rename from src/Core/Access/DiscussionPolicy.php rename to src/Discussion/DiscussionPolicy.php index 50f00a387..b43345727 100644 --- a/src/Core/Access/DiscussionPolicy.php +++ b/src/Discussion/DiscussionPolicy.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Access; +namespace Flarum\Discussion; use Carbon\Carbon; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\Event\ScopeHiddenDiscussionVisibility; use Flarum\Event\ScopePrivateDiscussionVisibility; use Flarum\Settings\SettingsRepositoryInterface; @@ -100,7 +100,7 @@ class DiscussionPolicy extends AbstractPolicy /** * @param User $actor - * @param Discussion $discussion + * @param \Flarum\Discussion\Discussion $discussion * @return bool|null */ public function rename(User $actor, Discussion $discussion) @@ -118,7 +118,7 @@ class DiscussionPolicy extends AbstractPolicy /** * @param User $actor - * @param Discussion $discussion + * @param \Flarum\Discussion\Discussion $discussion * @return bool|null */ public function hide(User $actor, Discussion $discussion) diff --git a/src/Core/Listener/DiscussionRenamedNotifier.php b/src/Discussion/DiscussionRenamedNotifier.php similarity index 83% rename from src/Core/Listener/DiscussionRenamedNotifier.php rename to src/Discussion/DiscussionRenamedNotifier.php index 1357b1948..2cd8bdc9c 100755 --- a/src/Core/Listener/DiscussionRenamedNotifier.php +++ b/src/Discussion/DiscussionRenamedNotifier.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Listener; +namespace Flarum\Discussion; use Flarum\Core\Notification\DiscussionRenamedBlueprint; use Flarum\Core\Notification\NotificationSyncer; use Flarum\Post\DiscussionRenamedPost; -use Flarum\Event\DiscussionWasRenamed; +use Flarum\Discussion\Event\Renamed; use Illuminate\Contracts\Events\Dispatcher; class DiscussionRenamedNotifier @@ -37,13 +37,13 @@ class DiscussionRenamedNotifier */ public function subscribe(Dispatcher $events) { - $events->listen(DiscussionWasRenamed::class, [$this, 'whenDiscussionWasRenamed']); + $events->listen(Renamed::class, [$this, 'whenDiscussionWasRenamed']); } /** - * @param \Flarum\Event\DiscussionWasRenamed $event + * @param \Flarum\Discussion\Event\Renamed $event */ - public function whenDiscussionWasRenamed(DiscussionWasRenamed $event) + public function whenDiscussionWasRenamed(Renamed $event) { $post = DiscussionRenamedPost::reply( $event->discussion->id, diff --git a/src/Core/Repository/DiscussionRepository.php b/src/Discussion/DiscussionRepository.php similarity index 94% rename from src/Core/Repository/DiscussionRepository.php rename to src/Discussion/DiscussionRepository.php index add4f2b30..11c64664a 100644 --- a/src/Core/Repository/DiscussionRepository.php +++ b/src/Discussion/DiscussionRepository.php @@ -9,9 +9,8 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Repository; +namespace Flarum\Discussion; -use Flarum\Core\Discussion; use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Query\Expression; @@ -34,7 +33,7 @@ class DiscussionRepository * * @param int $id * @param User $user - * @return \Flarum\Core\Discussion + * @return \Flarum\Discussion\Discussion */ public function findOrFail($id, User $user = null) { diff --git a/src/Core/Validator/DiscussionValidator.php b/src/Discussion/DiscussionValidator.php similarity index 93% rename from src/Core/Validator/DiscussionValidator.php rename to src/Discussion/DiscussionValidator.php index 2c2a90818..1511cd55d 100644 --- a/src/Core/Validator/DiscussionValidator.php +++ b/src/Discussion/DiscussionValidator.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Validator; +namespace Flarum\Discussion; use Flarum\Foundation\AbstractValidator; diff --git a/src/Event/DiscussionWasDeleted.php b/src/Discussion/Event/Deleted.php similarity index 75% rename from src/Event/DiscussionWasDeleted.php rename to src/Discussion/Event/Deleted.php index f57193918..d4b21bf87 100644 --- a/src/Event/DiscussionWasDeleted.php +++ b/src/Discussion/Event/Deleted.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Discussion\Event; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\User\User; -class DiscussionWasDeleted +class Deleted { /** - * @var Discussion + * @var \Flarum\Discussion\Discussion */ public $discussion; @@ -27,7 +27,7 @@ class DiscussionWasDeleted public $actor; /** - * @param Discussion $discussion + * @param \Flarum\Discussion\Discussion $discussion * @param User $actor */ public function __construct(Discussion $discussion, User $actor = null) diff --git a/src/Event/DiscussionWillBeDeleted.php b/src/Discussion/Event/Deleting.php similarity index 91% rename from src/Event/DiscussionWillBeDeleted.php rename to src/Discussion/Event/Deleting.php index d70e399fe..93f432192 100644 --- a/src/Event/DiscussionWillBeDeleted.php +++ b/src/Discussion/Event/Deleting.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Discussion\Event; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\User\User; -class DiscussionWillBeDeleted +class Deleting { /** * The discussion that is going to be deleted. diff --git a/src/Event/DiscussionWasStarted.php b/src/Discussion/Event/Hidden.php similarity index 75% rename from src/Event/DiscussionWasStarted.php rename to src/Discussion/Event/Hidden.php index b35ed7851..6a2095a74 100644 --- a/src/Event/DiscussionWasStarted.php +++ b/src/Discussion/Event/Hidden.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Discussion\Event; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\User\User; -class DiscussionWasStarted +class Hidden { /** - * @var Discussion + * @var \Flarum\Discussion\Discussion */ public $discussion; @@ -27,7 +27,7 @@ class DiscussionWasStarted public $actor; /** - * @param Discussion $discussion + * @param \Flarum\Discussion\Discussion $discussion * @param User $actor */ public function __construct(Discussion $discussion, User $actor = null) diff --git a/src/Event/DiscussionWasRenamed.php b/src/Discussion/Event/Renamed.php similarity index 83% rename from src/Event/DiscussionWasRenamed.php rename to src/Discussion/Event/Renamed.php index 7d71a20ed..3d06b959b 100644 --- a/src/Event/DiscussionWasRenamed.php +++ b/src/Discussion/Event/Renamed.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Discussion\Event; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\User\User; -class DiscussionWasRenamed +class Renamed { /** * @var Discussion @@ -32,7 +32,7 @@ class DiscussionWasRenamed public $actor; /** - * @param Discussion $discussion + * @param \Flarum\Discussion\Discussion $discussion * @param User $actor * @param string $oldTitle */ diff --git a/src/Event/DiscussionWasRestored.php b/src/Discussion/Event/Restored.php similarity index 75% rename from src/Event/DiscussionWasRestored.php rename to src/Discussion/Event/Restored.php index 22135b6ee..eb276e755 100644 --- a/src/Event/DiscussionWasRestored.php +++ b/src/Discussion/Event/Restored.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Discussion\Event; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\User\User; -class DiscussionWasRestored +class Restored { /** - * @var Discussion + * @var \Flarum\Discussion\Discussion */ public $discussion; @@ -27,7 +27,7 @@ class DiscussionWasRestored public $actor; /** - * @param Discussion $discussion + * @param \Flarum\Discussion\Discussion $discussion * @param User $actor */ public function __construct(Discussion $discussion, User $actor = null) diff --git a/src/Event/DiscussionWillBeSaved.php b/src/Discussion/Event/Saving.php similarity index 82% rename from src/Event/DiscussionWillBeSaved.php rename to src/Discussion/Event/Saving.php index 3d15ff4cc..e6d25a0ae 100644 --- a/src/Event/DiscussionWillBeSaved.php +++ b/src/Discussion/Event/Saving.php @@ -9,17 +9,17 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Discussion\Event; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\User\User; -class DiscussionWillBeSaved +class Saving { /** * The discussion that will be saved. * - * @var Discussion + * @var \Flarum\Discussion\Discussion */ public $discussion; @@ -38,7 +38,7 @@ class DiscussionWillBeSaved public $data; /** - * @param Discussion $discussion + * @param \Flarum\Discussion\Discussion $discussion * @param User $actor * @param array $data */ diff --git a/src/Event/DiscussionWasHidden.php b/src/Discussion/Event/Started.php similarity index 75% rename from src/Event/DiscussionWasHidden.php rename to src/Discussion/Event/Started.php index b99b3e03b..ddb640662 100644 --- a/src/Event/DiscussionWasHidden.php +++ b/src/Discussion/Event/Started.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Discussion\Event; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\User\User; -class DiscussionWasHidden +class Started { /** - * @var Discussion + * @var \Flarum\Discussion\Discussion */ public $discussion; @@ -27,7 +27,7 @@ class DiscussionWasHidden public $actor; /** - * @param Discussion $discussion + * @param \Flarum\Discussion\Discussion $discussion * @param User $actor */ public function __construct(Discussion $discussion, User $actor = null) diff --git a/src/Event/DiscussionStateWillBeSaved.php b/src/Discussion/Event/UserDataSaving.php similarity index 89% rename from src/Event/DiscussionStateWillBeSaved.php rename to src/Discussion/Event/UserDataSaving.php index 05ddd45cc..1574b44b6 100644 --- a/src/Event/DiscussionStateWillBeSaved.php +++ b/src/Discussion/Event/UserDataSaving.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Discussion\Event; use Flarum\Core\DiscussionState; -class DiscussionStateWillBeSaved +class UserDataSaving { /** * @var DiscussionState diff --git a/src/Event/DiscussionWasRead.php b/src/Discussion/Event/UserRead.php similarity index 90% rename from src/Event/DiscussionWasRead.php rename to src/Discussion/Event/UserRead.php index cf8936310..8baf3fc31 100644 --- a/src/Event/DiscussionWasRead.php +++ b/src/Discussion/Event/UserRead.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Discussion\Event; use Flarum\Core\DiscussionState; -class DiscussionWasRead +class UserRead { /** * @var DiscussionState diff --git a/src/Core/Search/Discussion/DiscussionSearch.php b/src/Discussion/Search/DiscussionSearch.php similarity index 96% rename from src/Core/Search/Discussion/DiscussionSearch.php rename to src/Discussion/Search/DiscussionSearch.php index 8b1324cf8..bde618ef1 100644 --- a/src/Core/Search/Discussion/DiscussionSearch.php +++ b/src/Discussion/Search/DiscussionSearch.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\Discussion; +namespace Flarum\Discussion\Search; use Flarum\Core\Search\AbstractSearch; diff --git a/src/Core/Search/Discussion/DiscussionSearcher.php b/src/Discussion/Search/DiscussionSearcher.php similarity index 96% rename from src/Core/Search/Discussion/DiscussionSearcher.php rename to src/Discussion/Search/DiscussionSearcher.php index f606d99c2..aacce651d 100644 --- a/src/Core/Search/Discussion/DiscussionSearcher.php +++ b/src/Discussion/Search/DiscussionSearcher.php @@ -9,10 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\Discussion; +namespace Flarum\Discussion\Search; -use Flarum\Core\Discussion; -use Flarum\Core\Repository\DiscussionRepository; +use Flarum\Discussion\Discussion; +use Flarum\Discussion\DiscussionRepository; +use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Post\PostRepository; use Flarum\Core\Search\ApplySearchParametersTrait; use Flarum\Core\Search\GambitManager; diff --git a/src/Core/Search/Discussion/Fulltext/DriverInterface.php b/src/Discussion/Search/Fulltext/DriverInterface.php similarity index 90% rename from src/Core/Search/Discussion/Fulltext/DriverInterface.php rename to src/Discussion/Search/Fulltext/DriverInterface.php index da90c44a0..bfcd37093 100644 --- a/src/Core/Search/Discussion/Fulltext/DriverInterface.php +++ b/src/Discussion/Search/Fulltext/DriverInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\Discussion\Fulltext; +namespace Flarum\Discussion\Search\Fulltext; interface DriverInterface { diff --git a/src/Core/Search/Discussion/Fulltext/MySqlFulltextDriver.php b/src/Discussion/Search/Fulltext/MySqlFulltextDriver.php similarity index 94% rename from src/Core/Search/Discussion/Fulltext/MySqlFulltextDriver.php rename to src/Discussion/Search/Fulltext/MySqlFulltextDriver.php index 402fefc4c..8c71066d6 100644 --- a/src/Core/Search/Discussion/Fulltext/MySqlFulltextDriver.php +++ b/src/Discussion/Search/Fulltext/MySqlFulltextDriver.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\Discussion\Fulltext; +namespace Flarum\Discussion\Search\Fulltext; use Flarum\Core\Post; diff --git a/src/Core/Search/Discussion/Gambit/AuthorGambit.php b/src/Discussion/Search/Gambit/AuthorGambit.php similarity index 93% rename from src/Core/Search/Discussion/Gambit/AuthorGambit.php rename to src/Discussion/Search/Gambit/AuthorGambit.php index d1336efec..10492e981 100644 --- a/src/Core/Search/Discussion/Gambit/AuthorGambit.php +++ b/src/Discussion/Search/Gambit/AuthorGambit.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\Discussion\Gambit; +namespace Flarum\Discussion\Search\Gambit; use Flarum\User\UserRepository; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; -use Flarum\Core\Search\Discussion\DiscussionSearch; +use Flarum\Discussion\Search\DiscussionSearch; use LogicException; class AuthorGambit extends AbstractRegexGambit diff --git a/src/Core/Search/Discussion/Gambit/CreatedGambit.php b/src/Discussion/Search/Gambit/CreatedGambit.php similarity index 93% rename from src/Core/Search/Discussion/Gambit/CreatedGambit.php rename to src/Discussion/Search/Gambit/CreatedGambit.php index e47bedfc4..244930d45 100644 --- a/src/Core/Search/Discussion/Gambit/CreatedGambit.php +++ b/src/Discussion/Search/Gambit/CreatedGambit.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\Discussion\Gambit; +namespace Flarum\Discussion\Search\Gambit; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; -use Flarum\Core\Search\Discussion\DiscussionSearch; +use Flarum\Discussion\Search\DiscussionSearch; use LogicException; class CreatedGambit extends AbstractRegexGambit diff --git a/src/Core/Search/Discussion/Gambit/FulltextGambit.php b/src/Discussion/Search/Gambit/FulltextGambit.php similarity index 79% rename from src/Core/Search/Discussion/Gambit/FulltextGambit.php rename to src/Discussion/Search/Gambit/FulltextGambit.php index 6531ba915..f28ccf412 100644 --- a/src/Core/Search/Discussion/Gambit/FulltextGambit.php +++ b/src/Discussion/Search/Gambit/FulltextGambit.php @@ -9,23 +9,23 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\Discussion\Gambit; +namespace Flarum\Discussion\Search\Gambit; use Flarum\Core\Search\AbstractSearch; -use Flarum\Core\Search\Discussion\DiscussionSearch; -use Flarum\Core\Search\Discussion\Fulltext\DriverInterface; +use Flarum\Discussion\Search\DiscussionSearch; +use Flarum\Discussion\Search\Fulltext\DriverInterface; use Flarum\Core\Search\GambitInterface; use LogicException; class FulltextGambit implements GambitInterface { /** - * @var DriverInterface + * @var \Flarum\Discussion\Search\Fulltext\DriverInterface */ protected $fulltext; /** - * @param DriverInterface $fulltext + * @param \Flarum\Discussion\Search\Fulltext\DriverInterface $fulltext */ public function __construct(DriverInterface $fulltext) { diff --git a/src/Core/Search/Discussion/Gambit/HiddenGambit.php b/src/Discussion/Search/Gambit/HiddenGambit.php similarity index 91% rename from src/Core/Search/Discussion/Gambit/HiddenGambit.php rename to src/Discussion/Search/Gambit/HiddenGambit.php index c27bf457a..99c544741 100644 --- a/src/Core/Search/Discussion/Gambit/HiddenGambit.php +++ b/src/Discussion/Search/Gambit/HiddenGambit.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\Discussion\Gambit; +namespace Flarum\Discussion\Search\Gambit; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; -use Flarum\Core\Search\Discussion\DiscussionSearch; +use Flarum\Discussion\Search\DiscussionSearch; use LogicException; class HiddenGambit extends AbstractRegexGambit diff --git a/src/Core/Search/Discussion/Gambit/UnreadGambit.php b/src/Discussion/Search/Gambit/UnreadGambit.php similarity index 85% rename from src/Core/Search/Discussion/Gambit/UnreadGambit.php rename to src/Discussion/Search/Gambit/UnreadGambit.php index 9c7890095..29f3b2f10 100644 --- a/src/Core/Search/Discussion/Gambit/UnreadGambit.php +++ b/src/Discussion/Search/Gambit/UnreadGambit.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search\Discussion\Gambit; +namespace Flarum\Discussion\Search\Gambit; -use Flarum\Core\Repository\DiscussionRepository; +use Flarum\Discussion\DiscussionRepository; use Flarum\Core\Search\AbstractRegexGambit; use Flarum\Core\Search\AbstractSearch; -use Flarum\Core\Search\Discussion\DiscussionSearch; +use Flarum\Discussion\Search\DiscussionSearch; use LogicException; class UnreadGambit extends AbstractRegexGambit @@ -25,12 +25,12 @@ class UnreadGambit extends AbstractRegexGambit protected $pattern = 'is:unread'; /** - * @var \Flarum\Core\Repository\DiscussionRepository + * @var \Flarum\Discussion\DiscussionRepository */ protected $discussions; /** - * @param DiscussionRepository $discussions + * @param \Flarum\Discussion\DiscussionRepository $discussions */ public function __construct(DiscussionRepository $discussions) { diff --git a/src/Event/ConfigureDiscussionSearch.php b/src/Event/ConfigureDiscussionSearch.php index 90ff9b1a0..f86d29fea 100644 --- a/src/Event/ConfigureDiscussionSearch.php +++ b/src/Event/ConfigureDiscussionSearch.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\Search\Discussion\DiscussionSearch; +use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Core\Search\SearchCriteria; class ConfigureDiscussionSearch diff --git a/src/Event/ScopePostVisibility.php b/src/Event/ScopePostVisibility.php index 16c488903..d8d2304e2 100644 --- a/src/Event/ScopePostVisibility.php +++ b/src/Event/ScopePostVisibility.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; @@ -21,7 +21,7 @@ use Illuminate\Database\Eloquent\Builder; class ScopePostVisibility { /** - * @var Discussion + * @var \Flarum\Discussion\Discussion */ public $discussion; diff --git a/src/Event/ScopePrivatePostVisibility.php b/src/Event/ScopePrivatePostVisibility.php index 1339e5f27..bb84cda39 100644 --- a/src/Event/ScopePrivatePostVisibility.php +++ b/src/Event/ScopePrivatePostVisibility.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; @@ -21,7 +21,7 @@ use Illuminate\Database\Eloquent\Builder; class ScopePrivatePostVisibility { /** - * @var Discussion + * @var \Flarum\Discussion\Discussion */ public $discussion; @@ -36,7 +36,7 @@ class ScopePrivatePostVisibility public $actor; /** - * @param Discussion $discussion + * @param \Flarum\Discussion\Discussion $discussion * @param Builder $query * @param User $actor */ diff --git a/src/Post/Post.php b/src/Post/Post.php index ab081b6a6..468a708fb 100755 --- a/src/Post/Post.php +++ b/src/Post/Post.php @@ -30,7 +30,7 @@ use Illuminate\Database\Eloquent\Builder; * @property int|null $edit_user_id * @property \Carbon\Carbon|null $hide_time * @property int|null $hide_user_id - * @property \Flarum\Core\Discussion|null $discussion + * @property \Flarum\Discussion\Discussion|null $discussion * @property User|null $user * @property User|null $editUser * @property User|null $hideUser @@ -129,7 +129,7 @@ class Post extends AbstractModel */ public function discussion() { - return $this->belongsTo('Flarum\Core\Discussion', 'discussion_id'); + return $this->belongsTo('Flarum\Discussion\Discussion', 'discussion_id'); } /** diff --git a/src/Post/PostRepository.php b/src/Post/PostRepository.php index b9560be91..a43ce300c 100644 --- a/src/Post/PostRepository.php +++ b/src/Post/PostRepository.php @@ -11,7 +11,7 @@ namespace Flarum\Post; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\Event\ScopePostVisibility; use Flarum\User\User; use Illuminate\Database\Eloquent\ModelNotFoundException; diff --git a/src/User/User.php b/src/User/User.php index dfb81d60d..f85470449 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -613,7 +613,7 @@ class User extends AbstractModel */ public function read() { - return $this->belongsToMany('Flarum\Core\Discussion', 'users_discussions'); + return $this->belongsToMany('Flarum\Discussion\Discussion', 'users_discussions'); } /** diff --git a/src/User/UserMetadataUpdater.php b/src/User/UserMetadataUpdater.php index 3e8af5404..3cf33979a 100755 --- a/src/User/UserMetadataUpdater.php +++ b/src/User/UserMetadataUpdater.php @@ -11,10 +11,10 @@ namespace Flarum\User; -use Flarum\Core\Discussion; +use Flarum\Discussion\Discussion; use Flarum\Core\Post; -use Flarum\Event\DiscussionWasDeleted; -use Flarum\Event\DiscussionWasStarted; +use Flarum\Discussion\Event\Deleted; +use Flarum\Discussion\Event\Started; use Flarum\Post\Event\Deleted; use Flarum\Post\Event\Hidden; use Flarum\Post\Event\Posted; @@ -32,8 +32,8 @@ class UserMetadataUpdater $events->listen(Deleted::class, [$this, 'whenPostWasDeleted']); $events->listen(Hidden::class, [$this, 'whenPostWasHidden']); $events->listen(Restored::class, [$this, 'whenPostWasRestored']); - $events->listen(DiscussionWasStarted::class, [$this, 'whenDiscussionWasStarted']); - $events->listen(DiscussionWasDeleted::class, [$this, 'whenDiscussionWasDeleted']); + $events->listen(Started::class, [$this, 'whenDiscussionWasStarted']); + $events->listen(Deleted::class, [$this, 'whenDiscussionWasDeleted']); } /** @@ -69,17 +69,17 @@ class UserMetadataUpdater } /** - * @param \Flarum\Event\DiscussionWasStarted $event + * @param \Flarum\Discussion\Event\Started $event */ - public function whenDiscussionWasStarted(DiscussionWasStarted $event) + public function whenDiscussionWasStarted(Started $event) { $this->updateDiscussionsCount($event->discussion, 1); } /** - * @param \Flarum\Event\DiscussionWasDeleted $event + * @param \Flarum\Discussion\Event\Deleted $event */ - public function whenDiscussionWasDeleted(DiscussionWasDeleted $event) + public function whenDiscussionWasDeleted(Deleted $event) { $this->updateDiscussionsCount($event->discussion, -1); } @@ -99,7 +99,7 @@ class UserMetadataUpdater } /** - * @param Discussion $discussion + * @param \Flarum\Discussion\Discussion $discussion * @param int $amount */ protected function updateDiscussionsCount(Discussion $discussion, $amount) From 11bf3e34b72d1a264f91982c899480b213642879 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 13:59:50 +0200 Subject: [PATCH 23/86] Extract Flarum\Search namespace --- .../Controller/ListDiscussionsController.php | 2 +- src/Api/Controller/ListUsersController.php | 2 +- src/Core/CoreServiceProvider.php | 2 +- src/Discussion/Search/DiscussionSearch.php | 2 +- src/Discussion/Search/DiscussionSearcher.php | 20 +++++++++---------- src/Discussion/Search/Gambit/AuthorGambit.php | 4 ++-- .../Search/Gambit/CreatedGambit.php | 4 ++-- .../Search/Gambit/FulltextGambit.php | 4 ++-- src/Discussion/Search/Gambit/HiddenGambit.php | 4 ++-- src/Discussion/Search/Gambit/UnreadGambit.php | 4 ++-- src/Event/AbstractConfigureGambits.php | 4 ++-- src/Event/ConfigureDiscussionSearch.php | 6 +++--- src/Event/ConfigureUserSearch.php | 2 +- src/{Core => }/Search/AbstractRegexGambit.php | 2 +- src/{Core => }/Search/AbstractSearch.php | 2 +- .../Search/ApplySearchParametersTrait.php | 2 +- src/{Core => }/Search/GambitInterface.php | 2 +- src/{Core => }/Search/GambitManager.php | 2 +- src/{Core => }/Search/SearchCriteria.php | 2 +- src/{Core => }/Search/SearchResults.php | 2 +- .../Search/SearchServiceProvider.php | 6 +++--- src/User/Search/Gambit/EmailGambit.php | 4 ++-- src/User/Search/Gambit/FulltextGambit.php | 4 ++-- src/User/Search/Gambit/GroupGambit.php | 4 ++-- src/User/Search/UserSearch.php | 2 +- src/User/Search/UserSearcher.php | 20 +++++++++---------- 26 files changed, 57 insertions(+), 57 deletions(-) rename src/{Core => }/Search/AbstractRegexGambit.php (97%) rename src/{Core => }/Search/AbstractSearch.php (98%) rename src/{Core => }/Search/ApplySearchParametersTrait.php (97%) rename src/{Core => }/Search/GambitInterface.php (95%) rename src/{Core => }/Search/GambitManager.php (99%) rename src/{Core => }/Search/SearchCriteria.php (97%) rename src/{Core => }/Search/SearchResults.php (96%) rename src/{Core => }/Search/SearchServiceProvider.php (94%) diff --git a/src/Api/Controller/ListDiscussionsController.php b/src/Api/Controller/ListDiscussionsController.php index a1acdb651..d69e07de6 100644 --- a/src/Api/Controller/ListDiscussionsController.php +++ b/src/Api/Controller/ListDiscussionsController.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Controller; use Flarum\Api\UrlGenerator; use Flarum\Discussion\Search\DiscussionSearcher; -use Flarum\Core\Search\SearchCriteria; +use Flarum\Search\SearchCriteria; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/ListUsersController.php b/src/Api/Controller/ListUsersController.php index 7d1f6526f..1dadbb103 100644 --- a/src/Api/Controller/ListUsersController.php +++ b/src/Api/Controller/ListUsersController.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Controller; use Flarum\Api\UrlGenerator; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Core\Search\SearchCriteria; +use Flarum\Search\SearchCriteria; use Flarum\Core\User\Search\UserSearcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Core/CoreServiceProvider.php b/src/Core/CoreServiceProvider.php index 106201d86..088733ce8 100644 --- a/src/Core/CoreServiceProvider.php +++ b/src/Core/CoreServiceProvider.php @@ -41,7 +41,7 @@ class CoreServiceProvider extends AbstractServiceProvider $this->registerAvatarsFilesystem(); $this->app->register('Flarum\Core\Notification\NotificationServiceProvider'); - $this->app->register('Flarum\Core\Search\SearchServiceProvider'); + $this->app->register('Flarum\Search\SearchServiceProvider'); $this->app->register('Flarum\Formatter\FormatterServiceProvider'); } diff --git a/src/Discussion/Search/DiscussionSearch.php b/src/Discussion/Search/DiscussionSearch.php index bde618ef1..8cb886e29 100644 --- a/src/Discussion/Search/DiscussionSearch.php +++ b/src/Discussion/Search/DiscussionSearch.php @@ -11,7 +11,7 @@ namespace Flarum\Discussion\Search; -use Flarum\Core\Search\AbstractSearch; +use Flarum\Search\AbstractSearch; /** * An object which represents the internal state of a search for discussions: diff --git a/src/Discussion/Search/DiscussionSearcher.php b/src/Discussion/Search/DiscussionSearcher.php index aacce651d..81ac2803a 100644 --- a/src/Discussion/Search/DiscussionSearcher.php +++ b/src/Discussion/Search/DiscussionSearcher.php @@ -15,10 +15,10 @@ use Flarum\Discussion\Discussion; use Flarum\Discussion\DiscussionRepository; use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Post\PostRepository; -use Flarum\Core\Search\ApplySearchParametersTrait; -use Flarum\Core\Search\GambitManager; -use Flarum\Core\Search\SearchCriteria; -use Flarum\Core\Search\SearchResults; +use Flarum\Search\ApplySearchParametersTrait; +use Flarum\Search\GambitManager; +use Flarum\Search\SearchCriteria; +use Flarum\Search\SearchResults; use Flarum\Event\ConfigureDiscussionSearch; use Illuminate\Database\Eloquent\Collection; @@ -31,7 +31,7 @@ class DiscussionSearcher use ApplySearchParametersTrait; /** - * @var GambitManager + * @var \Flarum\Search\GambitManager */ protected $gambits; @@ -46,7 +46,7 @@ class DiscussionSearcher protected $posts; /** - * @param GambitManager $gambits + * @param \Flarum\Search\GambitManager $gambits * @param DiscussionRepository $discussions * @param PostRepository $posts */ @@ -61,13 +61,13 @@ class DiscussionSearcher } /** - * @param SearchCriteria $criteria + * @param \Flarum\Search\SearchCriteria $criteria * @param int|null $limit * @param int $offset * @param array $load An array of relationships to load on the results. - * @return SearchResults + * @return \Flarum\Search\SearchResults */ - public function search(SearchCriteria $criteria, $limit = null, $offset = 0, array $load = []) + public function search(\Flarum\Search\SearchCriteria $criteria, $limit = null, $offset = 0, array $load = []) { $actor = $criteria->actor; @@ -110,7 +110,7 @@ class DiscussionSearcher Discussion::setStateUser($actor); $discussions->load($load); - return new SearchResults($discussions, $areMoreResults); + return new \Flarum\Search\SearchResults($discussions, $areMoreResults); } /** diff --git a/src/Discussion/Search/Gambit/AuthorGambit.php b/src/Discussion/Search/Gambit/AuthorGambit.php index 10492e981..15e425512 100644 --- a/src/Discussion/Search/Gambit/AuthorGambit.php +++ b/src/Discussion/Search/Gambit/AuthorGambit.php @@ -12,8 +12,8 @@ namespace Flarum\Discussion\Search\Gambit; use Flarum\User\UserRepository; -use Flarum\Core\Search\AbstractRegexGambit; -use Flarum\Core\Search\AbstractSearch; +use Flarum\Search\AbstractRegexGambit; +use Flarum\Search\AbstractSearch; use Flarum\Discussion\Search\DiscussionSearch; use LogicException; diff --git a/src/Discussion/Search/Gambit/CreatedGambit.php b/src/Discussion/Search/Gambit/CreatedGambit.php index 244930d45..0b38fec35 100644 --- a/src/Discussion/Search/Gambit/CreatedGambit.php +++ b/src/Discussion/Search/Gambit/CreatedGambit.php @@ -11,8 +11,8 @@ namespace Flarum\Discussion\Search\Gambit; -use Flarum\Core\Search\AbstractRegexGambit; -use Flarum\Core\Search\AbstractSearch; +use Flarum\Search\AbstractRegexGambit; +use Flarum\Search\AbstractSearch; use Flarum\Discussion\Search\DiscussionSearch; use LogicException; diff --git a/src/Discussion/Search/Gambit/FulltextGambit.php b/src/Discussion/Search/Gambit/FulltextGambit.php index f28ccf412..da54f358f 100644 --- a/src/Discussion/Search/Gambit/FulltextGambit.php +++ b/src/Discussion/Search/Gambit/FulltextGambit.php @@ -11,10 +11,10 @@ namespace Flarum\Discussion\Search\Gambit; -use Flarum\Core\Search\AbstractSearch; +use Flarum\Search\AbstractSearch; use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Discussion\Search\Fulltext\DriverInterface; -use Flarum\Core\Search\GambitInterface; +use Flarum\Search\GambitInterface; use LogicException; class FulltextGambit implements GambitInterface diff --git a/src/Discussion/Search/Gambit/HiddenGambit.php b/src/Discussion/Search/Gambit/HiddenGambit.php index 99c544741..9bd1c7b24 100644 --- a/src/Discussion/Search/Gambit/HiddenGambit.php +++ b/src/Discussion/Search/Gambit/HiddenGambit.php @@ -11,8 +11,8 @@ namespace Flarum\Discussion\Search\Gambit; -use Flarum\Core\Search\AbstractRegexGambit; -use Flarum\Core\Search\AbstractSearch; +use Flarum\Search\AbstractRegexGambit; +use Flarum\Search\AbstractSearch; use Flarum\Discussion\Search\DiscussionSearch; use LogicException; diff --git a/src/Discussion/Search/Gambit/UnreadGambit.php b/src/Discussion/Search/Gambit/UnreadGambit.php index 29f3b2f10..87eb7cfe2 100644 --- a/src/Discussion/Search/Gambit/UnreadGambit.php +++ b/src/Discussion/Search/Gambit/UnreadGambit.php @@ -12,8 +12,8 @@ namespace Flarum\Discussion\Search\Gambit; use Flarum\Discussion\DiscussionRepository; -use Flarum\Core\Search\AbstractRegexGambit; -use Flarum\Core\Search\AbstractSearch; +use Flarum\Search\AbstractRegexGambit; +use Flarum\Search\AbstractSearch; use Flarum\Discussion\Search\DiscussionSearch; use LogicException; diff --git a/src/Event/AbstractConfigureGambits.php b/src/Event/AbstractConfigureGambits.php index 1889ea861..0513eba48 100644 --- a/src/Event/AbstractConfigureGambits.php +++ b/src/Event/AbstractConfigureGambits.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\Search\GambitManager; +use Flarum\Search\GambitManager; abstract class AbstractConfigureGambits { @@ -21,7 +21,7 @@ abstract class AbstractConfigureGambits public $gambits; /** - * @param GambitManager $gambits + * @param \Flarum\Search\GambitManager $gambits */ public function __construct(GambitManager $gambits) { diff --git a/src/Event/ConfigureDiscussionSearch.php b/src/Event/ConfigureDiscussionSearch.php index f86d29fea..2b126046e 100644 --- a/src/Event/ConfigureDiscussionSearch.php +++ b/src/Event/ConfigureDiscussionSearch.php @@ -12,7 +12,7 @@ namespace Flarum\Event; use Flarum\Discussion\Search\DiscussionSearch; -use Flarum\Core\Search\SearchCriteria; +use Flarum\Search\SearchCriteria; class ConfigureDiscussionSearch { @@ -22,13 +22,13 @@ class ConfigureDiscussionSearch public $search; /** - * @var SearchCriteria + * @var \Flarum\Search\SearchCriteria */ public $criteria; /** * @param DiscussionSearch $search - * @param SearchCriteria $criteria + * @param \Flarum\Search\SearchCriteria $criteria */ public function __construct(DiscussionSearch $search, SearchCriteria $criteria) { diff --git a/src/Event/ConfigureUserSearch.php b/src/Event/ConfigureUserSearch.php index d32670705..309f60c10 100644 --- a/src/Event/ConfigureUserSearch.php +++ b/src/Event/ConfigureUserSearch.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\Search\SearchCriteria; +use Flarum\Search\SearchCriteria; use Flarum\Core\User\Search\UserSearch; class ConfigureUserSearch diff --git a/src/Core/Search/AbstractRegexGambit.php b/src/Search/AbstractRegexGambit.php similarity index 97% rename from src/Core/Search/AbstractRegexGambit.php rename to src/Search/AbstractRegexGambit.php index b15a83ddf..4771783a6 100644 --- a/src/Core/Search/AbstractRegexGambit.php +++ b/src/Search/AbstractRegexGambit.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search; +namespace Flarum\Search; abstract class AbstractRegexGambit implements GambitInterface { diff --git a/src/Core/Search/AbstractSearch.php b/src/Search/AbstractSearch.php similarity index 98% rename from src/Core/Search/AbstractSearch.php rename to src/Search/AbstractSearch.php index c4f54250d..23e7c4b78 100644 --- a/src/Core/Search/AbstractSearch.php +++ b/src/Search/AbstractSearch.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search; +namespace Flarum\Search; use Flarum\User\User; use Illuminate\Database\Query\Builder; diff --git a/src/Core/Search/ApplySearchParametersTrait.php b/src/Search/ApplySearchParametersTrait.php similarity index 97% rename from src/Core/Search/ApplySearchParametersTrait.php rename to src/Search/ApplySearchParametersTrait.php index 4854eefb5..58691946c 100644 --- a/src/Core/Search/ApplySearchParametersTrait.php +++ b/src/Search/ApplySearchParametersTrait.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search; +namespace Flarum\Search; trait ApplySearchParametersTrait { diff --git a/src/Core/Search/GambitInterface.php b/src/Search/GambitInterface.php similarity index 95% rename from src/Core/Search/GambitInterface.php rename to src/Search/GambitInterface.php index 7ecb13fda..bcc9f4c9f 100644 --- a/src/Core/Search/GambitInterface.php +++ b/src/Search/GambitInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search; +namespace Flarum\Search; interface GambitInterface { diff --git a/src/Core/Search/GambitManager.php b/src/Search/GambitManager.php similarity index 99% rename from src/Core/Search/GambitManager.php rename to src/Search/GambitManager.php index 6a912f14f..391b42f0c 100644 --- a/src/Core/Search/GambitManager.php +++ b/src/Search/GambitManager.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search; +namespace Flarum\Search; use Illuminate\Contracts\Container\Container; use LogicException; diff --git a/src/Core/Search/SearchCriteria.php b/src/Search/SearchCriteria.php similarity index 97% rename from src/Core/Search/SearchCriteria.php rename to src/Search/SearchCriteria.php index 567155d8b..be5d598b0 100644 --- a/src/Core/Search/SearchCriteria.php +++ b/src/Search/SearchCriteria.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search; +namespace Flarum\Search; use Flarum\User\User; diff --git a/src/Core/Search/SearchResults.php b/src/Search/SearchResults.php similarity index 96% rename from src/Core/Search/SearchResults.php rename to src/Search/SearchResults.php index 1d85b67e3..d7841320b 100644 --- a/src/Core/Search/SearchResults.php +++ b/src/Search/SearchResults.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search; +namespace Flarum\Search; use Illuminate\Database\Eloquent\Collection; diff --git a/src/Core/Search/SearchServiceProvider.php b/src/Search/SearchServiceProvider.php similarity index 94% rename from src/Core/Search/SearchServiceProvider.php rename to src/Search/SearchServiceProvider.php index 554a6bd7b..9b2ded54b 100644 --- a/src/Core/Search/SearchServiceProvider.php +++ b/src/Search/SearchServiceProvider.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Search; +namespace Flarum\Search; use Flarum\Event\ConfigureDiscussionGambits; use Flarum\Event\ConfigureUserGambits; @@ -38,7 +38,7 @@ class SearchServiceProvider extends AbstractServiceProvider public function registerUserGambits() { $this->app->when('Flarum\Core\User\Search\UserSearcher') - ->needs('Flarum\Core\Search\GambitManager') + ->needs('Flarum\Search\GambitManager') ->give(function (Container $app) { $gambits = new GambitManager($app); @@ -57,7 +57,7 @@ class SearchServiceProvider extends AbstractServiceProvider public function registerDiscussionGambits() { $this->app->when('Flarum\Discussion\Search\DiscussionSearcher') - ->needs('Flarum\Core\Search\GambitManager') + ->needs('Flarum\Search\GambitManager') ->give(function (Container $app) { $gambits = new GambitManager($app); diff --git a/src/User/Search/Gambit/EmailGambit.php b/src/User/Search/Gambit/EmailGambit.php index 11b0b793a..3d12c02ed 100644 --- a/src/User/Search/Gambit/EmailGambit.php +++ b/src/User/Search/Gambit/EmailGambit.php @@ -12,8 +12,8 @@ namespace Flarum\Core\User\Search\Gambit; use Flarum\User\UserRepository; -use Flarum\Core\Search\AbstractRegexGambit; -use Flarum\Core\Search\AbstractSearch; +use Flarum\Search\AbstractRegexGambit; +use Flarum\Search\AbstractSearch; use Flarum\Core\User\Search\UserSearch; use LogicException; diff --git a/src/User/Search/Gambit/FulltextGambit.php b/src/User/Search/Gambit/FulltextGambit.php index c8349d740..0d2c02baa 100644 --- a/src/User/Search/Gambit/FulltextGambit.php +++ b/src/User/Search/Gambit/FulltextGambit.php @@ -12,8 +12,8 @@ namespace Flarum\Core\User\Search\Gambit; use Flarum\User\UserRepository; -use Flarum\Core\Search\AbstractSearch; -use Flarum\Core\Search\GambitInterface; +use Flarum\Search\AbstractSearch; +use Flarum\Search\GambitInterface; class FulltextGambit implements GambitInterface { diff --git a/src/User/Search/Gambit/GroupGambit.php b/src/User/Search/Gambit/GroupGambit.php index abe1ad984..b8c627bde 100644 --- a/src/User/Search/Gambit/GroupGambit.php +++ b/src/User/Search/Gambit/GroupGambit.php @@ -12,8 +12,8 @@ namespace Flarum\Core\User\Search\Gambit; use Flarum\Core\Repository\GroupRepository; -use Flarum\Core\Search\AbstractRegexGambit; -use Flarum\Core\Search\AbstractSearch; +use Flarum\Search\AbstractRegexGambit; +use Flarum\Search\AbstractSearch; use Flarum\Core\User\Search\UserSearch; use LogicException; diff --git a/src/User/Search/UserSearch.php b/src/User/Search/UserSearch.php index 9223dbd04..d26620f5e 100644 --- a/src/User/Search/UserSearch.php +++ b/src/User/Search/UserSearch.php @@ -11,7 +11,7 @@ namespace Flarum\Core\User\Search; -use Flarum\Core\Search\AbstractSearch; +use Flarum\Search\AbstractSearch; class UserSearch extends AbstractSearch { diff --git a/src/User/Search/UserSearcher.php b/src/User/Search/UserSearcher.php index 0043deb1d..13b0838aa 100644 --- a/src/User/Search/UserSearcher.php +++ b/src/User/Search/UserSearcher.php @@ -13,10 +13,10 @@ namespace Flarum\Core\User\Search; use Flarum\Core\User\Search\UserSearch; use Flarum\User\UserRepository; -use Flarum\Core\Search\ApplySearchParametersTrait; -use Flarum\Core\Search\GambitManager; -use Flarum\Core\Search\SearchCriteria; -use Flarum\Core\Search\SearchResults; +use Flarum\Search\ApplySearchParametersTrait; +use Flarum\Search\GambitManager; +use Flarum\Search\SearchCriteria; +use Flarum\Search\SearchResults; use Flarum\Event\ConfigureUserSearch; /** @@ -28,7 +28,7 @@ class UserSearcher use ApplySearchParametersTrait; /** - * @var GambitManager + * @var \Flarum\Search\GambitManager */ protected $gambits; @@ -38,10 +38,10 @@ class UserSearcher protected $users; /** - * @param GambitManager $gambits + * @param \Flarum\Search\GambitManager $gambits * @param \Flarum\User\UserRepository $users */ - public function __construct(GambitManager $gambits, UserRepository $users) + public function __construct(\Flarum\Search\GambitManager $gambits, UserRepository $users) { $this->gambits = $gambits; $this->users = $users; @@ -52,9 +52,9 @@ class UserSearcher * @param int|null $limit * @param int $offset * @param array $load An array of relationships to load on the results. - * @return SearchResults + * @return \Flarum\Search\SearchResults */ - public function search(SearchCriteria $criteria, $limit = null, $offset = 0, array $load = []) + public function search(\Flarum\Search\SearchCriteria $criteria, $limit = null, $offset = 0, array $load = []) { $actor = $criteria->actor; @@ -83,6 +83,6 @@ class UserSearcher $users->load($load); - return new SearchResults($users, $areMoreResults); + return new \Flarum\Search\SearchResults($users, $areMoreResults); } } From c22219ec20d1381434006aaa27a57ce49daf4118 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 14:05:00 +0200 Subject: [PATCH 24/86] Extract Flarum\Group namespace --- src/Admin/Controller/FrontendController.php | 2 +- src/Api/Controller/ListGroupsController.php | 2 +- src/Api/Controller/SetPermissionController.php | 2 +- src/Api/Controller/ShowForumController.php | 2 +- src/Api/Serializer/GroupSerializer.php | 2 +- src/Core/Command/CreateGroupHandler.php | 14 +++++++------- src/Core/Command/DeleteGroupHandler.php | 8 ++++---- src/Core/Command/EditGroupHandler.php | 12 ++++++------ src/Core/CoreServiceProvider.php | 2 +- .../Event/Created.php} | 8 ++++---- .../Event/Deleted.php} | 10 +++++----- .../Event/Deleting.php} | 6 +++--- .../Event/Renamed.php} | 10 +++++----- .../Event/Saving.php} | 8 ++++---- src/{Core => Group}/Group.php | 16 ++++++++-------- src/{Core/Access => Group}/GroupPolicy.php | 3 +-- .../Repository => Group}/GroupRepository.php | 5 ++--- src/{Core/Validator => Group}/GroupValidator.php | 2 +- src/{Core => Group}/Permission.php | 4 ++-- src/Install/Console/InstallCommand.php | 4 ++-- src/User/Event/GroupsChanged.php | 4 ++-- src/User/Guest.php | 4 ++-- src/User/Search/Gambit/GroupGambit.php | 4 ++-- src/User/User.php | 6 +++--- 24 files changed, 69 insertions(+), 71 deletions(-) rename src/{Event/GroupWasCreated.php => Group/Event/Created.php} (84%) rename src/{Event/GroupWasDeleted.php => Group/Event/Deleted.php} (78%) rename src/{Event/GroupWillBeDeleted.php => Group/Event/Deleting.php} (92%) rename src/{Event/GroupWasRenamed.php => Group/Event/Renamed.php} (78%) rename src/{Event/GroupWillBeSaved.php => Group/Event/Saving.php} (90%) rename src/{Core => Group}/Group.php (88%) rename src/{Core/Access => Group}/GroupPolicy.php (92%) rename src/{Core/Repository => Group}/GroupRepository.php (95%) rename src/{Core/Validator => Group}/GroupValidator.php (92%) rename src/{Core => Group}/Permission.php (93%) diff --git a/src/Admin/Controller/FrontendController.php b/src/Admin/Controller/FrontendController.php index d1b18d2ba..14258eb05 100644 --- a/src/Admin/Controller/FrontendController.php +++ b/src/Admin/Controller/FrontendController.php @@ -12,7 +12,7 @@ namespace Flarum\Admin\Controller; use Flarum\Admin\Frontend; -use Flarum\Core\Permission; +use Flarum\Group\Permission; use Flarum\Settings\Event\Deserializing; use Flarum\Extension\ExtensionManager; use Flarum\Frontend\AbstractFrontendController; diff --git a/src/Api/Controller/ListGroupsController.php b/src/Api/Controller/ListGroupsController.php index 66d734917..f02253810 100644 --- a/src/Api/Controller/ListGroupsController.php +++ b/src/Api/Controller/ListGroupsController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Group; +use Flarum\Group\Group; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/SetPermissionController.php b/src/Api/Controller/SetPermissionController.php index 8eff7ccd9..edbc7cf20 100644 --- a/src/Api/Controller/SetPermissionController.php +++ b/src/Api/Controller/SetPermissionController.php @@ -12,7 +12,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Permission; +use Flarum\Group\Permission; use Flarum\Http\Controller\ControllerInterface; use Psr\Http\Message\ServerRequestInterface; use Zend\Diactoros\Response\EmptyResponse; diff --git a/src/Api/Controller/ShowForumController.php b/src/Api/Controller/ShowForumController.php index d221646e8..2dd3cd369 100644 --- a/src/Api/Controller/ShowForumController.php +++ b/src/Api/Controller/ShowForumController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Group; +use Flarum\Group\Group; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Serializer/GroupSerializer.php b/src/Api/Serializer/GroupSerializer.php index ba07e7754..7cd1eb989 100644 --- a/src/Api/Serializer/GroupSerializer.php +++ b/src/Api/Serializer/GroupSerializer.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Serializer; -use Flarum\Core\Group; +use Flarum\Group\Group; use InvalidArgumentException; use Symfony\Component\Translation\TranslatorInterface; diff --git a/src/Core/Command/CreateGroupHandler.php b/src/Core/Command/CreateGroupHandler.php index 6c3be8830..299cf5804 100644 --- a/src/Core/Command/CreateGroupHandler.php +++ b/src/Core/Command/CreateGroupHandler.php @@ -13,10 +13,10 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Core\Group; +use Flarum\Group\Group; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Core\Validator\GroupValidator; -use Flarum\Event\GroupWillBeSaved; +use Flarum\Group\GroupValidator; +use Flarum\Group\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class CreateGroupHandler @@ -25,13 +25,13 @@ class CreateGroupHandler use AssertPermissionTrait; /** - * @var GroupValidator + * @var \Flarum\Group\GroupValidator */ protected $validator; /** * @param Dispatcher $events - * @param GroupValidator $validator + * @param \Flarum\Group\GroupValidator $validator */ public function __construct(Dispatcher $events, GroupValidator $validator) { @@ -41,7 +41,7 @@ class CreateGroupHandler /** * @param CreateGroup $command - * @return Group + * @return \Flarum\Group\Group * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(CreateGroup $command) @@ -59,7 +59,7 @@ class CreateGroupHandler ); $this->events->fire( - new GroupWillBeSaved($group, $actor, $data) + new Saving($group, $actor, $data) ); $this->validator->assertValid($group->getAttributes()); diff --git a/src/Core/Command/DeleteGroupHandler.php b/src/Core/Command/DeleteGroupHandler.php index e3ee47543..9755311cd 100644 --- a/src/Core/Command/DeleteGroupHandler.php +++ b/src/Core/Command/DeleteGroupHandler.php @@ -13,9 +13,9 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Core\Repository\GroupRepository; +use Flarum\Group\GroupRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Event\GroupWillBeDeleted; +use Flarum\Group\Event\Deleting; use Illuminate\Contracts\Events\Dispatcher; class DeleteGroupHandler @@ -39,7 +39,7 @@ class DeleteGroupHandler /** * @param DeleteGroup $command - * @return \Flarum\Core\Group + * @return \Flarum\Group\Group * @throws PermissionDeniedException */ public function handle(DeleteGroup $command) @@ -51,7 +51,7 @@ class DeleteGroupHandler $this->assertCan($actor, 'delete', $group); $this->events->fire( - new GroupWillBeDeleted($group, $actor, $command->data) + new Deleting($group, $actor, $command->data) ); $group->delete(); diff --git a/src/Core/Command/EditGroupHandler.php b/src/Core/Command/EditGroupHandler.php index 42fe0e0a7..1425f59df 100644 --- a/src/Core/Command/EditGroupHandler.php +++ b/src/Core/Command/EditGroupHandler.php @@ -13,11 +13,11 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Core\Group; -use Flarum\Core\Repository\GroupRepository; +use Flarum\Group\Group; +use Flarum\Group\GroupRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Core\Validator\GroupValidator; -use Flarum\Event\GroupWillBeSaved; +use Flarum\Group\GroupValidator; +use Flarum\Group\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class EditGroupHandler @@ -26,7 +26,7 @@ class EditGroupHandler use AssertPermissionTrait; /** - * @var GroupRepository + * @var \Flarum\Group\GroupRepository */ protected $groups; @@ -76,7 +76,7 @@ class EditGroupHandler } $this->events->fire( - new GroupWillBeSaved($group, $actor, $data) + new Saving($group, $actor, $data) ); $this->validator->assertValid($group->getDirty()); diff --git a/src/Core/CoreServiceProvider.php b/src/Core/CoreServiceProvider.php index 088733ce8..ed79cbfaf 100644 --- a/src/Core/CoreServiceProvider.php +++ b/src/Core/CoreServiceProvider.php @@ -114,7 +114,7 @@ class CoreServiceProvider extends AbstractServiceProvider $events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier'); $events->subscribe('Flarum\Discussion\DiscussionPolicy'); - $events->subscribe('Flarum\Core\Access\GroupPolicy'); + $events->subscribe('Flarum\Group\GroupPolicy'); $events->subscribe('Flarum\Post\PostPolicy'); $events->subscribe('Flarum\User\UserPolicy'); diff --git a/src/Event/GroupWasCreated.php b/src/Group/Event/Created.php similarity index 84% rename from src/Event/GroupWasCreated.php rename to src/Group/Event/Created.php index 2e4962809..109c615d6 100644 --- a/src/Event/GroupWasCreated.php +++ b/src/Group/Event/Created.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Group\Event; -use Flarum\Core\Group; +use Flarum\Group\Group; use Flarum\User\User; -class GroupWasCreated +class Created { /** - * @var Group + * @var \Flarum\Group\Group */ public $group; diff --git a/src/Event/GroupWasDeleted.php b/src/Group/Event/Deleted.php similarity index 78% rename from src/Event/GroupWasDeleted.php rename to src/Group/Event/Deleted.php index 1d2290b7b..6fbc5fbc1 100644 --- a/src/Event/GroupWasDeleted.php +++ b/src/Group/Event/Deleted.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Group\Event; -use Flarum\Core\Group; +use Flarum\Group\Group; use Flarum\User\User; -class GroupWasDeleted +class Deleted { /** - * @var Group + * @var \Flarum\Group\Group */ public $group; @@ -27,7 +27,7 @@ class GroupWasDeleted public $actor; /** - * @param Group $group + * @param \Flarum\Group\Group $group * @param User $actor */ public function __construct(Group $group, User $actor = null) diff --git a/src/Event/GroupWillBeDeleted.php b/src/Group/Event/Deleting.php similarity index 92% rename from src/Event/GroupWillBeDeleted.php rename to src/Group/Event/Deleting.php index ac0d5b406..1c91063e1 100644 --- a/src/Event/GroupWillBeDeleted.php +++ b/src/Group/Event/Deleting.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Group\Event; -use Flarum\Core\Group; +use Flarum\Group\Group; use Flarum\User\User; -class GroupWillBeDeleted +class Deleting { /** * The group that will be deleted. diff --git a/src/Event/GroupWasRenamed.php b/src/Group/Event/Renamed.php similarity index 78% rename from src/Event/GroupWasRenamed.php rename to src/Group/Event/Renamed.php index ded05ce98..c9c201872 100644 --- a/src/Event/GroupWasRenamed.php +++ b/src/Group/Event/Renamed.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Group\Event; -use Flarum\Core\Group; +use Flarum\Group\Group; use Flarum\User\User; -class GroupWasRenamed +class Renamed { /** - * @var Group + * @var \Flarum\Group\Group */ public $group; @@ -27,7 +27,7 @@ class GroupWasRenamed public $actor; /** - * @param Group $group + * @param \Flarum\Group\Group $group * @param User $actor */ public function __construct(Group $group, User $actor = null) diff --git a/src/Event/GroupWillBeSaved.php b/src/Group/Event/Saving.php similarity index 90% rename from src/Event/GroupWillBeSaved.php rename to src/Group/Event/Saving.php index feeaac887..2dd019dca 100644 --- a/src/Event/GroupWillBeSaved.php +++ b/src/Group/Event/Saving.php @@ -9,17 +9,17 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Group\Event; -use Flarum\Core\Group; +use Flarum\Group\Group; use Flarum\User\User; -class GroupWillBeSaved +class Saving { /** * The group that will be saved. * - * @var Group + * @var \Flarum\Group\Group */ public $group; diff --git a/src/Core/Group.php b/src/Group/Group.php similarity index 88% rename from src/Core/Group.php rename to src/Group/Group.php index 53d4da36f..dd30cbb53 100755 --- a/src/Core/Group.php +++ b/src/Group/Group.php @@ -9,14 +9,14 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\Group; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; -use Flarum\Event\GroupWasCreated; -use Flarum\Event\GroupWasDeleted; -use Flarum\Event\GroupWasRenamed; +use Flarum\Group\Event\Created; +use Flarum\Group\Event\Deleting; +use Flarum\Group\Event\Renamed; /** * @property int $id @@ -67,7 +67,7 @@ class Group extends AbstractModel parent::boot(); static::deleted(function (Group $group) { - $group->raise(new GroupWasDeleted($group)); + $group->raise(new Deleting($group)); $group->permissions()->delete(); }); @@ -91,7 +91,7 @@ class Group extends AbstractModel $group->color = $color; $group->icon = $icon; - $group->raise(new GroupWasCreated($group)); + $group->raise(new Created($group)); return $group; } @@ -108,7 +108,7 @@ class Group extends AbstractModel $this->name_singular = $nameSingular; $this->name_plural = $namePlural; - $this->raise(new GroupWasRenamed($this)); + $this->raise(new Renamed($this)); return $this; } @@ -130,6 +130,6 @@ class Group extends AbstractModel */ public function permissions() { - return $this->hasMany('Flarum\Core\Permission'); + return $this->hasMany('Flarum\Group\Permission'); } } diff --git a/src/Core/Access/GroupPolicy.php b/src/Group/GroupPolicy.php similarity index 92% rename from src/Core/Access/GroupPolicy.php rename to src/Group/GroupPolicy.php index ff9861a07..91af563a8 100644 --- a/src/Core/Access/GroupPolicy.php +++ b/src/Group/GroupPolicy.php @@ -9,9 +9,8 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Access; +namespace Flarum\Group; -use Flarum\Core\Group; use Flarum\User\AbstractPolicy; use Flarum\User\User; diff --git a/src/Core/Repository/GroupRepository.php b/src/Group/GroupRepository.php similarity index 95% rename from src/Core/Repository/GroupRepository.php rename to src/Group/GroupRepository.php index f6cfe3d82..4372fa560 100644 --- a/src/Core/Repository/GroupRepository.php +++ b/src/Group/GroupRepository.php @@ -9,9 +9,8 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Repository; +namespace Flarum\Group; -use Flarum\Core\Group; use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; @@ -33,7 +32,7 @@ class GroupRepository * * @param int $id * @param User $actor - * @return Group + * @return \Flarum\Group\Group * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ diff --git a/src/Core/Validator/GroupValidator.php b/src/Group/GroupValidator.php similarity index 92% rename from src/Core/Validator/GroupValidator.php rename to src/Group/GroupValidator.php index 506163f6f..58d8aee16 100644 --- a/src/Core/Validator/GroupValidator.php +++ b/src/Group/GroupValidator.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Validator; +namespace Flarum\Group; use Flarum\Foundation\AbstractValidator; diff --git a/src/Core/Permission.php b/src/Group/Permission.php similarity index 93% rename from src/Core/Permission.php rename to src/Group/Permission.php index 21bd7d88a..0ed470e3b 100755 --- a/src/Core/Permission.php +++ b/src/Group/Permission.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\Group; use Flarum\Database\AbstractModel; use Illuminate\Database\Eloquent\Builder; @@ -31,7 +31,7 @@ class Permission extends AbstractModel */ public function group() { - return $this->belongsTo('Flarum\Core\Group', 'group_id'); + return $this->belongsTo('Flarum\Group\Group', 'group_id'); } /** diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index acf67997d..ace02e89b 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -13,8 +13,8 @@ namespace Flarum\Install\Console; use Exception; use Flarum\Console\AbstractCommand; -use Flarum\Core\Group; -use Flarum\Core\Permission; +use Flarum\Group\Group; +use Flarum\Group\Permission; use Flarum\User\User; use Flarum\Database\AbstractModel; use Illuminate\Contracts\Foundation\Application; diff --git a/src/User/Event/GroupsChanged.php b/src/User/Event/GroupsChanged.php index feb6484d7..310d70fb7 100644 --- a/src/User/Event/GroupsChanged.php +++ b/src/User/Event/GroupsChanged.php @@ -23,7 +23,7 @@ class GroupsChanged public $user; /** - * @var \Flarum\Core\Group[] + * @var \Flarum\Group\Group[] */ public $oldGroups; @@ -34,7 +34,7 @@ class GroupsChanged /** * @param User $user The user whose groups were changed. - * @param \Flarum\Core\Group[] $oldGroups + * @param \Flarum\Group\Group[] $oldGroups * @param User $actor */ public function __construct(User $user, array $oldGroups, User $actor = null) diff --git a/src/User/Guest.php b/src/User/Guest.php index e62b8c695..e7dc3f502 100755 --- a/src/User/Guest.php +++ b/src/User/Guest.php @@ -11,7 +11,7 @@ namespace Flarum\User; -use Flarum\Core\Group; +use Flarum\Group\Group; class Guest extends User { @@ -25,7 +25,7 @@ class Guest extends User /** * Get the guest's group, containing only the 'guests' group model. * - * @return Group + * @return \Flarum\Group\Group */ public function getGroupsAttribute() { diff --git a/src/User/Search/Gambit/GroupGambit.php b/src/User/Search/Gambit/GroupGambit.php index b8c627bde..317ea8232 100644 --- a/src/User/Search/Gambit/GroupGambit.php +++ b/src/User/Search/Gambit/GroupGambit.php @@ -11,7 +11,7 @@ namespace Flarum\Core\User\Search\Gambit; -use Flarum\Core\Repository\GroupRepository; +use Flarum\Group\GroupRepository; use Flarum\Search\AbstractRegexGambit; use Flarum\Search\AbstractSearch; use Flarum\Core\User\Search\UserSearch; @@ -30,7 +30,7 @@ class GroupGambit extends AbstractRegexGambit protected $groups; /** - * @param \Flarum\Core\Repository\GroupRepository $groups + * @param \Flarum\Group\GroupRepository $groups */ public function __construct(GroupRepository $groups) { diff --git a/src/User/User.php b/src/User/User.php index f85470449..24a6ab8bb 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -13,9 +13,9 @@ namespace Flarum\User; use DomainException; use Flarum\User\Gate; -use Flarum\Core\Group; +use Flarum\Group\Group; use Flarum\Core\Notification; -use Flarum\Core\Permission; +use Flarum\Group\Permission; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; @@ -623,7 +623,7 @@ class User extends AbstractModel */ public function groups() { - return $this->belongsToMany('Flarum\Core\Group', 'users_groups'); + return $this->belongsToMany('Flarum\Group\Group', 'users_groups'); } /** From 920a4071b61ba943c2b7db594fa7c8d341b11f93 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 14:10:39 +0200 Subject: [PATCH 25/86] Fix some incorrect automated refactorings --- src/Api/Serializer/BasicPostSerializer.php | 4 ++-- src/Core/Command/DeletePostHandler.php | 2 +- src/Core/Command/EditPostHandler.php | 2 +- src/Core/CoreServiceProvider.php | 4 ++-- src/Discussion/Discussion.php | 4 ++-- .../Search/Fulltext/MySqlFulltextDriver.php | 2 +- src/Post/PostRepository.php | 2 +- src/User/User.php | 5 ++--- src/User/UserMetadataUpdater.php | 14 +++++++------- 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/Api/Serializer/BasicPostSerializer.php b/src/Api/Serializer/BasicPostSerializer.php index 2e0a75951..b63b6dec6 100644 --- a/src/Api/Serializer/BasicPostSerializer.php +++ b/src/Api/Serializer/BasicPostSerializer.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Serializer; -use Flarum\Core\Post; +use Flarum\Post\Post; use Flarum\Post\CommentPost; use InvalidArgumentException; @@ -25,7 +25,7 @@ class BasicPostSerializer extends AbstractSerializer /** * {@inheritdoc} * - * @param \Flarum\Core\Post $post + * @param \Flarum\Post\Post $post * @throws InvalidArgumentException */ protected function getDefaultAttributes($post) diff --git a/src/Core/Command/DeletePostHandler.php b/src/Core/Command/DeletePostHandler.php index 176aa5d3f..541c5cb40 100644 --- a/src/Core/Command/DeletePostHandler.php +++ b/src/Core/Command/DeletePostHandler.php @@ -40,7 +40,7 @@ class DeletePostHandler /** * @param DeletePost $command - * @return \Flarum\Core\Post + * @return \Flarum\Post\Post * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(DeletePost $command) diff --git a/src/Core/Command/EditPostHandler.php b/src/Core/Command/EditPostHandler.php index af0a52a45..7bca65370 100644 --- a/src/Core/Command/EditPostHandler.php +++ b/src/Core/Command/EditPostHandler.php @@ -48,7 +48,7 @@ class EditPostHandler /** * @param EditPost $command - * @return \Flarum\Core\Post + * @return \Flarum\Post\Post * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(EditPost $command) diff --git a/src/Core/CoreServiceProvider.php b/src/Core/CoreServiceProvider.php index ed79cbfaf..82e5f6b0d 100644 --- a/src/Core/CoreServiceProvider.php +++ b/src/Core/CoreServiceProvider.php @@ -124,8 +124,8 @@ class CoreServiceProvider extends AbstractServiceProvider public function registerPostTypes() { $models = [ - 'Flarum\Post\Post\CommentPost', - 'Flarum\Post\Post\DiscussionRenamedPost' + 'Flarum\Post\CommentPost', + 'Flarum\Post\DiscussionRenamedPost' ]; $this->app->make('events')->fire( diff --git a/src/Discussion/Discussion.php b/src/Discussion/Discussion.php index 34122fd90..0b06f632f 100644 --- a/src/Discussion/Discussion.php +++ b/src/Discussion/Discussion.php @@ -21,7 +21,7 @@ use Flarum\Discussion\Event\Hidden; use Flarum\Discussion\Event\Renamed; use Flarum\Discussion\Event\Restored; use Flarum\Discussion\Event\Started; -use Flarum\Post\Event\Deleted; +use Flarum\Post\Event\Deleted as PostDeleted; use Flarum\Event\ScopePostVisibility; use Flarum\Post\Post; use Flarum\User\Guest; @@ -111,7 +111,7 @@ class Discussion extends AbstractModel $posts = $discussion->posts()->allTypes(); foreach ($posts->get() as $post) { - $discussion->raise(new Deleted($post)); + $discussion->raise(new PostDeleted($post)); } $posts->delete(); diff --git a/src/Discussion/Search/Fulltext/MySqlFulltextDriver.php b/src/Discussion/Search/Fulltext/MySqlFulltextDriver.php index 8c71066d6..0c1136297 100644 --- a/src/Discussion/Search/Fulltext/MySqlFulltextDriver.php +++ b/src/Discussion/Search/Fulltext/MySqlFulltextDriver.php @@ -11,7 +11,7 @@ namespace Flarum\Discussion\Search\Fulltext; -use Flarum\Core\Post; +use Flarum\Post\Post; class MySqlFulltextDriver implements DriverInterface { diff --git a/src/Post/PostRepository.php b/src/Post/PostRepository.php index a43ce300c..e6a38af03 100644 --- a/src/Post/PostRepository.php +++ b/src/Post/PostRepository.php @@ -34,7 +34,7 @@ class PostRepository * * @param int $id * @param \Flarum\User\User $actor - * @return \Flarum\Core\Post + * @return \Flarum\Post\Post * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ diff --git a/src/User/User.php b/src/User/User.php index 24a6ab8bb..70396e6ff 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -12,7 +12,6 @@ namespace Flarum\User; use DomainException; -use Flarum\User\Gate; use Flarum\Group\Group; use Flarum\Core\Notification; use Flarum\Group\Permission; @@ -21,7 +20,7 @@ use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\CheckUserPassword; use Flarum\Event\ConfigureUserPreferences; -use Flarum\Post\Event\Deleted; +use Flarum\Post\Event\Deleted as PostDeleted; use Flarum\Event\PrepareUserGroups; use Flarum\User\Event\AvatarChanged; use Flarum\User\Event\BioChanged; @@ -136,7 +135,7 @@ class User extends AbstractModel $posts = $user->posts()->allTypes(); foreach ($posts->get() as $post) { - $user->raise(new Deleted($post)); + $user->raise(new PostDeleted($post)); } $posts->delete(); diff --git a/src/User/UserMetadataUpdater.php b/src/User/UserMetadataUpdater.php index 3cf33979a..a690813dd 100755 --- a/src/User/UserMetadataUpdater.php +++ b/src/User/UserMetadataUpdater.php @@ -12,13 +12,13 @@ namespace Flarum\User; use Flarum\Discussion\Discussion; -use Flarum\Core\Post; -use Flarum\Discussion\Event\Deleted; +use Flarum\Discussion\Event\Deleted as DiscussionDeleted; use Flarum\Discussion\Event\Started; -use Flarum\Post\Event\Deleted; +use Flarum\Post\Event\Deleted as PostDeleted; use Flarum\Post\Event\Hidden; use Flarum\Post\Event\Posted; use Flarum\Post\Event\Restored; +use Flarum\Post\Post; use Illuminate\Contracts\Events\Dispatcher; class UserMetadataUpdater @@ -29,11 +29,11 @@ class UserMetadataUpdater public function subscribe(Dispatcher $events) { $events->listen(Posted::class, [$this, 'whenPostWasPosted']); - $events->listen(Deleted::class, [$this, 'whenPostWasDeleted']); + $events->listen(PostDeleted::class, [$this, 'whenPostWasDeleted']); $events->listen(Hidden::class, [$this, 'whenPostWasHidden']); $events->listen(Restored::class, [$this, 'whenPostWasRestored']); $events->listen(Started::class, [$this, 'whenDiscussionWasStarted']); - $events->listen(Deleted::class, [$this, 'whenDiscussionWasDeleted']); + $events->listen(DiscussionDeleted::class, [$this, 'whenDiscussionWasDeleted']); } /** @@ -47,7 +47,7 @@ class UserMetadataUpdater /** * @param \Flarum\Post\Event\Deleted $event */ - public function whenPostWasDeleted(Deleted $event) + public function whenPostWasDeleted(PostDeleted $event) { $this->updateCommentsCount($event->post, -1); } @@ -79,7 +79,7 @@ class UserMetadataUpdater /** * @param \Flarum\Discussion\Event\Deleted $event */ - public function whenDiscussionWasDeleted(Deleted $event) + public function whenDiscussionWasDeleted(DiscussionDeleted $event) { $this->updateDiscussionsCount($event->discussion, -1); } From 4a13cd8088ee9411240ae022619e0de28af37552 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 14:16:19 +0200 Subject: [PATCH 26/86] Move another trait out of obsolete Flarum\Core namespace --- src/Admin/Middleware/RequireAdministrateAbility.php | 2 +- src/Api/Controller/DeleteFaviconController.php | 2 +- src/Api/Controller/DeleteLogoController.php | 2 +- src/Api/Controller/SendConfirmationEmailController.php | 2 +- src/Api/Controller/SetPermissionController.php | 2 +- src/Api/Controller/SetSettingsController.php | 2 +- src/Api/Controller/UninstallExtensionController.php | 2 +- src/Api/Controller/UpdateExtensionController.php | 2 +- src/Api/Controller/UploadFaviconController.php | 2 +- src/Api/Controller/UploadLogoController.php | 2 +- src/Core/Command/CreateGroupHandler.php | 5 ++--- src/Core/Command/DeleteAvatarHandler.php | 4 ++-- src/Core/Command/DeleteDiscussionHandler.php | 4 ++-- src/Core/Command/DeleteGroupHandler.php | 4 ++-- src/Core/Command/DeletePostHandler.php | 4 ++-- src/Core/Command/DeleteUserHandler.php | 4 ++-- src/Core/Command/EditDiscussionHandler.php | 4 ++-- src/Core/Command/EditGroupHandler.php | 4 ++-- src/Core/Command/EditPostHandler.php | 4 ++-- src/Core/Command/EditUserHandler.php | 4 ++-- src/Core/Command/PostReplyHandler.php | 4 ++-- src/Core/Command/ReadAllNotificationsHandler.php | 2 +- src/Core/Command/ReadDiscussionHandler.php | 4 ++-- src/Core/Command/ReadNotificationHandler.php | 2 +- src/Core/Command/RegisterUserHandler.php | 4 ++-- src/Core/Command/StartDiscussionHandler.php | 4 ++-- src/Core/Command/UploadAvatarHandler.php | 4 ++-- src/Forum/Controller/LogOutController.php | 2 +- src/{Core/Access => User}/AssertPermissionTrait.php | 3 +-- 29 files changed, 44 insertions(+), 46 deletions(-) rename src/{Core/Access => User}/AssertPermissionTrait.php (96%) diff --git a/src/Admin/Middleware/RequireAdministrateAbility.php b/src/Admin/Middleware/RequireAdministrateAbility.php index b52ab4163..b970e4d2e 100644 --- a/src/Admin/Middleware/RequireAdministrateAbility.php +++ b/src/Admin/Middleware/RequireAdministrateAbility.php @@ -11,7 +11,7 @@ namespace Flarum\Admin\Middleware; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Zend\Stratigility\MiddlewareInterface; diff --git a/src/Api/Controller/DeleteFaviconController.php b/src/Api/Controller/DeleteFaviconController.php index 00c38bb50..4c2807abc 100644 --- a/src/Api/Controller/DeleteFaviconController.php +++ b/src/Api/Controller/DeleteFaviconController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; use League\Flysystem\Adapter\Local; diff --git a/src/Api/Controller/DeleteLogoController.php b/src/Api/Controller/DeleteLogoController.php index 4e4cc016a..532674577 100644 --- a/src/Api/Controller/DeleteLogoController.php +++ b/src/Api/Controller/DeleteLogoController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; use League\Flysystem\Adapter\Local; diff --git a/src/Api/Controller/SendConfirmationEmailController.php b/src/Api/Controller/SendConfirmationEmailController.php index 02c22b020..a6314ad97 100644 --- a/src/Api/Controller/SendConfirmationEmailController.php +++ b/src/Api/Controller/SendConfirmationEmailController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\EmailToken; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Forum\UrlGenerator; diff --git a/src/Api/Controller/SetPermissionController.php b/src/Api/Controller/SetPermissionController.php index edbc7cf20..a11dc056f 100644 --- a/src/Api/Controller/SetPermissionController.php +++ b/src/Api/Controller/SetPermissionController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Group\Permission; use Flarum\Http\Controller\ControllerInterface; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/SetSettingsController.php b/src/Api/Controller/SetSettingsController.php index 09f23c6eb..b9cb59cdd 100644 --- a/src/Api/Controller/SetSettingsController.php +++ b/src/Api/Controller/SetSettingsController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Settings\Event\Serializing; use Flarum\Settings\Event\Saved; use Flarum\Http\Controller\ControllerInterface; diff --git a/src/Api/Controller/UninstallExtensionController.php b/src/Api/Controller/UninstallExtensionController.php index 4b9b185fb..0e2f02a59 100644 --- a/src/Api/Controller/UninstallExtensionController.php +++ b/src/Api/Controller/UninstallExtensionController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Extension\ExtensionManager; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/UpdateExtensionController.php b/src/Api/Controller/UpdateExtensionController.php index f9d983769..c701ae469 100644 --- a/src/Api/Controller/UpdateExtensionController.php +++ b/src/Api/Controller/UpdateExtensionController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Extension\ExtensionManager; use Flarum\Http\Controller\ControllerInterface; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/UploadFaviconController.php b/src/Api/Controller/UploadFaviconController.php index 1ccd5e088..80b33abee 100644 --- a/src/Api/Controller/UploadFaviconController.php +++ b/src/Api/Controller/UploadFaviconController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Support\Str; diff --git a/src/Api/Controller/UploadLogoController.php b/src/Api/Controller/UploadLogoController.php index ff49683f2..ed10a8b67 100644 --- a/src/Api/Controller/UploadLogoController.php +++ b/src/Api/Controller/UploadLogoController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Support\Str; diff --git a/src/Core/Command/CreateGroupHandler.php b/src/Core/Command/CreateGroupHandler.php index 299cf5804..ee152d1ec 100644 --- a/src/Core/Command/CreateGroupHandler.php +++ b/src/Core/Command/CreateGroupHandler.php @@ -11,8 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\User\Exception\PermissionDeniedException; +use Flarum\User\AssertPermissionTrait; use Flarum\Group\Group; use Flarum\Foundation\DispatchEventsTrait; use Flarum\Group\GroupValidator; @@ -21,7 +20,7 @@ use Illuminate\Contracts\Events\Dispatcher; class CreateGroupHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/DeleteAvatarHandler.php b/src/Core/Command/DeleteAvatarHandler.php index 00961f741..2dfe68efd 100644 --- a/src/Core/Command/DeleteAvatarHandler.php +++ b/src/Core/Command/DeleteAvatarHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\UserRepository; use Flarum\Foundation\DispatchEventsTrait; @@ -21,7 +21,7 @@ use League\Flysystem\FilesystemInterface; class DeleteAvatarHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/DeleteDiscussionHandler.php b/src/Core/Command/DeleteDiscussionHandler.php index 4665db213..9643b5e96 100644 --- a/src/Core/Command/DeleteDiscussionHandler.php +++ b/src/Core/Command/DeleteDiscussionHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Discussion\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; @@ -20,7 +20,7 @@ use Illuminate\Contracts\Events\Dispatcher; class DeleteDiscussionHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/DeleteGroupHandler.php b/src/Core/Command/DeleteGroupHandler.php index 9755311cd..119758d1f 100644 --- a/src/Core/Command/DeleteGroupHandler.php +++ b/src/Core/Command/DeleteGroupHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Group\GroupRepository; use Flarum\Foundation\DispatchEventsTrait; @@ -20,7 +20,7 @@ use Illuminate\Contracts\Events\Dispatcher; class DeleteGroupHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/DeletePostHandler.php b/src/Core/Command/DeletePostHandler.php index 541c5cb40..1e5301f2e 100644 --- a/src/Core/Command/DeletePostHandler.php +++ b/src/Core/Command/DeletePostHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Post\PostRepository; use Flarum\Foundation\DispatchEventsTrait; @@ -20,7 +20,7 @@ use Illuminate\Contracts\Events\Dispatcher; class DeletePostHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/DeleteUserHandler.php b/src/Core/Command/DeleteUserHandler.php index d5ed6c15f..e2f64e482 100644 --- a/src/Core/Command/DeleteUserHandler.php +++ b/src/Core/Command/DeleteUserHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\UserRepository; use Flarum\Foundation\DispatchEventsTrait; @@ -20,7 +20,7 @@ use Illuminate\Contracts\Events\Dispatcher; class DeleteUserHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/EditDiscussionHandler.php b/src/Core/Command/EditDiscussionHandler.php index bce27933e..038777d3e 100644 --- a/src/Core/Command/EditDiscussionHandler.php +++ b/src/Core/Command/EditDiscussionHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Discussion\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; @@ -21,7 +21,7 @@ use Illuminate\Contracts\Events\Dispatcher; class EditDiscussionHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/EditGroupHandler.php b/src/Core/Command/EditGroupHandler.php index 1425f59df..c3fee99f4 100644 --- a/src/Core/Command/EditGroupHandler.php +++ b/src/Core/Command/EditGroupHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Group\Group; use Flarum\Group\GroupRepository; @@ -22,7 +22,7 @@ use Illuminate\Contracts\Events\Dispatcher; class EditGroupHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/EditPostHandler.php b/src/Core/Command/EditPostHandler.php index 7bca65370..e2b093f9a 100644 --- a/src/Core/Command/EditPostHandler.php +++ b/src/Core/Command/EditPostHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Post\CommentPost; use Flarum\Post\PostRepository; use Flarum\Foundation\DispatchEventsTrait; @@ -21,7 +21,7 @@ use Illuminate\Contracts\Events\Dispatcher; class EditPostHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/EditUserHandler.php b/src/Core/Command/EditUserHandler.php index 6071fa1ad..cb2b2b725 100644 --- a/src/Core/Command/EditUserHandler.php +++ b/src/Core/Command/EditUserHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\UserRepository; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\User; @@ -22,7 +22,7 @@ use Illuminate\Contracts\Events\Dispatcher; class EditUserHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/PostReplyHandler.php b/src/Core/Command/PostReplyHandler.php index cb51c4fda..e4b3147e7 100644 --- a/src/Core/Command/PostReplyHandler.php +++ b/src/Core/Command/PostReplyHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use DateTime; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Core\Notification\NotificationSyncer; use Flarum\Post\CommentPost; use Flarum\Discussion\DiscussionRepository; @@ -23,7 +23,7 @@ use Illuminate\Contracts\Events\Dispatcher; class PostReplyHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/ReadAllNotificationsHandler.php b/src/Core/Command/ReadAllNotificationsHandler.php index 023568f9b..9269ed958 100644 --- a/src/Core/Command/ReadAllNotificationsHandler.php +++ b/src/Core/Command/ReadAllNotificationsHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Core\Repository\NotificationRepository; class ReadAllNotificationsHandler diff --git a/src/Core/Command/ReadDiscussionHandler.php b/src/Core/Command/ReadDiscussionHandler.php index 42e4722ea..9be64074b 100644 --- a/src/Core/Command/ReadDiscussionHandler.php +++ b/src/Core/Command/ReadDiscussionHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Discussion\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; use Flarum\Discussion\Event\UserDataSaving; @@ -19,7 +19,7 @@ use Illuminate\Contracts\Events\Dispatcher; class ReadDiscussionHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/ReadNotificationHandler.php b/src/Core/Command/ReadNotificationHandler.php index b7da93198..f70f1d6b1 100644 --- a/src/Core/Command/ReadNotificationHandler.php +++ b/src/Core/Command/ReadNotificationHandler.php @@ -11,7 +11,7 @@ namespace Flarum\Core\Command; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Core\Notification; class ReadNotificationHandler diff --git a/src/Core/Command/RegisterUserHandler.php b/src/Core/Command/RegisterUserHandler.php index 2c3bdb931..edbf35d65 100644 --- a/src/Core/Command/RegisterUserHandler.php +++ b/src/Core/Command/RegisterUserHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Exception; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\AuthToken; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Foundation\DispatchEventsTrait; @@ -33,7 +33,7 @@ use League\Flysystem\MountManager; class RegisterUserHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/StartDiscussionHandler.php b/src/Core/Command/StartDiscussionHandler.php index bad252625..7f8586031 100644 --- a/src/Core/Command/StartDiscussionHandler.php +++ b/src/Core/Command/StartDiscussionHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Exception; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\Discussion\Discussion; use Flarum\Foundation\DispatchEventsTrait; use Flarum\Discussion\DiscussionValidator; @@ -22,7 +22,7 @@ use Illuminate\Contracts\Events\Dispatcher as EventDispatcher; class StartDiscussionHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Core/Command/UploadAvatarHandler.php b/src/Core/Command/UploadAvatarHandler.php index 791090e58..adcf76ee3 100644 --- a/src/Core/Command/UploadAvatarHandler.php +++ b/src/Core/Command/UploadAvatarHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Exception; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\UserRepository; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AvatarValidator; @@ -29,7 +29,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; class UploadAvatarHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; use AssertPermissionTrait; /** diff --git a/src/Forum/Controller/LogOutController.php b/src/Forum/Controller/LogOutController.php index c83601268..af220a6b6 100644 --- a/src/Forum/Controller/LogOutController.php +++ b/src/Forum/Controller/LogOutController.php @@ -11,7 +11,7 @@ namespace Flarum\Forum\Controller; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\User\AssertPermissionTrait; use Flarum\User\Event\LoggedOut; use Flarum\Foundation\Application; use Flarum\Http\Controller\ControllerInterface; diff --git a/src/Core/Access/AssertPermissionTrait.php b/src/User/AssertPermissionTrait.php similarity index 96% rename from src/Core/Access/AssertPermissionTrait.php rename to src/User/AssertPermissionTrait.php index 647ca9fac..d6310440a 100644 --- a/src/Core/Access/AssertPermissionTrait.php +++ b/src/User/AssertPermissionTrait.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Access; +namespace Flarum\User; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\User\User; trait AssertPermissionTrait { From b38ade986d177c7274cd618162f3571748ecb9f7 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 14:22:19 +0200 Subject: [PATCH 27/86] Extract Flarum\Notification namespace --- .../ListNotificationsController.php | 8 +++---- src/Api/Serializer/NotificationSerializer.php | 4 ++-- src/Core/Command/PostReplyHandler.php | 6 ++--- .../Command/ReadAllNotificationsHandler.php | 2 +- src/Core/Command/ReadNotificationHandler.php | 4 ++-- src/Core/CoreServiceProvider.php | 2 +- src/Discussion/DiscussionRenamedNotifier.php | 4 ++-- src/Event/ConfigureNotificationTypes.php | 2 +- .../Blueprint}/BlueprintInterface.php | 2 +- .../Blueprint}/DiscussionRenamedBlueprint.php | 2 +- .../Event/Sending.php} | 8 +++---- .../Notification/MailableInterface.php | 2 +- src/{Core => Notification}/Notification.php | 2 +- .../Notification/NotificationMailer.php | 2 +- .../NotificationRepository.php | 3 +-- .../NotificationServiceProvider.php | 7 +++--- .../Notification/NotificationSyncer.php | 23 +++++++++---------- src/User/User.php | 4 ++-- 18 files changed, 42 insertions(+), 45 deletions(-) rename src/{Core/Notification => Notification/Blueprint}/BlueprintInterface.php (96%) rename src/{Core/Notification => Notification/Blueprint}/DiscussionRenamedBlueprint.php (96%) rename src/{Event/NotificationWillBeSent.php => Notification/Event/Sending.php} (79%) rename src/{Core => }/Notification/MailableInterface.php (93%) rename src/{Core => Notification}/Notification.php (99%) rename src/{Core => }/Notification/NotificationMailer.php (96%) rename src/{Core/Repository => Notification}/NotificationRepository.php (96%) rename src/{Core => }/Notification/NotificationServiceProvider.php (88%) rename src/{Core => }/Notification/NotificationSyncer.php (89%) diff --git a/src/Api/Controller/ListNotificationsController.php b/src/Api/Controller/ListNotificationsController.php index c167498fe..aeca867a8 100644 --- a/src/Api/Controller/ListNotificationsController.php +++ b/src/Api/Controller/ListNotificationsController.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Controller; use Flarum\Discussion\Discussion; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Core\Repository\NotificationRepository; +use Flarum\Notification\NotificationRepository; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -39,12 +39,12 @@ class ListNotificationsController extends AbstractListController public $limit = 10; /** - * @var \Flarum\Core\Repository\NotificationRepository + * @var \Flarum\Notification\NotificationRepository */ protected $notifications; /** - * @param \Flarum\Core\Repository\NotificationRepository $notifications + * @param \Flarum\Notification\NotificationRepository $notifications */ public function __construct(NotificationRepository $notifications) { @@ -80,7 +80,7 @@ class ListNotificationsController extends AbstractListController } /** - * @param \Flarum\Core\Notification[] $notifications + * @param \Flarum\Notification\Notification[] $notifications */ private function loadSubjectDiscussions(array $notifications) { diff --git a/src/Api/Serializer/NotificationSerializer.php b/src/Api/Serializer/NotificationSerializer.php index bfbd8e943..9159445a3 100644 --- a/src/Api/Serializer/NotificationSerializer.php +++ b/src/Api/Serializer/NotificationSerializer.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Serializer; -use Flarum\Core\Notification; +use Flarum\Notification\Notification; use InvalidArgumentException; class NotificationSerializer extends AbstractSerializer @@ -32,7 +32,7 @@ class NotificationSerializer extends AbstractSerializer /** * {@inheritdoc} * - * @param \Flarum\Core\Notification $notification + * @param \Flarum\Notification\Notification $notification * @throws InvalidArgumentException */ protected function getDefaultAttributes($notification) diff --git a/src/Core/Command/PostReplyHandler.php b/src/Core/Command/PostReplyHandler.php index e4b3147e7..2a8314a8e 100644 --- a/src/Core/Command/PostReplyHandler.php +++ b/src/Core/Command/PostReplyHandler.php @@ -13,7 +13,7 @@ namespace Flarum\Core\Command; use DateTime; use Flarum\User\AssertPermissionTrait; -use Flarum\Core\Notification\NotificationSyncer; +use Flarum\Notification\NotificationSyncer; use Flarum\Post\CommentPost; use Flarum\Discussion\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; @@ -32,7 +32,7 @@ class PostReplyHandler protected $discussions; /** - * @var NotificationSyncer + * @var \Flarum\Notification\NotificationSyncer */ protected $notifications; @@ -44,7 +44,7 @@ class PostReplyHandler /** * @param Dispatcher $events * @param DiscussionRepository $discussions - * @param NotificationSyncer $notifications + * @param \Flarum\Notification\NotificationSyncer $notifications * @param PostValidator $validator */ public function __construct( diff --git a/src/Core/Command/ReadAllNotificationsHandler.php b/src/Core/Command/ReadAllNotificationsHandler.php index 9269ed958..7e2255fd5 100644 --- a/src/Core/Command/ReadAllNotificationsHandler.php +++ b/src/Core/Command/ReadAllNotificationsHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Flarum\User\AssertPermissionTrait; -use Flarum\Core\Repository\NotificationRepository; +use Flarum\Notification\NotificationRepository; class ReadAllNotificationsHandler { diff --git a/src/Core/Command/ReadNotificationHandler.php b/src/Core/Command/ReadNotificationHandler.php index f70f1d6b1..d8ed0a8fa 100644 --- a/src/Core/Command/ReadNotificationHandler.php +++ b/src/Core/Command/ReadNotificationHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Core\Command; use Flarum\User\AssertPermissionTrait; -use Flarum\Core\Notification; +use Flarum\Notification\Notification; class ReadNotificationHandler { @@ -20,7 +20,7 @@ class ReadNotificationHandler /** * @param ReadNotification $command - * @return \Flarum\Core\Notification + * @return \Flarum\Notification\Notification * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(ReadNotification $command) diff --git a/src/Core/CoreServiceProvider.php b/src/Core/CoreServiceProvider.php index 82e5f6b0d..dda6e1a28 100644 --- a/src/Core/CoreServiceProvider.php +++ b/src/Core/CoreServiceProvider.php @@ -40,7 +40,7 @@ class CoreServiceProvider extends AbstractServiceProvider $this->registerAvatarsFilesystem(); - $this->app->register('Flarum\Core\Notification\NotificationServiceProvider'); + $this->app->register('Flarum\Notification\Notification\NotificationServiceProvider'); $this->app->register('Flarum\Search\SearchServiceProvider'); $this->app->register('Flarum\Formatter\FormatterServiceProvider'); } diff --git a/src/Discussion/DiscussionRenamedNotifier.php b/src/Discussion/DiscussionRenamedNotifier.php index 2cd8bdc9c..d4cc7c5e4 100755 --- a/src/Discussion/DiscussionRenamedNotifier.php +++ b/src/Discussion/DiscussionRenamedNotifier.php @@ -11,8 +11,8 @@ namespace Flarum\Discussion; -use Flarum\Core\Notification\DiscussionRenamedBlueprint; -use Flarum\Core\Notification\NotificationSyncer; +use Flarum\Notification\Blueprint\DiscussionRenamedBlueprint; +use Flarum\Notification\NotificationSyncer; use Flarum\Post\DiscussionRenamedPost; use Flarum\Discussion\Event\Renamed; use Illuminate\Contracts\Events\Dispatcher; diff --git a/src/Event/ConfigureNotificationTypes.php b/src/Event/ConfigureNotificationTypes.php index 084701f0a..3c6eec2b7 100644 --- a/src/Event/ConfigureNotificationTypes.php +++ b/src/Event/ConfigureNotificationTypes.php @@ -11,7 +11,7 @@ namespace Flarum\Event; -use Flarum\Core\Notification\BlueprintInterface; +use Flarum\Notification\Blueprint\BlueprintInterface; use InvalidArgumentException; use ReflectionClass; diff --git a/src/Core/Notification/BlueprintInterface.php b/src/Notification/Blueprint/BlueprintInterface.php similarity index 96% rename from src/Core/Notification/BlueprintInterface.php rename to src/Notification/Blueprint/BlueprintInterface.php index 67bcc31ff..ed8273396 100644 --- a/src/Core/Notification/BlueprintInterface.php +++ b/src/Notification/Blueprint/BlueprintInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Notification; +namespace Flarum\Notification\Blueprint; /** * A notification BlueprintInterface, when instantiated, represents a notification about diff --git a/src/Core/Notification/DiscussionRenamedBlueprint.php b/src/Notification/Blueprint/DiscussionRenamedBlueprint.php similarity index 96% rename from src/Core/Notification/DiscussionRenamedBlueprint.php rename to src/Notification/Blueprint/DiscussionRenamedBlueprint.php index b642d82b9..996483c27 100644 --- a/src/Core/Notification/DiscussionRenamedBlueprint.php +++ b/src/Notification/Blueprint/DiscussionRenamedBlueprint.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Notification; +namespace Flarum\Notification\Blueprint; use Flarum\Post\DiscussionRenamedPost; diff --git a/src/Event/NotificationWillBeSent.php b/src/Notification/Event/Sending.php similarity index 79% rename from src/Event/NotificationWillBeSent.php rename to src/Notification/Event/Sending.php index 12a90ea9d..5633ada9a 100644 --- a/src/Event/NotificationWillBeSent.php +++ b/src/Notification/Event/Sending.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Notification\Event; -use Flarum\Core\Notification\BlueprintInterface; +use Flarum\Notification\Blueprint\BlueprintInterface; -class NotificationWillBeSent +class Sending { /** * The blueprint for the notification. @@ -30,7 +30,7 @@ class NotificationWillBeSent public $users; /** - * @param BlueprintInterface $blueprint + * @param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint * @param \Flarum\User\User[] $users */ public function __construct(BlueprintInterface $blueprint, array &$users) diff --git a/src/Core/Notification/MailableInterface.php b/src/Notification/MailableInterface.php similarity index 93% rename from src/Core/Notification/MailableInterface.php rename to src/Notification/MailableInterface.php index c276a32e9..0d059af8e 100644 --- a/src/Core/Notification/MailableInterface.php +++ b/src/Notification/MailableInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Notification; +namespace Flarum\Notification; interface MailableInterface { diff --git a/src/Core/Notification.php b/src/Notification/Notification.php similarity index 99% rename from src/Core/Notification.php rename to src/Notification/Notification.php index 4429cc4b3..6a32fdd36 100644 --- a/src/Core/Notification.php +++ b/src/Notification/Notification.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\Notification; use Flarum\Database\AbstractModel; diff --git a/src/Core/Notification/NotificationMailer.php b/src/Notification/NotificationMailer.php similarity index 96% rename from src/Core/Notification/NotificationMailer.php rename to src/Notification/NotificationMailer.php index 327f0252e..2bee77e5a 100644 --- a/src/Core/Notification/NotificationMailer.php +++ b/src/Notification/NotificationMailer.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Notification; +namespace Flarum\Notification; use Flarum\User\User; use Illuminate\Contracts\Mail\Mailer; diff --git a/src/Core/Repository/NotificationRepository.php b/src/Notification/NotificationRepository.php similarity index 96% rename from src/Core/Repository/NotificationRepository.php rename to src/Notification/NotificationRepository.php index 1b9fe63fb..ae70ea600 100644 --- a/src/Core/Repository/NotificationRepository.php +++ b/src/Notification/NotificationRepository.php @@ -9,9 +9,8 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Repository; +namespace Flarum\Notification; -use Flarum\Core\Notification; use Flarum\User\User; class NotificationRepository diff --git a/src/Core/Notification/NotificationServiceProvider.php b/src/Notification/NotificationServiceProvider.php similarity index 88% rename from src/Core/Notification/NotificationServiceProvider.php rename to src/Notification/NotificationServiceProvider.php index d8cf09474..811f3b61e 100644 --- a/src/Core/Notification/NotificationServiceProvider.php +++ b/src/Notification/NotificationServiceProvider.php @@ -9,9 +9,8 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Notification; +namespace Flarum\Notification; -use Flarum\Core\Notification; use Flarum\Event\ConfigureNotificationTypes; use Flarum\Foundation\AbstractServiceProvider; use Flarum\User\User; @@ -33,7 +32,7 @@ class NotificationServiceProvider extends AbstractServiceProvider public function registerNotificationTypes() { $blueprints = [ - 'Flarum\Core\Notification\DiscussionRenamedBlueprint' => ['alert'] + 'Flarum\Notification\Notification\DiscussionRenamedBlueprint' => ['alert'] ]; $this->app->make('events')->fire( @@ -52,7 +51,7 @@ class NotificationServiceProvider extends AbstractServiceProvider in_array('alert', $enabled) ); - if ((new ReflectionClass($blueprint))->implementsInterface('Flarum\Core\Notification\MailableInterface')) { + if ((new ReflectionClass($blueprint))->implementsInterface('Flarum\Notification\Notification\MailableInterface')) { User::addPreference( User::getNotificationPreferenceKey($type, 'email'), 'boolval', diff --git a/src/Core/Notification/NotificationSyncer.php b/src/Notification/NotificationSyncer.php similarity index 89% rename from src/Core/Notification/NotificationSyncer.php rename to src/Notification/NotificationSyncer.php index aab276b5b..5abef59e2 100644 --- a/src/Core/Notification/NotificationSyncer.php +++ b/src/Notification/NotificationSyncer.php @@ -9,12 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Notification; +namespace Flarum\Notification; use Carbon\Carbon; -use Flarum\Core\Notification; -use Flarum\Core\Repository\NotificationRepository; -use Flarum\Event\NotificationWillBeSent; +use Flarum\Notification\Event\Sending; +use Flarum\Notification\Blueprint\BlueprintInterface; use Flarum\User\User; /** @@ -66,11 +65,11 @@ class NotificationSyncer * visible to anyone else. If it is being made visible for the first time, * attempt to send the user an email. * - * @param BlueprintInterface $blueprint + * @param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint * @param User[] $users * @return void */ - public function sync(BlueprintInterface $blueprint, array $users) + public function sync(Blueprint\BlueprintInterface $blueprint, array $users) { $attributes = $this->getAttributes($blueprint); @@ -125,7 +124,7 @@ class NotificationSyncer /** * Delete a notification for all users. * - * @param BlueprintInterface $blueprint + * @param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint * @return void */ public function delete(BlueprintInterface $blueprint) @@ -165,14 +164,14 @@ class NotificationSyncer * Create a notification record and send an email (depending on user * preference) from a blueprint to a list of recipients. * - * @param BlueprintInterface $blueprint + * @param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint * @param User[] $recipients */ - protected function sendNotifications(BlueprintInterface $blueprint, array $recipients) + protected function sendNotifications(Blueprint\BlueprintInterface $blueprint, array $recipients) { $now = Carbon::now('utc')->toDateTimeString(); - event(new NotificationWillBeSent($blueprint, $recipients)); + event(new Sending($blueprint, $recipients)); $attributes = $this->getAttributes($blueprint); @@ -220,10 +219,10 @@ class NotificationSyncer * Construct an array of attributes to be stored in a notification record in * the database, given a notification blueprint. * - * @param BlueprintInterface $blueprint + * @param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint * @return array */ - protected function getAttributes(BlueprintInterface $blueprint) + protected function getAttributes(Blueprint\BlueprintInterface $blueprint) { return [ 'type' => $blueprint::getType(), diff --git a/src/User/User.php b/src/User/User.php index 70396e6ff..ea222484f 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -13,7 +13,7 @@ namespace Flarum\User; use DomainException; use Flarum\Group\Group; -use Flarum\Core\Notification; +use Flarum\Notification\Notification; use Flarum\Group\Permission; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; @@ -632,7 +632,7 @@ class User extends AbstractModel */ public function notifications() { - return $this->hasMany('Flarum\Core\Notification'); + return $this->hasMany('Flarum\Notification\Notification'); } /** From 8a16c1ecc88a202b796ec68cd39eaec932abcd1f Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 14:24:42 +0200 Subject: [PATCH 28/86] Move UserState class to Flarum\Discussion namespace --- src/Core/Command/ReadDiscussionHandler.php | 2 +- src/Discussion/Discussion.php | 10 +++++----- src/Discussion/Event/UserDataSaving.php | 8 ++++---- src/Discussion/Event/UserRead.php | 8 ++++---- .../DiscussionState.php => Discussion/UserState.php} | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) rename src/{Core/DiscussionState.php => Discussion/UserState.php} (97%) diff --git a/src/Core/Command/ReadDiscussionHandler.php b/src/Core/Command/ReadDiscussionHandler.php index 9be64074b..dea81e8b6 100644 --- a/src/Core/Command/ReadDiscussionHandler.php +++ b/src/Core/Command/ReadDiscussionHandler.php @@ -39,7 +39,7 @@ class ReadDiscussionHandler /** * @param ReadDiscussion $command - * @return \Flarum\Core\DiscussionState + * @return \Flarum\Discussion\UserState * @throws \Flarum\User\Exception\PermissionDeniedException */ public function handle(ReadDiscussion $command) diff --git a/src/Discussion/Discussion.php b/src/Discussion/Discussion.php index 0b06f632f..2c73a5aea 100644 --- a/src/Discussion/Discussion.php +++ b/src/Discussion/Discussion.php @@ -11,7 +11,7 @@ namespace Flarum\Discussion; -use Flarum\Core\DiscussionState; +use Flarum\Discussion\UserState; use Flarum\Post\MergeableInterface; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; @@ -44,7 +44,7 @@ use Flarum\Util\Str; * @property int|null $last_post_number * @property \Carbon\Carbon|null $hide_time * @property int|null $hide_user_id - * @property DiscussionState|null $state + * @property UserState|null $state * @property \Illuminate\Database\Eloquent\Collection $posts * @property \Illuminate\Database\Eloquent\Collection $comments * @property \Illuminate\Database\Eloquent\Collection $participants @@ -416,7 +416,7 @@ class Discussion extends AbstractModel { $user = $user ?: static::$stateUser; - return $this->hasOne('Flarum\Core\DiscussionState')->where('user_id', $user ? $user->id : null); + return $this->hasOne('Flarum\Discussion\UserState')->where('user_id', $user ? $user->id : null); } /** @@ -424,14 +424,14 @@ class Discussion extends AbstractModel * exist. * * @param User $user - * @return \Flarum\Core\DiscussionState + * @return \Flarum\Discussion\UserState */ public function stateFor(User $user) { $state = $this->state($user)->first(); if (! $state) { - $state = new DiscussionState; + $state = new UserState; $state->discussion_id = $this->id; $state->user_id = $user->id; } diff --git a/src/Discussion/Event/UserDataSaving.php b/src/Discussion/Event/UserDataSaving.php index 1574b44b6..52a85fe6b 100644 --- a/src/Discussion/Event/UserDataSaving.php +++ b/src/Discussion/Event/UserDataSaving.php @@ -11,19 +11,19 @@ namespace Flarum\Discussion\Event; -use Flarum\Core\DiscussionState; +use Flarum\Discussion\UserState; class UserDataSaving { /** - * @var DiscussionState + * @var \Flarum\Discussion\UserState */ public $state; /** - * @param DiscussionState $state + * @param \Flarum\Discussion\UserState $state */ - public function __construct(DiscussionState $state) + public function __construct(UserState $state) { $this->state = $state; } diff --git a/src/Discussion/Event/UserRead.php b/src/Discussion/Event/UserRead.php index 8baf3fc31..972a20129 100644 --- a/src/Discussion/Event/UserRead.php +++ b/src/Discussion/Event/UserRead.php @@ -11,19 +11,19 @@ namespace Flarum\Discussion\Event; -use Flarum\Core\DiscussionState; +use Flarum\Discussion\UserState; class UserRead { /** - * @var DiscussionState + * @var UserState */ public $state; /** - * @param DiscussionState $state + * @param UserState $state */ - public function __construct(DiscussionState $state) + public function __construct(UserState $state) { $this->state = $state; } diff --git a/src/Core/DiscussionState.php b/src/Discussion/UserState.php similarity index 97% rename from src/Core/DiscussionState.php rename to src/Discussion/UserState.php index be5e246fc..68a9ad714 100644 --- a/src/Core/DiscussionState.php +++ b/src/Discussion/UserState.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\Discussion; use Flarum\Discussion\Discussion; use Flarum\Foundation\EventGeneratorTrait; @@ -31,7 +31,7 @@ use Illuminate\Database\Eloquent\Builder; * @property Discussion $discussion * @property \Flarum\User\User $user */ -class DiscussionState extends AbstractModel +class UserState extends AbstractModel { use EventGeneratorTrait; From e71deed8d50e41ec7ecb0cf3fd2f570f4d430e4d Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 14:27:54 +0200 Subject: [PATCH 29/86] Move ExtensionValidator class to Flarum\Extension namespace --- src/Core/CoreServiceProvider.php | 2 +- .../DefaultLanguagePackGuard.php} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/{Core/Listener/ExtensionValidator.php => Extension/DefaultLanguagePackGuard.php} (95%) diff --git a/src/Core/CoreServiceProvider.php b/src/Core/CoreServiceProvider.php index dda6e1a28..f5b364f28 100644 --- a/src/Core/CoreServiceProvider.php +++ b/src/Core/CoreServiceProvider.php @@ -109,7 +109,7 @@ class CoreServiceProvider extends AbstractServiceProvider $events->subscribe('Flarum\Core\Listener\SelfDemotionGuard'); $events->subscribe('Flarum\Discussion\DiscussionMetadataUpdater'); $events->subscribe('Flarum\User\UserMetadataUpdater'); - $events->subscribe('Flarum\Core\Listener\ExtensionValidator'); + $events->subscribe('Flarum\Extension\DefaultLanguagePackGuard'); $events->subscribe('Flarum\User\EmailConfirmationMailer'); $events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier'); diff --git a/src/Core/Listener/ExtensionValidator.php b/src/Extension/DefaultLanguagePackGuard.php similarity index 95% rename from src/Core/Listener/ExtensionValidator.php rename to src/Extension/DefaultLanguagePackGuard.php index b7e3634d6..68afffd91 100644 --- a/src/Core/Listener/ExtensionValidator.php +++ b/src/Extension/DefaultLanguagePackGuard.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Listener; +namespace Flarum\Extension; use Flarum\Event\ExtensionWillBeDisabled; use Flarum\Http\Exception\ForbiddenException; use Illuminate\Contracts\Events\Dispatcher; -class ExtensionValidator +class DefaultLanguagePackGuard { /** * @param Dispatcher $events From e6e453177156dc550f26636073653aa8e72e041e Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 14:37:13 +0200 Subject: [PATCH 30/86] Fix class names in strings --- src/Notification/NotificationServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Notification/NotificationServiceProvider.php b/src/Notification/NotificationServiceProvider.php index 811f3b61e..3edbffcaa 100644 --- a/src/Notification/NotificationServiceProvider.php +++ b/src/Notification/NotificationServiceProvider.php @@ -32,7 +32,7 @@ class NotificationServiceProvider extends AbstractServiceProvider public function registerNotificationTypes() { $blueprints = [ - 'Flarum\Notification\Notification\DiscussionRenamedBlueprint' => ['alert'] + 'Flarum\Notification\Blueprint\DiscussionRenamedBlueprint' => ['alert'] ]; $this->app->make('events')->fire( @@ -51,7 +51,7 @@ class NotificationServiceProvider extends AbstractServiceProvider in_array('alert', $enabled) ); - if ((new ReflectionClass($blueprint))->implementsInterface('Flarum\Notification\Notification\MailableInterface')) { + if ((new ReflectionClass($blueprint))->implementsInterface('Flarum\Notification\MailableInterface')) { User::addPreference( User::getNotificationPreferenceKey($type, 'email'), 'boolval', From 66f35d2530e939fa104bc08fc3d273f584aa3fff Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 14:51:42 +0200 Subject: [PATCH 31/86] Split up old CoreServiceProvider --- src/BusServiceProvider.php | 30 ++++++++++++ src/Discussion/DiscussionServiceProvider.php | 29 +++++++++++ src/Extension/ExtensionServiceProvider.php | 10 ++++ src/Foundation/AbstractServer.php | 11 ++++- src/Frontend/FrontendServiceProvider.php | 25 ++++++++++ src/Group/GroupServiceProvider.php | 26 ++++++++++ src/Install/Console/InstallCommand.php | 8 ++- src/Post/PostServiceProvider.php | 47 ++++++++++++++++++ .../UserServiceProvider.php} | 49 ++----------------- 9 files changed, 187 insertions(+), 48 deletions(-) create mode 100644 src/BusServiceProvider.php create mode 100644 src/Discussion/DiscussionServiceProvider.php create mode 100644 src/Frontend/FrontendServiceProvider.php create mode 100644 src/Group/GroupServiceProvider.php create mode 100644 src/Post/PostServiceProvider.php rename src/{Core/CoreServiceProvider.php => User/UserServiceProvider.php} (68%) diff --git a/src/BusServiceProvider.php b/src/BusServiceProvider.php new file mode 100644 index 000000000..4406460f6 --- /dev/null +++ b/src/BusServiceProvider.php @@ -0,0 +1,30 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum; + +use Flarum\Foundation\AbstractServiceProvider; + +/** + * @deprecated + */ +class BusServiceProvider extends AbstractServiceProvider +{ + /** + * {@inheritdoc} + */ + public function boot() + { + $this->app->make('Illuminate\Contracts\Bus\Dispatcher')->mapUsing(function ($command) { + return get_class($command).'Handler@handle'; + }); + } +} diff --git a/src/Discussion/DiscussionServiceProvider.php b/src/Discussion/DiscussionServiceProvider.php new file mode 100644 index 000000000..89b9ce30d --- /dev/null +++ b/src/Discussion/DiscussionServiceProvider.php @@ -0,0 +1,29 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Discussion; + +use Flarum\Foundation\AbstractServiceProvider; + +class DiscussionServiceProvider extends AbstractServiceProvider +{ + /** + * {@inheritdoc} + */ + public function boot() + { + $events = $this->app->make('events'); + + $events->subscribe('Flarum\Discussion\DiscussionMetadataUpdater'); + $events->subscribe('Flarum\Discussion\DiscussionPolicy'); + $events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier'); + } +} diff --git a/src/Extension/ExtensionServiceProvider.php b/src/Extension/ExtensionServiceProvider.php index 522f9d9e5..a421b1865 100644 --- a/src/Extension/ExtensionServiceProvider.php +++ b/src/Extension/ExtensionServiceProvider.php @@ -30,4 +30,14 @@ class ExtensionServiceProvider extends AbstractServiceProvider $this->app->call($bootstrapper); } } + + /** + * {@inheritdoc} + */ + public function boot() + { + $events = $this->app->make('events'); + + $events->subscribe('Flarum\Extension\DefaultLanguagePackGuard'); + } } diff --git a/src/Foundation/AbstractServer.php b/src/Foundation/AbstractServer.php index 34ef520d2..bcc7c534b 100644 --- a/src/Foundation/AbstractServer.php +++ b/src/Foundation/AbstractServer.php @@ -190,7 +190,16 @@ abstract class AbstractServer $config->set('mail.username', $settings->get('mail_username')); $config->set('mail.password', $settings->get('mail_password')); - $app->register('Flarum\Core\CoreServiceProvider'); + $app->register('Flarum\BusServiceProvider'); + + $app->register('Flarum\Discussion\DiscussionServiceProvider'); + $app->register('Flarum\Formatter\FormatterServiceProvider'); + $app->register('Flarum\Group\GroupServiceProvider'); + $app->register('Flarum\Notification\NotificationServiceProvider'); + $app->register('Flarum\Post\PostServiceProvider'); + $app->register('Flarum\Search\SearchServiceProvider'); + $app->register('Flarum\User\UserServiceProvider'); + $app->register('Flarum\Api\ApiServiceProvider'); $app->register('Flarum\Forum\ForumServiceProvider'); $app->register('Flarum\Admin\AdminServiceProvider'); diff --git a/src/Frontend/FrontendServiceProvider.php b/src/Frontend/FrontendServiceProvider.php new file mode 100644 index 000000000..aa4ba6064 --- /dev/null +++ b/src/Frontend/FrontendServiceProvider.php @@ -0,0 +1,25 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Frontend; + +use Flarum\Foundation\AbstractServiceProvider; + +class FrontendServiceProvider extends AbstractServiceProvider +{ + /** + * {@inheritdoc} + */ + public function boot() + { + $this->loadViewsFrom(__DIR__.'/../../views', 'flarum'); + } +} diff --git a/src/Group/GroupServiceProvider.php b/src/Group/GroupServiceProvider.php new file mode 100644 index 000000000..bdf1ceb15 --- /dev/null +++ b/src/Group/GroupServiceProvider.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Group; + +use Flarum\Foundation\AbstractServiceProvider; + +class GroupServiceProvider extends AbstractServiceProvider +{ + /** + * {@inheritdoc} + */ + public function boot() + { + $events = $this->app->make('events'); + $events->subscribe('Flarum\Group\GroupPolicy'); + } +} diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index ace02e89b..c75928601 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -171,7 +171,13 @@ class InstallCommand extends AbstractCommand $this->writeSettings(); - $this->application->register('Flarum\Core\CoreServiceProvider'); + $this->application->register('Flarum\Formatter\FormatterServiceProvider'); + $this->application->register('Flarum\Discussion\DiscussionServiceProvider'); + $this->application->register('Flarum\Group\GroupServiceProvider'); + $this->application->register('Flarum\Notification\NotificationServiceProvider'); + $this->application->register('Flarum\Search\SearchServiceProvider'); + $this->application->register('Flarum\Post\PostServiceProvider'); + $this->application->register('Flarum\User\UserServiceProvider'); $this->seedGroups(); $this->seedPermissions(); diff --git a/src/Post/PostServiceProvider.php b/src/Post/PostServiceProvider.php new file mode 100644 index 000000000..b597f875c --- /dev/null +++ b/src/Post/PostServiceProvider.php @@ -0,0 +1,47 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Post; + +use Flarum\Event\ConfigurePostTypes; +use Flarum\Foundation\AbstractServiceProvider; + +class PostServiceProvider extends AbstractServiceProvider +{ + /** + * {@inheritdoc} + */ + public function boot() + { + CommentPost::setFormatter($this->app->make('flarum.formatter')); + + $this->registerPostTypes(); + + $events = $this->app->make('events'); + $events->subscribe('Flarum\Post\PostPolicy'); + } + + public function registerPostTypes() + { + $models = [ + 'Flarum\Post\CommentPost', + 'Flarum\Post\DiscussionRenamedPost' + ]; + + $this->app->make('events')->fire( + new ConfigurePostTypes($models) + ); + + foreach ($models as $model) { + Post::setModel($model::$type, $model); + } + } +} diff --git a/src/Core/CoreServiceProvider.php b/src/User/UserServiceProvider.php similarity index 68% rename from src/Core/CoreServiceProvider.php rename to src/User/UserServiceProvider.php index f5b364f28..45a7e8a24 100644 --- a/src/Core/CoreServiceProvider.php +++ b/src/User/UserServiceProvider.php @@ -9,20 +9,14 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\User; -use Flarum\Post\CommentPost; -use Flarum\Event\ConfigurePostTypes; use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\GetPermission; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Post\Post; -use Flarum\User\Gate; -use Flarum\User\User; use Illuminate\Contracts\Container\Container; -use RuntimeException; -class CoreServiceProvider extends AbstractServiceProvider +class UserServiceProvider extends AbstractServiceProvider { /** * {@inheritdoc} @@ -39,10 +33,6 @@ class CoreServiceProvider extends AbstractServiceProvider $this->app->alias('flarum.gate', 'Flarum\User\Gate'); $this->registerAvatarsFilesystem(); - - $this->app->register('Flarum\Notification\Notification\NotificationServiceProvider'); - $this->app->register('Flarum\Search\SearchServiceProvider'); - $this->app->register('Flarum\Formatter\FormatterServiceProvider'); } protected function registerAvatarsFilesystem() @@ -69,12 +59,6 @@ class CoreServiceProvider extends AbstractServiceProvider */ public function boot() { - $this->loadViewsFrom(__DIR__.'/../../views', 'flarum'); - - $this->app->make('Illuminate\Contracts\Bus\Dispatcher')->mapUsing(function ($command) { - return get_class($command).'Handler@handle'; - }); - $this->app->make('flarum.gate')->before(function (User $actor, $ability, $model = null) { // Fire an event so that core and extension policies can hook into // this permission query and explicitly grant or deny the @@ -97,46 +81,19 @@ class CoreServiceProvider extends AbstractServiceProvider return false; }); - $this->registerPostTypes(); - - CommentPost::setFormatter($this->app->make('flarum.formatter')); - User::setHasher($this->app->make('hash')); User::setGate($this->app->make('flarum.gate')); $events = $this->app->make('events'); $events->subscribe('Flarum\Core\Listener\SelfDemotionGuard'); - $events->subscribe('Flarum\Discussion\DiscussionMetadataUpdater'); - $events->subscribe('Flarum\User\UserMetadataUpdater'); - $events->subscribe('Flarum\Extension\DefaultLanguagePackGuard'); $events->subscribe('Flarum\User\EmailConfirmationMailer'); - $events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier'); - - $events->subscribe('Flarum\Discussion\DiscussionPolicy'); - $events->subscribe('Flarum\Group\GroupPolicy'); - $events->subscribe('Flarum\Post\PostPolicy'); + $events->subscribe('Flarum\User\UserMetadataUpdater'); $events->subscribe('Flarum\User\UserPolicy'); $events->listen(ConfigureUserPreferences::class, [$this, 'configureUserPreferences']); } - public function registerPostTypes() - { - $models = [ - 'Flarum\Post\CommentPost', - 'Flarum\Post\DiscussionRenamedPost' - ]; - - $this->app->make('events')->fire( - new ConfigurePostTypes($models) - ); - - foreach ($models as $model) { - Post::setModel($model::$type, $model); - } - } - /** * @param ConfigureUserPreferences $event */ From a39ed6edec4a7bc2529fb75468852f48c63a37a3 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 14:55:47 +0200 Subject: [PATCH 32/86] Rename listener class to DiscussionRenamedLogger --- ...iscussionRenamedNotifier.php => DiscussionRenamedLogger.php} | 2 +- src/Discussion/DiscussionServiceProvider.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/Discussion/{DiscussionRenamedNotifier.php => DiscussionRenamedLogger.php} (98%) diff --git a/src/Discussion/DiscussionRenamedNotifier.php b/src/Discussion/DiscussionRenamedLogger.php similarity index 98% rename from src/Discussion/DiscussionRenamedNotifier.php rename to src/Discussion/DiscussionRenamedLogger.php index d4cc7c5e4..8ccf74ff9 100755 --- a/src/Discussion/DiscussionRenamedNotifier.php +++ b/src/Discussion/DiscussionRenamedLogger.php @@ -17,7 +17,7 @@ use Flarum\Post\DiscussionRenamedPost; use Flarum\Discussion\Event\Renamed; use Illuminate\Contracts\Events\Dispatcher; -class DiscussionRenamedNotifier +class DiscussionRenamedLogger { /** * @var NotificationSyncer diff --git a/src/Discussion/DiscussionServiceProvider.php b/src/Discussion/DiscussionServiceProvider.php index 89b9ce30d..5f8ca4216 100644 --- a/src/Discussion/DiscussionServiceProvider.php +++ b/src/Discussion/DiscussionServiceProvider.php @@ -24,6 +24,6 @@ class DiscussionServiceProvider extends AbstractServiceProvider $events->subscribe('Flarum\Discussion\DiscussionMetadataUpdater'); $events->subscribe('Flarum\Discussion\DiscussionPolicy'); - $events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier'); + $events->subscribe('Flarum\Discussion\DiscussionRenamedLogger'); } } From 95dc7e71f452bee5e53f6cfda0cbb9d502d097e2 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 15:04:46 +0200 Subject: [PATCH 33/86] Fix namespaces --- src/Api/Controller/ListUsersController.php | 2 +- src/Event/ConfigureUserSearch.php | 4 ++-- src/Post/Post.php | 2 +- src/Search/SearchServiceProvider.php | 8 ++++---- src/User/EmailToken.php | 2 +- src/User/PasswordToken.php | 2 +- src/User/Search/Gambit/EmailGambit.php | 6 +++--- src/User/Search/Gambit/FulltextGambit.php | 4 ++-- src/User/Search/Gambit/GroupGambit.php | 4 ++-- src/User/Search/UserSearch.php | 2 +- src/User/Search/UserSearcher.php | 15 +++++++-------- 11 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/Api/Controller/ListUsersController.php b/src/Api/Controller/ListUsersController.php index 1dadbb103..f953e33b4 100644 --- a/src/Api/Controller/ListUsersController.php +++ b/src/Api/Controller/ListUsersController.php @@ -14,7 +14,7 @@ namespace Flarum\Api\Controller; use Flarum\Api\UrlGenerator; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Search\SearchCriteria; -use Flarum\Core\User\Search\UserSearcher; +use Flarum\User\Search\UserSearcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Event/ConfigureUserSearch.php b/src/Event/ConfigureUserSearch.php index 309f60c10..1b9a235e4 100644 --- a/src/Event/ConfigureUserSearch.php +++ b/src/Event/ConfigureUserSearch.php @@ -12,12 +12,12 @@ namespace Flarum\Event; use Flarum\Search\SearchCriteria; -use Flarum\Core\User\Search\UserSearch; +use Flarum\User\Search\UserSearch; class ConfigureUserSearch { /** - * @var \Flarum\Core\User\Search\UserSearch + * @var \Flarum\User\Search\UserSearch */ public $search; diff --git a/src/Post/Post.php b/src/Post/Post.php index 468a708fb..c85538582 100755 --- a/src/Post/Post.php +++ b/src/Post/Post.php @@ -11,11 +11,11 @@ namespace Flarum\Post; -use Flarum\Core\User; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Post\Event\Deleted; +use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; /** diff --git a/src/Search/SearchServiceProvider.php b/src/Search/SearchServiceProvider.php index 9b2ded54b..71d316d54 100644 --- a/src/Search/SearchServiceProvider.php +++ b/src/Search/SearchServiceProvider.php @@ -37,14 +37,14 @@ class SearchServiceProvider extends AbstractServiceProvider public function registerUserGambits() { - $this->app->when('Flarum\Core\User\Search\UserSearcher') + $this->app->when('Flarum\User\Search\UserSearcher') ->needs('Flarum\Search\GambitManager') ->give(function (Container $app) { $gambits = new GambitManager($app); - $gambits->setFulltextGambit('Flarum\Core\User\Search\Gambit\FulltextGambit'); - $gambits->add('Flarum\Core\User\Search\Gambit\EmailGambit'); - $gambits->add('Flarum\Core\User\Search\Gambit\GroupGambit'); + $gambits->setFulltextGambit('Flarum\User\Search\Gambit\FulltextGambit'); + $gambits->add('Flarum\User\Search\Gambit\EmailGambit'); + $gambits->add('Flarum\User\Search\Gambit\GroupGambit'); $app->make('events')->fire( new ConfigureUserGambits($gambits) diff --git a/src/User/EmailToken.php b/src/User/EmailToken.php index e0383f2ff..f60d35c89 100644 --- a/src/User/EmailToken.php +++ b/src/User/EmailToken.php @@ -64,7 +64,7 @@ class EmailToken extends AbstractModel */ public function user() { - return $this->belongsTo('Flarum\Core\User'); + return $this->belongsTo('Flarum\User'); } /** diff --git a/src/User/PasswordToken.php b/src/User/PasswordToken.php index 190d1d27a..53b955eda 100644 --- a/src/User/PasswordToken.php +++ b/src/User/PasswordToken.php @@ -59,6 +59,6 @@ class PasswordToken extends AbstractModel */ public function user() { - return $this->belongsTo('Flarum\Core\User'); + return $this->belongsTo('Flarum\User'); } } diff --git a/src/User/Search/Gambit/EmailGambit.php b/src/User/Search/Gambit/EmailGambit.php index 3d12c02ed..c44ebc1ba 100644 --- a/src/User/Search/Gambit/EmailGambit.php +++ b/src/User/Search/Gambit/EmailGambit.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\User\Search\Gambit; +namespace Flarum\User\Search\Gambit; -use Flarum\User\UserRepository; use Flarum\Search\AbstractRegexGambit; use Flarum\Search\AbstractSearch; -use Flarum\Core\User\Search\UserSearch; +use Flarum\User\Search\UserSearch; +use Flarum\User\UserRepository; use LogicException; class EmailGambit extends AbstractRegexGambit diff --git a/src/User/Search/Gambit/FulltextGambit.php b/src/User/Search/Gambit/FulltextGambit.php index 0d2c02baa..a41821693 100644 --- a/src/User/Search/Gambit/FulltextGambit.php +++ b/src/User/Search/Gambit/FulltextGambit.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\User\Search\Gambit; +namespace Flarum\User\Search\Gambit; -use Flarum\User\UserRepository; use Flarum\Search\AbstractSearch; use Flarum\Search\GambitInterface; +use Flarum\User\UserRepository; class FulltextGambit implements GambitInterface { diff --git a/src/User/Search/Gambit/GroupGambit.php b/src/User/Search/Gambit/GroupGambit.php index 317ea8232..e690d93e5 100644 --- a/src/User/Search/Gambit/GroupGambit.php +++ b/src/User/Search/Gambit/GroupGambit.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\User\Search\Gambit; +namespace Flarum\User\Search\Gambit; use Flarum\Group\GroupRepository; use Flarum\Search\AbstractRegexGambit; use Flarum\Search\AbstractSearch; -use Flarum\Core\User\Search\UserSearch; +use Flarum\User\Search\UserSearch; use LogicException; class GroupGambit extends AbstractRegexGambit diff --git a/src/User/Search/UserSearch.php b/src/User/Search/UserSearch.php index d26620f5e..d3a7ba28b 100644 --- a/src/User/Search/UserSearch.php +++ b/src/User/Search/UserSearch.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\User\Search; +namespace Flarum\User\Search; use Flarum\Search\AbstractSearch; diff --git a/src/User/Search/UserSearcher.php b/src/User/Search/UserSearcher.php index 13b0838aa..2cb5cab2b 100644 --- a/src/User/Search/UserSearcher.php +++ b/src/User/Search/UserSearcher.php @@ -9,9 +9,8 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\User\Search; +namespace Flarum\User\Search; -use Flarum\Core\User\Search\UserSearch; use Flarum\User\UserRepository; use Flarum\Search\ApplySearchParametersTrait; use Flarum\Search\GambitManager; @@ -28,7 +27,7 @@ class UserSearcher use ApplySearchParametersTrait; /** - * @var \Flarum\Search\GambitManager + * @var GambitManager */ protected $gambits; @@ -38,10 +37,10 @@ class UserSearcher protected $users; /** - * @param \Flarum\Search\GambitManager $gambits + * @param GambitManager $gambits * @param \Flarum\User\UserRepository $users */ - public function __construct(\Flarum\Search\GambitManager $gambits, UserRepository $users) + public function __construct(GambitManager $gambits, UserRepository $users) { $this->gambits = $gambits; $this->users = $users; @@ -52,9 +51,9 @@ class UserSearcher * @param int|null $limit * @param int $offset * @param array $load An array of relationships to load on the results. - * @return \Flarum\Search\SearchResults + * @return SearchResults */ - public function search(\Flarum\Search\SearchCriteria $criteria, $limit = null, $offset = 0, array $load = []) + public function search(SearchCriteria $criteria, $limit = null, $offset = 0, array $load = []) { $actor = $criteria->actor; @@ -83,6 +82,6 @@ class UserSearcher $users->load($load); - return new \Flarum\Search\SearchResults($users, $areMoreResults); + return new SearchResults($users, $areMoreResults); } } From 5b0d0d9f0f1a47c94e28e8341f12dd0871e19a83 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 15:21:07 +0200 Subject: [PATCH 34/86] Move command classes to domain namespaces They will probably be refactored away at a later stage (when we get rid of the command bus). Until then, this lets us remove the Flarum\Core namespace and actually feels quite clean. --- src/Api/Controller/CreateDiscussionController.php | 4 ++-- src/Api/Controller/CreateGroupController.php | 2 +- src/Api/Controller/CreatePostController.php | 4 ++-- src/Api/Controller/CreateUserController.php | 2 +- src/Api/Controller/DeleteAvatarController.php | 2 +- src/Api/Controller/DeleteDiscussionController.php | 2 +- src/Api/Controller/DeleteGroupController.php | 2 +- src/Api/Controller/DeletePostController.php | 2 +- src/Api/Controller/DeleteUserController.php | 2 +- src/Api/Controller/ForgotPasswordController.php | 2 +- src/Api/Controller/ReadAllNotificationsController.php | 2 +- src/Api/Controller/UpdateDiscussionController.php | 4 ++-- src/Api/Controller/UpdateGroupController.php | 2 +- src/Api/Controller/UpdateNotificationController.php | 2 +- src/Api/Controller/UpdatePostController.php | 2 +- src/Api/Controller/UpdateUserController.php | 2 +- src/Api/Controller/UploadAvatarController.php | 2 +- src/{Core => Discussion}/Command/DeleteDiscussion.php | 2 +- .../Command/DeleteDiscussionHandler.php | 8 ++++---- src/{Core => Discussion}/Command/EditDiscussion.php | 2 +- .../Command/EditDiscussionHandler.php | 7 +++---- src/{Core => Discussion}/Command/ReadDiscussion.php | 2 +- .../Command/ReadDiscussionHandler.php | 6 +++--- src/{Core => Discussion}/Command/StartDiscussion.php | 2 +- .../Command/StartDiscussionHandler.php | 6 +++--- src/Forum/Controller/ConfirmEmailController.php | 4 ++-- src/{Core => Group}/Command/CreateGroup.php | 2 +- src/{Core => Group}/Command/CreateGroupHandler.php | 8 ++++---- src/{Core => Group}/Command/DeleteGroup.php | 2 +- src/{Core => Group}/Command/DeleteGroupHandler.php | 8 ++++---- src/{Core => Group}/Command/EditGroup.php | 2 +- src/{Core => Group}/Command/EditGroupHandler.php | 10 +++++----- .../Command/ReadAllNotifications.php | 2 +- .../Command/ReadAllNotificationsHandler.php | 4 ++-- .../Command/ReadNotification.php | 2 +- .../Command/ReadNotificationHandler.php | 4 ++-- src/{Core => Post}/Command/DeletePost.php | 2 +- src/{Core => Post}/Command/DeletePostHandler.php | 7 +++---- src/{Core => Post}/Command/EditPost.php | 2 +- src/{Core => Post}/Command/EditPostHandler.php | 10 +++++----- src/{Core => Post}/Command/PostReply.php | 2 +- src/{Core => Post}/Command/PostReplyHandler.php | 10 +++++----- src/{Core => User}/Command/ConfirmEmail.php | 2 +- src/{Core => User}/Command/ConfirmEmailHandler.php | 6 +++--- src/{Core => User}/Command/DeleteAvatar.php | 2 +- src/{Core => User}/Command/DeleteAvatarHandler.php | 9 ++++----- src/{Core => User}/Command/DeleteUser.php | 2 +- src/{Core => User}/Command/DeleteUserHandler.php | 6 +++--- src/{Core => User}/Command/EditUser.php | 2 +- src/{Core => User}/Command/EditUserHandler.php | 10 +++++----- src/{Core => User}/Command/RegisterUser.php | 2 +- src/{Core => User}/Command/RegisterUserHandler.php | 10 +++++----- src/{Core => User}/Command/RequestPasswordReset.php | 2 +- .../Command/RequestPasswordResetHandler.php | 7 +++---- src/{Core => User}/Command/UploadAvatar.php | 2 +- src/{Core => User}/Command/UploadAvatarHandler.php | 10 +++++----- src/User/UserServiceProvider.php | 6 +++--- 57 files changed, 115 insertions(+), 119 deletions(-) rename src/{Core => Discussion}/Command/DeleteDiscussion.php (96%) rename src/{Core => Discussion}/Command/DeleteDiscussionHandler.php (97%) rename src/{Core => Discussion}/Command/EditDiscussion.php (96%) rename src/{Core => Discussion}/Command/EditDiscussionHandler.php (96%) rename src/{Core => Discussion}/Command/ReadDiscussion.php (96%) rename src/{Core => Discussion}/Command/ReadDiscussionHandler.php (97%) rename src/{Core => Discussion}/Command/StartDiscussion.php (95%) rename src/{Core => Discussion}/Command/StartDiscussionHandler.php (98%) rename src/{Core => Group}/Command/CreateGroup.php (95%) rename src/{Core => Group}/Command/CreateGroupHandler.php (98%) rename src/{Core => Group}/Command/DeleteGroup.php (97%) rename src/{Core => Group}/Command/DeleteGroupHandler.php (97%) rename src/{Core => Group}/Command/EditGroup.php (96%) rename src/{Core => Group}/Command/EditGroupHandler.php (98%) rename src/{Core => Notification}/Command/ReadAllNotifications.php (93%) rename src/{Core => Notification}/Command/ReadAllNotificationsHandler.php (96%) rename src/{Core => Notification}/Command/ReadNotification.php (95%) rename src/{Core => Notification}/Command/ReadNotificationHandler.php (96%) rename src/{Core => Post}/Command/DeletePost.php (97%) rename src/{Core => Post}/Command/DeletePostHandler.php (94%) rename src/{Core => Post}/Command/EditPost.php (96%) rename src/{Core => Post}/Command/EditPostHandler.php (98%) rename src/{Core => Post}/Command/PostReply.php (97%) rename src/{Core => Post}/Command/PostReplyHandler.php (99%) rename src/{Core => User}/Command/ConfirmEmail.php (94%) rename src/{Core => User}/Command/ConfirmEmailHandler.php (93%) rename src/{Core => User}/Command/DeleteAvatar.php (96%) rename src/{Core => User}/Command/DeleteAvatarHandler.php (95%) rename src/{Core => User}/Command/DeleteUser.php (97%) rename src/{Core => User}/Command/DeleteUserHandler.php (97%) rename src/{Core => User}/Command/EditUser.php (96%) rename src/{Core => User}/Command/EditUserHandler.php (99%) rename src/{Core => User}/Command/RegisterUser.php (95%) rename src/{Core => User}/Command/RegisterUserHandler.php (99%) rename src/{Core => User}/Command/RequestPasswordReset.php (94%) rename src/{Core => User}/Command/RequestPasswordResetHandler.php (98%) rename src/{Core => User}/Command/UploadAvatar.php (97%) rename src/{Core => User}/Command/UploadAvatarHandler.php (99%) diff --git a/src/Api/Controller/CreateDiscussionController.php b/src/Api/Controller/CreateDiscussionController.php index ab6eb9cde..69f2afc15 100644 --- a/src/Api/Controller/CreateDiscussionController.php +++ b/src/Api/Controller/CreateDiscussionController.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\ReadDiscussion; -use Flarum\Core\Command\StartDiscussion; +use Flarum\Discussion\Command\ReadDiscussion; +use Flarum\Discussion\Command\StartDiscussion; use Flarum\Post\Floodgate; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/CreateGroupController.php b/src/Api/Controller/CreateGroupController.php index 977ae9c62..9bf23052f 100644 --- a/src/Api/Controller/CreateGroupController.php +++ b/src/Api/Controller/CreateGroupController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\CreateGroup; +use Flarum\Group\Command\CreateGroup; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/CreatePostController.php b/src/Api/Controller/CreatePostController.php index a268b7d21..fc7432530 100644 --- a/src/Api/Controller/CreatePostController.php +++ b/src/Api/Controller/CreatePostController.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\PostReply; -use Flarum\Core\Command\ReadDiscussion; +use Flarum\Discussion\Command\ReadDiscussion; +use Flarum\Post\Command\PostReply; use Flarum\Post\Floodgate; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/CreateUserController.php b/src/Api/Controller/CreateUserController.php index 608cd039d..155f862ac 100644 --- a/src/Api/Controller/CreateUserController.php +++ b/src/Api/Controller/CreateUserController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\RegisterUser; +use Flarum\User\Command\RegisterUser; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/DeleteAvatarController.php b/src/Api/Controller/DeleteAvatarController.php index 73cbe9dd1..61ab87109 100644 --- a/src/Api/Controller/DeleteAvatarController.php +++ b/src/Api/Controller/DeleteAvatarController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\DeleteAvatar; +use Flarum\User\Command\DeleteAvatar; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/DeleteDiscussionController.php b/src/Api/Controller/DeleteDiscussionController.php index 793c34273..17c0206d6 100644 --- a/src/Api/Controller/DeleteDiscussionController.php +++ b/src/Api/Controller/DeleteDiscussionController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\DeleteDiscussion; +use Flarum\Discussion\Command\DeleteDiscussion; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/DeleteGroupController.php b/src/Api/Controller/DeleteGroupController.php index 051edea19..e4f1adb61 100644 --- a/src/Api/Controller/DeleteGroupController.php +++ b/src/Api/Controller/DeleteGroupController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\DeleteGroup; +use Flarum\Group\Command\DeleteGroup; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/DeletePostController.php b/src/Api/Controller/DeletePostController.php index 1b3ea47e1..eb1bd812c 100644 --- a/src/Api/Controller/DeletePostController.php +++ b/src/Api/Controller/DeletePostController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\DeletePost; +use Flarum\Post\Command\DeletePost; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/DeleteUserController.php b/src/Api/Controller/DeleteUserController.php index 6f3a7fb42..2d00d8897 100644 --- a/src/Api/Controller/DeleteUserController.php +++ b/src/Api/Controller/DeleteUserController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\DeleteUser; +use Flarum\User\Command\DeleteUser; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/ForgotPasswordController.php b/src/Api/Controller/ForgotPasswordController.php index 5516c6d47..56e638878 100644 --- a/src/Api/Controller/ForgotPasswordController.php +++ b/src/Api/Controller/ForgotPasswordController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\RequestPasswordReset; +use Flarum\User\Command\RequestPasswordReset; use Flarum\User\UserRepository; use Flarum\Http\Controller\ControllerInterface; use Illuminate\Contracts\Bus\Dispatcher; diff --git a/src/Api/Controller/ReadAllNotificationsController.php b/src/Api/Controller/ReadAllNotificationsController.php index 231f743ff..c60230fa5 100644 --- a/src/Api/Controller/ReadAllNotificationsController.php +++ b/src/Api/Controller/ReadAllNotificationsController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\ReadAllNotifications; +use Flarum\Notification\Command\ReadAllNotifications; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/UpdateDiscussionController.php b/src/Api/Controller/UpdateDiscussionController.php index 09ba078c5..4cdd3a0a1 100644 --- a/src/Api/Controller/UpdateDiscussionController.php +++ b/src/Api/Controller/UpdateDiscussionController.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\EditDiscussion; -use Flarum\Core\Command\ReadDiscussion; +use Flarum\Discussion\Command\EditDiscussion; +use Flarum\Discussion\Command\ReadDiscussion; use Illuminate\Contracts\Bus\Dispatcher; use Illuminate\Database\Eloquent\Collection; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/UpdateGroupController.php b/src/Api/Controller/UpdateGroupController.php index ccb6a8b6e..c4bd8f5dd 100644 --- a/src/Api/Controller/UpdateGroupController.php +++ b/src/Api/Controller/UpdateGroupController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\EditGroup; +use Flarum\Group\Command\EditGroup; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/UpdateNotificationController.php b/src/Api/Controller/UpdateNotificationController.php index 01e305bc7..f459e0338 100644 --- a/src/Api/Controller/UpdateNotificationController.php +++ b/src/Api/Controller/UpdateNotificationController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\ReadNotification; +use Flarum\Notification\Command\ReadNotification; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/UpdatePostController.php b/src/Api/Controller/UpdatePostController.php index bb5a5f08a..6f13e3371 100644 --- a/src/Api/Controller/UpdatePostController.php +++ b/src/Api/Controller/UpdatePostController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\EditPost; +use Flarum\Post\Command\EditPost; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/UpdateUserController.php b/src/Api/Controller/UpdateUserController.php index 818e4d941..42a57754a 100644 --- a/src/Api/Controller/UpdateUserController.php +++ b/src/Api/Controller/UpdateUserController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\EditUser; +use Flarum\User\Command\EditUser; use Flarum\User\Exception\PermissionDeniedException; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/UploadAvatarController.php b/src/Api/Controller/UploadAvatarController.php index ac3619d24..b2e23e33b 100644 --- a/src/Api/Controller/UploadAvatarController.php +++ b/src/Api/Controller/UploadAvatarController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Command\UploadAvatar; +use Flarum\User\Command\UploadAvatar; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Core/Command/DeleteDiscussion.php b/src/Discussion/Command/DeleteDiscussion.php similarity index 96% rename from src/Core/Command/DeleteDiscussion.php rename to src/Discussion/Command/DeleteDiscussion.php index 3c4d1219b..f79525fb6 100644 --- a/src/Core/Command/DeleteDiscussion.php +++ b/src/Discussion/Command/DeleteDiscussion.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Discussion\Command; use Flarum\User\User; diff --git a/src/Core/Command/DeleteDiscussionHandler.php b/src/Discussion/Command/DeleteDiscussionHandler.php similarity index 97% rename from src/Core/Command/DeleteDiscussionHandler.php rename to src/Discussion/Command/DeleteDiscussionHandler.php index 9643b5e96..de0bb03b3 100644 --- a/src/Core/Command/DeleteDiscussionHandler.php +++ b/src/Discussion/Command/DeleteDiscussionHandler.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Discussion\Command; +use Flarum\Discussion\DiscussionRepository; +use Flarum\Discussion\Event\Deleting; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Discussion\DiscussionRepository; -use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Discussion\Event\Deleting; use Illuminate\Contracts\Events\Dispatcher; class DeleteDiscussionHandler diff --git a/src/Core/Command/EditDiscussion.php b/src/Discussion/Command/EditDiscussion.php similarity index 96% rename from src/Core/Command/EditDiscussion.php rename to src/Discussion/Command/EditDiscussion.php index 4ae77a276..660ed8b0d 100644 --- a/src/Core/Command/EditDiscussion.php +++ b/src/Discussion/Command/EditDiscussion.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Discussion\Command; use Flarum\User\User; diff --git a/src/Core/Command/EditDiscussionHandler.php b/src/Discussion/Command/EditDiscussionHandler.php similarity index 96% rename from src/Core/Command/EditDiscussionHandler.php rename to src/Discussion/Command/EditDiscussionHandler.php index 038777d3e..42e38f9e9 100644 --- a/src/Core/Command/EditDiscussionHandler.php +++ b/src/Discussion/Command/EditDiscussionHandler.php @@ -9,14 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Discussion\Command; -use Flarum\User\AssertPermissionTrait; -use Flarum\User\Exception\PermissionDeniedException; use Flarum\Discussion\DiscussionRepository; -use Flarum\Foundation\DispatchEventsTrait; use Flarum\Discussion\DiscussionValidator; use Flarum\Discussion\Event\Saving; +use Flarum\Foundation\DispatchEventsTrait; +use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Events\Dispatcher; class EditDiscussionHandler diff --git a/src/Core/Command/ReadDiscussion.php b/src/Discussion/Command/ReadDiscussion.php similarity index 96% rename from src/Core/Command/ReadDiscussion.php rename to src/Discussion/Command/ReadDiscussion.php index 4a0c8ebd4..c6a8826e3 100644 --- a/src/Core/Command/ReadDiscussion.php +++ b/src/Discussion/Command/ReadDiscussion.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Discussion\Command; use Flarum\User\User; diff --git a/src/Core/Command/ReadDiscussionHandler.php b/src/Discussion/Command/ReadDiscussionHandler.php similarity index 97% rename from src/Core/Command/ReadDiscussionHandler.php rename to src/Discussion/Command/ReadDiscussionHandler.php index dea81e8b6..0197d8684 100644 --- a/src/Core/Command/ReadDiscussionHandler.php +++ b/src/Discussion/Command/ReadDiscussionHandler.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Discussion\Command; -use Flarum\User\AssertPermissionTrait; use Flarum\Discussion\DiscussionRepository; -use Flarum\Foundation\DispatchEventsTrait; use Flarum\Discussion\Event\UserDataSaving; +use Flarum\Foundation\DispatchEventsTrait; +use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Events\Dispatcher; class ReadDiscussionHandler diff --git a/src/Core/Command/StartDiscussion.php b/src/Discussion/Command/StartDiscussion.php similarity index 95% rename from src/Core/Command/StartDiscussion.php rename to src/Discussion/Command/StartDiscussion.php index 9bc0cab10..3b564c0f1 100644 --- a/src/Core/Command/StartDiscussion.php +++ b/src/Discussion/Command/StartDiscussion.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Discussion\Command; use Flarum\User\User; diff --git a/src/Core/Command/StartDiscussionHandler.php b/src/Discussion/Command/StartDiscussionHandler.php similarity index 98% rename from src/Core/Command/StartDiscussionHandler.php rename to src/Discussion/Command/StartDiscussionHandler.php index 7f8586031..01f99b832 100644 --- a/src/Core/Command/StartDiscussionHandler.php +++ b/src/Discussion/Command/StartDiscussionHandler.php @@ -9,14 +9,14 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Discussion\Command; use Exception; -use Flarum\User\AssertPermissionTrait; use Flarum\Discussion\Discussion; -use Flarum\Foundation\DispatchEventsTrait; use Flarum\Discussion\DiscussionValidator; use Flarum\Discussion\Event\Saving; +use Flarum\Foundation\DispatchEventsTrait; +use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher; use Illuminate\Contracts\Events\Dispatcher as EventDispatcher; diff --git a/src/Forum/Controller/ConfirmEmailController.php b/src/Forum/Controller/ConfirmEmailController.php index 0284674ed..5889fdfb6 100644 --- a/src/Forum/Controller/ConfirmEmailController.php +++ b/src/Forum/Controller/ConfirmEmailController.php @@ -11,11 +11,11 @@ namespace Flarum\Forum\Controller; -use Flarum\Core\Command\ConfirmEmail; -use Flarum\User\Exception\InvalidConfirmationTokenException; use Flarum\Foundation\Application; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\SessionAuthenticator; +use Flarum\User\Command\ConfirmEmail; +use Flarum\User\Exception\InvalidConfirmationTokenException; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; use Zend\Diactoros\Response\HtmlResponse; diff --git a/src/Core/Command/CreateGroup.php b/src/Group/Command/CreateGroup.php similarity index 95% rename from src/Core/Command/CreateGroup.php rename to src/Group/Command/CreateGroup.php index e67eefea6..e20fb6154 100644 --- a/src/Core/Command/CreateGroup.php +++ b/src/Group/Command/CreateGroup.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Group\Command; use Flarum\User\User; diff --git a/src/Core/Command/CreateGroupHandler.php b/src/Group/Command/CreateGroupHandler.php similarity index 98% rename from src/Core/Command/CreateGroupHandler.php rename to src/Group/Command/CreateGroupHandler.php index ee152d1ec..e18ac566b 100644 --- a/src/Core/Command/CreateGroupHandler.php +++ b/src/Group/Command/CreateGroupHandler.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Group\Command; -use Flarum\User\AssertPermissionTrait; -use Flarum\Group\Group; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Group\GroupValidator; use Flarum\Group\Event\Saving; +use Flarum\Group\Group; +use Flarum\Group\GroupValidator; +use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Events\Dispatcher; class CreateGroupHandler diff --git a/src/Core/Command/DeleteGroup.php b/src/Group/Command/DeleteGroup.php similarity index 97% rename from src/Core/Command/DeleteGroup.php rename to src/Group/Command/DeleteGroup.php index b57bc7c33..b2bb6873e 100644 --- a/src/Core/Command/DeleteGroup.php +++ b/src/Group/Command/DeleteGroup.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Group\Command; use Flarum\User\User; diff --git a/src/Core/Command/DeleteGroupHandler.php b/src/Group/Command/DeleteGroupHandler.php similarity index 97% rename from src/Core/Command/DeleteGroupHandler.php rename to src/Group/Command/DeleteGroupHandler.php index 119758d1f..568f92802 100644 --- a/src/Core/Command/DeleteGroupHandler.php +++ b/src/Group/Command/DeleteGroupHandler.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Group\Command; -use Flarum\User\AssertPermissionTrait; -use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Group\GroupRepository; use Flarum\Foundation\DispatchEventsTrait; use Flarum\Group\Event\Deleting; +use Flarum\Group\GroupRepository; +use Flarum\User\AssertPermissionTrait; +use Flarum\User\Exception\PermissionDeniedException; use Illuminate\Contracts\Events\Dispatcher; class DeleteGroupHandler diff --git a/src/Core/Command/EditGroup.php b/src/Group/Command/EditGroup.php similarity index 96% rename from src/Core/Command/EditGroup.php rename to src/Group/Command/EditGroup.php index f05dc26cd..e64cb9913 100644 --- a/src/Core/Command/EditGroup.php +++ b/src/Group/Command/EditGroup.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Group\Command; use Flarum\User\User; diff --git a/src/Core/Command/EditGroupHandler.php b/src/Group/Command/EditGroupHandler.php similarity index 98% rename from src/Core/Command/EditGroupHandler.php rename to src/Group/Command/EditGroupHandler.php index c3fee99f4..d82020328 100644 --- a/src/Core/Command/EditGroupHandler.php +++ b/src/Group/Command/EditGroupHandler.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Group\Command; -use Flarum\User\AssertPermissionTrait; -use Flarum\User\Exception\PermissionDeniedException; +use Flarum\Foundation\DispatchEventsTrait; +use Flarum\Group\Event\Saving; use Flarum\Group\Group; use Flarum\Group\GroupRepository; -use Flarum\Foundation\DispatchEventsTrait; use Flarum\Group\GroupValidator; -use Flarum\Group\Event\Saving; +use Flarum\User\AssertPermissionTrait; +use Flarum\User\Exception\PermissionDeniedException; use Illuminate\Contracts\Events\Dispatcher; class EditGroupHandler diff --git a/src/Core/Command/ReadAllNotifications.php b/src/Notification/Command/ReadAllNotifications.php similarity index 93% rename from src/Core/Command/ReadAllNotifications.php rename to src/Notification/Command/ReadAllNotifications.php index d231153ce..d0ee62429 100644 --- a/src/Core/Command/ReadAllNotifications.php +++ b/src/Notification/Command/ReadAllNotifications.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Notification\Command; use Flarum\User\User; diff --git a/src/Core/Command/ReadAllNotificationsHandler.php b/src/Notification/Command/ReadAllNotificationsHandler.php similarity index 96% rename from src/Core/Command/ReadAllNotificationsHandler.php rename to src/Notification/Command/ReadAllNotificationsHandler.php index 7e2255fd5..4d99dfdf5 100644 --- a/src/Core/Command/ReadAllNotificationsHandler.php +++ b/src/Notification/Command/ReadAllNotificationsHandler.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Notification\Command; -use Flarum\User\AssertPermissionTrait; use Flarum\Notification\NotificationRepository; +use Flarum\User\AssertPermissionTrait; class ReadAllNotificationsHandler { diff --git a/src/Core/Command/ReadNotification.php b/src/Notification/Command/ReadNotification.php similarity index 95% rename from src/Core/Command/ReadNotification.php rename to src/Notification/Command/ReadNotification.php index f525299b7..93a139ea8 100644 --- a/src/Core/Command/ReadNotification.php +++ b/src/Notification/Command/ReadNotification.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Notification\Command; use Flarum\User\User; diff --git a/src/Core/Command/ReadNotificationHandler.php b/src/Notification/Command/ReadNotificationHandler.php similarity index 96% rename from src/Core/Command/ReadNotificationHandler.php rename to src/Notification/Command/ReadNotificationHandler.php index d8ed0a8fa..41da8e781 100644 --- a/src/Core/Command/ReadNotificationHandler.php +++ b/src/Notification/Command/ReadNotificationHandler.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Notification\Command; -use Flarum\User\AssertPermissionTrait; use Flarum\Notification\Notification; +use Flarum\User\AssertPermissionTrait; class ReadNotificationHandler { diff --git a/src/Core/Command/DeletePost.php b/src/Post/Command/DeletePost.php similarity index 97% rename from src/Core/Command/DeletePost.php rename to src/Post/Command/DeletePost.php index e2c2e897b..27d79dc09 100644 --- a/src/Core/Command/DeletePost.php +++ b/src/Post/Command/DeletePost.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Post\Command; use Flarum\User\User; diff --git a/src/Core/Command/DeletePostHandler.php b/src/Post/Command/DeletePostHandler.php similarity index 94% rename from src/Core/Command/DeletePostHandler.php rename to src/Post/Command/DeletePostHandler.php index 1e5301f2e..f21845ea4 100644 --- a/src/Core/Command/DeletePostHandler.php +++ b/src/Post/Command/DeletePostHandler.php @@ -9,13 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Post\Command; -use Flarum\User\AssertPermissionTrait; -use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Post\PostRepository; use Flarum\Foundation\DispatchEventsTrait; use Flarum\Post\Event\Deleting; +use Flarum\Post\PostRepository; +use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Events\Dispatcher; class DeletePostHandler diff --git a/src/Core/Command/EditPost.php b/src/Post/Command/EditPost.php similarity index 96% rename from src/Core/Command/EditPost.php rename to src/Post/Command/EditPost.php index 25390c890..270756d30 100644 --- a/src/Core/Command/EditPost.php +++ b/src/Post/Command/EditPost.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Post\Command; use Flarum\User\User; diff --git a/src/Core/Command/EditPostHandler.php b/src/Post/Command/EditPostHandler.php similarity index 98% rename from src/Core/Command/EditPostHandler.php rename to src/Post/Command/EditPostHandler.php index e2b093f9a..e4e3269e8 100644 --- a/src/Core/Command/EditPostHandler.php +++ b/src/Post/Command/EditPostHandler.php @@ -9,14 +9,14 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Post\Command; -use Flarum\User\AssertPermissionTrait; -use Flarum\Post\CommentPost; -use Flarum\Post\PostRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Post\PostValidator; +use Flarum\Post\CommentPost; use Flarum\Post\Event\Saving; +use Flarum\Post\PostRepository; +use Flarum\Post\PostValidator; +use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Events\Dispatcher; class EditPostHandler diff --git a/src/Core/Command/PostReply.php b/src/Post/Command/PostReply.php similarity index 97% rename from src/Core/Command/PostReply.php rename to src/Post/Command/PostReply.php index 4877b3045..cc7575707 100644 --- a/src/Core/Command/PostReply.php +++ b/src/Post/Command/PostReply.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Post\Command; use Flarum\User\User; diff --git a/src/Core/Command/PostReplyHandler.php b/src/Post/Command/PostReplyHandler.php similarity index 99% rename from src/Core/Command/PostReplyHandler.php rename to src/Post/Command/PostReplyHandler.php index 2a8314a8e..519f515ec 100644 --- a/src/Core/Command/PostReplyHandler.php +++ b/src/Post/Command/PostReplyHandler.php @@ -9,16 +9,16 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\Post\Command; use DateTime; -use Flarum\User\AssertPermissionTrait; -use Flarum\Notification\NotificationSyncer; -use Flarum\Post\CommentPost; use Flarum\Discussion\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Post\PostValidator; +use Flarum\Notification\NotificationSyncer; +use Flarum\Post\CommentPost; use Flarum\Post\Event\Saving; +use Flarum\Post\PostValidator; +use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Events\Dispatcher; class PostReplyHandler diff --git a/src/Core/Command/ConfirmEmail.php b/src/User/Command/ConfirmEmail.php similarity index 94% rename from src/Core/Command/ConfirmEmail.php rename to src/User/Command/ConfirmEmail.php index 1b9f5ab0c..b07fd38a2 100644 --- a/src/Core/Command/ConfirmEmail.php +++ b/src/User/Command/ConfirmEmail.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; class ConfirmEmail { diff --git a/src/Core/Command/ConfirmEmailHandler.php b/src/User/Command/ConfirmEmailHandler.php similarity index 93% rename from src/Core/Command/ConfirmEmailHandler.php rename to src/User/Command/ConfirmEmailHandler.php index b657f1972..cef9f70b8 100644 --- a/src/Core/Command/ConfirmEmailHandler.php +++ b/src/User/Command/ConfirmEmailHandler.php @@ -9,16 +9,16 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\EmailToken; use Flarum\User\UserRepository; -use Flarum\Foundation\DispatchEventsTrait; use Illuminate\Contracts\Events\Dispatcher; class ConfirmEmailHandler { - use Flarum\Foundation\DispatchEventsTrait; + use DispatchEventsTrait; /** * @var \Flarum\User\UserRepository diff --git a/src/Core/Command/DeleteAvatar.php b/src/User/Command/DeleteAvatar.php similarity index 96% rename from src/Core/Command/DeleteAvatar.php rename to src/User/Command/DeleteAvatar.php index a8f757c14..23593c245 100644 --- a/src/Core/Command/DeleteAvatar.php +++ b/src/User/Command/DeleteAvatar.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; use Flarum\User\User; diff --git a/src/Core/Command/DeleteAvatarHandler.php b/src/User/Command/DeleteAvatarHandler.php similarity index 95% rename from src/Core/Command/DeleteAvatarHandler.php rename to src/User/Command/DeleteAvatarHandler.php index 2dfe68efd..f75bea567 100644 --- a/src/Core/Command/DeleteAvatarHandler.php +++ b/src/User/Command/DeleteAvatarHandler.php @@ -9,13 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; -use Flarum\User\AssertPermissionTrait; -use Flarum\User\Exception\PermissionDeniedException; -use Flarum\User\UserRepository; -use Flarum\Foundation\DispatchEventsTrait; use Flarum\Event\AvatarWillBeDeleted; +use Flarum\Foundation\DispatchEventsTrait; +use Flarum\User\AssertPermissionTrait; +use Flarum\User\UserRepository; use Illuminate\Contracts\Events\Dispatcher; use League\Flysystem\FilesystemInterface; diff --git a/src/Core/Command/DeleteUser.php b/src/User/Command/DeleteUser.php similarity index 97% rename from src/Core/Command/DeleteUser.php rename to src/User/Command/DeleteUser.php index 2aa0f3edb..43bfd555c 100644 --- a/src/Core/Command/DeleteUser.php +++ b/src/User/Command/DeleteUser.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; use Flarum\User\User; diff --git a/src/Core/Command/DeleteUserHandler.php b/src/User/Command/DeleteUserHandler.php similarity index 97% rename from src/Core/Command/DeleteUserHandler.php rename to src/User/Command/DeleteUserHandler.php index e2f64e482..006d5e17b 100644 --- a/src/Core/Command/DeleteUserHandler.php +++ b/src/User/Command/DeleteUserHandler.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; +use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; +use Flarum\User\Event\Deleting; use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\UserRepository; -use Flarum\Foundation\DispatchEventsTrait; -use Flarum\User\Event\Deleting; use Illuminate\Contracts\Events\Dispatcher; class DeleteUserHandler diff --git a/src/Core/Command/EditUser.php b/src/User/Command/EditUser.php similarity index 96% rename from src/Core/Command/EditUser.php rename to src/User/Command/EditUser.php index fa758483f..9ac9382de 100644 --- a/src/Core/Command/EditUser.php +++ b/src/User/Command/EditUser.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; use Flarum\User\User; diff --git a/src/Core/Command/EditUserHandler.php b/src/User/Command/EditUserHandler.php similarity index 99% rename from src/Core/Command/EditUserHandler.php rename to src/User/Command/EditUserHandler.php index cb2b2b725..a9df676c0 100644 --- a/src/Core/Command/EditUserHandler.php +++ b/src/User/Command/EditUserHandler.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; -use Flarum\User\AssertPermissionTrait; -use Flarum\User\UserRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\User\User; -use Flarum\User\UserValidator; +use Flarum\User\AssertPermissionTrait; use Flarum\User\Event\GroupsChanged; use Flarum\User\Event\Saving; +use Flarum\User\User; +use Flarum\User\UserRepository; +use Flarum\User\UserValidator; use Illuminate\Contracts\Events\Dispatcher; class EditUserHandler diff --git a/src/Core/Command/RegisterUser.php b/src/User/Command/RegisterUser.php similarity index 95% rename from src/Core/Command/RegisterUser.php rename to src/User/Command/RegisterUser.php index 1d9a32b70..47494cf25 100644 --- a/src/Core/Command/RegisterUser.php +++ b/src/User/Command/RegisterUser.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; use Flarum\User\User; diff --git a/src/Core/Command/RegisterUserHandler.php b/src/User/Command/RegisterUserHandler.php similarity index 99% rename from src/Core/Command/RegisterUserHandler.php rename to src/User/Command/RegisterUserHandler.php index edbf35d65..cab155c22 100644 --- a/src/Core/Command/RegisterUserHandler.php +++ b/src/User/Command/RegisterUserHandler.php @@ -9,18 +9,18 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; use Exception; +use Flarum\Foundation\Application; +use Flarum\Foundation\DispatchEventsTrait; +use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\AssertPermissionTrait; use Flarum\User\AuthToken; +use Flarum\User\Event\Saving; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\User; use Flarum\User\UserValidator; -use Flarum\User\Event\Saving; -use Flarum\Foundation\Application; -use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Validation\Factory; use Illuminate\Contracts\Validation\ValidationException; diff --git a/src/Core/Command/RequestPasswordReset.php b/src/User/Command/RequestPasswordReset.php similarity index 94% rename from src/Core/Command/RequestPasswordReset.php rename to src/User/Command/RequestPasswordReset.php index 7a59942ae..fd997179d 100644 --- a/src/Core/Command/RequestPasswordReset.php +++ b/src/User/Command/RequestPasswordReset.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; class RequestPasswordReset { diff --git a/src/Core/Command/RequestPasswordResetHandler.php b/src/User/Command/RequestPasswordResetHandler.php similarity index 98% rename from src/Core/Command/RequestPasswordResetHandler.php rename to src/User/Command/RequestPasswordResetHandler.php index 4647bc004..ba464a698 100644 --- a/src/Core/Command/RequestPasswordResetHandler.php +++ b/src/User/Command/RequestPasswordResetHandler.php @@ -9,13 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; -use Flarum\Core; -use Flarum\User\PasswordToken; -use Flarum\User\UserRepository; use Flarum\Forum\UrlGenerator; use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\User\PasswordToken; +use Flarum\User\UserRepository; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Contracts\Validation\Factory; use Illuminate\Contracts\Validation\ValidationException; diff --git a/src/Core/Command/UploadAvatar.php b/src/User/Command/UploadAvatar.php similarity index 97% rename from src/Core/Command/UploadAvatar.php rename to src/User/Command/UploadAvatar.php index ac34220e5..6a06cf852 100644 --- a/src/Core/Command/UploadAvatar.php +++ b/src/User/Command/UploadAvatar.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; use Flarum\User\User; use Psr\Http\Message\UploadedFileInterface; diff --git a/src/Core/Command/UploadAvatarHandler.php b/src/User/Command/UploadAvatarHandler.php similarity index 99% rename from src/Core/Command/UploadAvatarHandler.php rename to src/User/Command/UploadAvatarHandler.php index adcf76ee3..454373099 100644 --- a/src/Core/Command/UploadAvatarHandler.php +++ b/src/User/Command/UploadAvatarHandler.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Command; +namespace Flarum\User\Command; use Exception; -use Flarum\User\AssertPermissionTrait; -use Flarum\User\UserRepository; -use Flarum\Foundation\DispatchEventsTrait; -use Flarum\User\AvatarValidator; use Flarum\Event\AvatarWillBeSaved; use Flarum\Foundation\Application; +use Flarum\Foundation\DispatchEventsTrait; +use Flarum\User\AssertPermissionTrait; +use Flarum\User\UserRepository; +use Flarum\User\AvatarValidator; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Support\Str; use Intervention\Image\ImageManager; diff --git a/src/User/UserServiceProvider.php b/src/User/UserServiceProvider.php index 45a7e8a24..7c17943c6 100644 --- a/src/User/UserServiceProvider.php +++ b/src/User/UserServiceProvider.php @@ -41,15 +41,15 @@ class UserServiceProvider extends AbstractServiceProvider return $app->make('Illuminate\Contracts\Filesystem\Factory')->disk('flarum-avatars')->getDriver(); }; - $this->app->when('Flarum\Core\Command\UploadAvatarHandler') + $this->app->when('Flarum\User\Command\UploadAvatarHandler') ->needs('League\Flysystem\FilesystemInterface') ->give($avatarsFilesystem); - $this->app->when('Flarum\Core\Command\DeleteAvatarHandler') + $this->app->when('Flarum\User\Command\DeleteAvatarHandler') ->needs('League\Flysystem\FilesystemInterface') ->give($avatarsFilesystem); - $this->app->when('Flarum\Core\Command\RegisterUserHandler') + $this->app->when('Flarum\User\Command\RegisterUserHandler') ->needs('League\Flysystem\FilesystemInterface') ->give($avatarsFilesystem); } From 78f3681fc1b68ed16367e6d91e0b42b5a085fdf4 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sat, 24 Jun 2017 15:48:20 +0200 Subject: [PATCH 35/86] Fix namespace orderings (Thanks, StyleCI!) --- src/Admin/AdminServiceProvider.php | 4 ++-- src/Admin/Controller/FrontendController.php | 4 ++-- src/Admin/routes.php | 2 +- src/Api/ApiServiceProvider.php | 2 +- .../Controller/DeleteFaviconController.php | 2 +- src/Api/Controller/DeleteLogoController.php | 2 +- .../Controller/ForgotPasswordController.php | 2 +- .../ListNotificationsController.php | 2 +- src/Api/Controller/ListPostsController.php | 2 +- src/Api/Controller/ListUsersController.php | 2 +- .../SendConfirmationEmailController.php | 6 ++--- .../Controller/SetPermissionController.php | 2 +- src/Api/Controller/SetSettingsController.php | 6 ++--- src/Api/Controller/TokenController.php | 4 ++-- .../UninstallExtensionController.php | 2 +- .../Controller/UpdateExtensionController.php | 2 +- .../Controller/UploadFaviconController.php | 2 +- src/Api/Controller/UploadLogoController.php | 2 +- src/Api/Serializer/BasicPostSerializer.php | 2 +- src/Api/Serializer/DiscussionSerializer.php | 2 +- src/Api/Serializer/PostSerializer.php | 2 +- src/Api/routes.php | 2 +- src/Console/Server.php | 4 ++-- src/Database/ScopeVisibilityTrait.php | 2 +- src/Discussion/Discussion.php | 9 ++++---- src/Discussion/DiscussionMetadataUpdater.php | 2 +- src/Discussion/DiscussionPolicy.php | 1 - src/Discussion/DiscussionRenamedLogger.php | 2 +- src/Discussion/Search/DiscussionSearcher.php | 5 +---- src/Discussion/Search/Gambit/AuthorGambit.php | 4 ++-- .../Search/Gambit/CreatedGambit.php | 2 +- .../Search/Gambit/FulltextGambit.php | 2 +- src/Discussion/Search/Gambit/HiddenGambit.php | 2 +- src/Discussion/Search/Gambit/UnreadGambit.php | 2 +- src/Discussion/UserState.php | 3 +-- src/Event/AbstractConfigureRoutes.php | 2 +- src/Extension/ExtensionManager.php | 4 ++-- src/Forum/Controller/DiscussionController.php | 2 +- src/Forum/Controller/IndexController.php | 2 +- src/Forum/Controller/LogInController.php | 4 ++-- src/Forum/Controller/LogOutController.php | 4 ++-- .../Controller/ResetPasswordController.php | 2 +- .../Controller/SavePasswordController.php | 4 ++-- src/Forum/ForumServiceProvider.php | 4 ++-- src/Forum/routes.php | 2 +- src/Frontend/FrontendAssets.php | 2 +- src/Frontend/FrontendView.php | 2 +- src/Group/Group.php | 4 ++-- src/Http/AbstractServer.php | 4 ++-- .../Middleware/AuthenticateWithHeader.php | 2 +- src/Install/Console/InstallCommand.php | 2 +- src/Install/InstallServiceProvider.php | 2 +- src/Notification/NotificationSyncer.php | 2 +- src/Post/CommentPost.php | 2 +- src/Post/Post.php | 4 ++-- src/Update/Controller/UpdateController.php | 2 +- src/Update/UpdateServiceProvider.php | 2 +- src/User/AuthToken.php | 2 +- src/User/Command/UploadAvatarHandler.php | 2 +- src/User/EmailConfirmationMailer.php | 4 ++-- src/User/EmailToken.php | 2 +- src/User/Event/LoggedIn.php | 2 +- src/User/Search/UserSearcher.php | 4 ++-- src/User/User.php | 22 +++++++++---------- src/User/UserPolicy.php | 1 - 65 files changed, 95 insertions(+), 102 deletions(-) diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index f394637e2..1166ee120 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -13,10 +13,10 @@ namespace Flarum\Admin; use Flarum\Extension\Event\Disabled; use Flarum\Extension\Event\Enabled; -use Flarum\Settings\Event\Saved; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; +use Flarum\Http\RouteHandlerFactory; +use Flarum\Settings\Event\Saved; class AdminServiceProvider extends AbstractServiceProvider { diff --git a/src/Admin/Controller/FrontendController.php b/src/Admin/Controller/FrontendController.php index 14258eb05..a274a3d61 100644 --- a/src/Admin/Controller/FrontendController.php +++ b/src/Admin/Controller/FrontendController.php @@ -12,10 +12,10 @@ namespace Flarum\Admin\Controller; use Flarum\Admin\Frontend; -use Flarum\Group\Permission; -use Flarum\Settings\Event\Deserializing; use Flarum\Extension\ExtensionManager; use Flarum\Frontend\AbstractFrontendController; +use Flarum\Group\Permission; +use Flarum\Settings\Event\Deserializing; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Admin/routes.php b/src/Admin/routes.php index f2a04f74b..eac48ca4e 100644 --- a/src/Admin/routes.php +++ b/src/Admin/routes.php @@ -10,8 +10,8 @@ */ use Flarum\Admin\Controller; -use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; +use Flarum\Http\RouteHandlerFactory; return function (RouteCollection $map, RouteHandlerFactory $route) { $map->get( diff --git a/src/Api/ApiServiceProvider.php b/src/Api/ApiServiceProvider.php index 8e524324f..c886b25ec 100644 --- a/src/Api/ApiServiceProvider.php +++ b/src/Api/ApiServiceProvider.php @@ -17,8 +17,8 @@ use Flarum\Api\Serializer\NotificationSerializer; use Flarum\Event\ConfigureApiRoutes; use Flarum\Event\ConfigureNotificationTypes; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; +use Flarum\Http\RouteHandlerFactory; use Tobscure\JsonApi\ErrorHandler; use Tobscure\JsonApi\Exception\Handler\FallbackExceptionHandler; use Tobscure\JsonApi\Exception\Handler\InvalidParameterExceptionHandler; diff --git a/src/Api/Controller/DeleteFaviconController.php b/src/Api/Controller/DeleteFaviconController.php index 4c2807abc..887360942 100644 --- a/src/Api/Controller/DeleteFaviconController.php +++ b/src/Api/Controller/DeleteFaviconController.php @@ -11,9 +11,9 @@ namespace Flarum\Api\Controller; -use Flarum\User\AssertPermissionTrait; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\User\AssertPermissionTrait; use League\Flysystem\Adapter\Local; use League\Flysystem\Filesystem; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/DeleteLogoController.php b/src/Api/Controller/DeleteLogoController.php index 532674577..50a76c658 100644 --- a/src/Api/Controller/DeleteLogoController.php +++ b/src/Api/Controller/DeleteLogoController.php @@ -11,9 +11,9 @@ namespace Flarum\Api\Controller; -use Flarum\User\AssertPermissionTrait; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\User\AssertPermissionTrait; use League\Flysystem\Adapter\Local; use League\Flysystem\Filesystem; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/ForgotPasswordController.php b/src/Api/Controller/ForgotPasswordController.php index 56e638878..341f16d34 100644 --- a/src/Api/Controller/ForgotPasswordController.php +++ b/src/Api/Controller/ForgotPasswordController.php @@ -11,9 +11,9 @@ namespace Flarum\Api\Controller; +use Flarum\Http\Controller\ControllerInterface; use Flarum\User\Command\RequestPasswordReset; use Flarum\User\UserRepository; -use Flarum\Http\Controller\ControllerInterface; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Zend\Diactoros\Response\EmptyResponse; diff --git a/src/Api/Controller/ListNotificationsController.php b/src/Api/Controller/ListNotificationsController.php index aeca867a8..d86922b42 100644 --- a/src/Api/Controller/ListNotificationsController.php +++ b/src/Api/Controller/ListNotificationsController.php @@ -12,8 +12,8 @@ namespace Flarum\Api\Controller; use Flarum\Discussion\Discussion; -use Flarum\User\Exception\PermissionDeniedException; use Flarum\Notification\NotificationRepository; +use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/ListPostsController.php b/src/Api/Controller/ListPostsController.php index 071dbc41d..b506f814a 100644 --- a/src/Api/Controller/ListPostsController.php +++ b/src/Api/Controller/ListPostsController.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Controller; -use Flarum\Post\PostRepository; use Flarum\Event\ConfigurePostsQuery; +use Flarum\Post\PostRepository; use Illuminate\Database\Eloquent\Builder; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/ListUsersController.php b/src/Api/Controller/ListUsersController.php index f953e33b4..d27369655 100644 --- a/src/Api/Controller/ListUsersController.php +++ b/src/Api/Controller/ListUsersController.php @@ -12,8 +12,8 @@ namespace Flarum\Api\Controller; use Flarum\Api\UrlGenerator; -use Flarum\User\Exception\PermissionDeniedException; use Flarum\Search\SearchCriteria; +use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\Search\UserSearcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Api/Controller/SendConfirmationEmailController.php b/src/Api/Controller/SendConfirmationEmailController.php index a6314ad97..2718501ea 100644 --- a/src/Api/Controller/SendConfirmationEmailController.php +++ b/src/Api/Controller/SendConfirmationEmailController.php @@ -11,12 +11,12 @@ namespace Flarum\Api\Controller; -use Flarum\User\AssertPermissionTrait; -use Flarum\User\EmailToken; -use Flarum\User\Exception\PermissionDeniedException; use Flarum\Forum\UrlGenerator; use Flarum\Http\Controller\ControllerInterface; use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\User\AssertPermissionTrait; +use Flarum\User\EmailToken; +use Flarum\User\Exception\PermissionDeniedException; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Mail\Message; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/SetPermissionController.php b/src/Api/Controller/SetPermissionController.php index a11dc056f..1171111b1 100644 --- a/src/Api/Controller/SetPermissionController.php +++ b/src/Api/Controller/SetPermissionController.php @@ -11,9 +11,9 @@ namespace Flarum\Api\Controller; -use Flarum\User\AssertPermissionTrait; use Flarum\Group\Permission; use Flarum\Http\Controller\ControllerInterface; +use Flarum\User\AssertPermissionTrait; use Psr\Http\Message\ServerRequestInterface; use Zend\Diactoros\Response\EmptyResponse; diff --git a/src/Api/Controller/SetSettingsController.php b/src/Api/Controller/SetSettingsController.php index b9cb59cdd..f98d4645f 100644 --- a/src/Api/Controller/SetSettingsController.php +++ b/src/Api/Controller/SetSettingsController.php @@ -11,11 +11,11 @@ namespace Flarum\Api\Controller; -use Flarum\User\AssertPermissionTrait; -use Flarum\Settings\Event\Serializing; -use Flarum\Settings\Event\Saved; use Flarum\Http\Controller\ControllerInterface; +use Flarum\Settings\Event\Saved; +use Flarum\Settings\Event\Serializing; use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Zend\Diactoros\Response\EmptyResponse; diff --git a/src/Api/Controller/TokenController.php b/src/Api/Controller/TokenController.php index 376e48747..e0f6f6464 100644 --- a/src/Api/Controller/TokenController.php +++ b/src/Api/Controller/TokenController.php @@ -11,10 +11,10 @@ namespace Flarum\Api\Controller; -use Flarum\User\Exception\PermissionDeniedException; -use Flarum\User\UserRepository; use Flarum\Http\AccessToken; use Flarum\Http\Controller\ControllerInterface; +use Flarum\User\Exception\PermissionDeniedException; +use Flarum\User\UserRepository; use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher; use Illuminate\Contracts\Events\Dispatcher as EventDispatcher; use Psr\Http\Message\ServerRequestInterface; diff --git a/src/Api/Controller/UninstallExtensionController.php b/src/Api/Controller/UninstallExtensionController.php index 0e2f02a59..454ea6109 100644 --- a/src/Api/Controller/UninstallExtensionController.php +++ b/src/Api/Controller/UninstallExtensionController.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Controller; -use Flarum\User\AssertPermissionTrait; use Flarum\Extension\ExtensionManager; +use Flarum\User\AssertPermissionTrait; use Psr\Http\Message\ServerRequestInterface; class UninstallExtensionController extends AbstractDeleteController diff --git a/src/Api/Controller/UpdateExtensionController.php b/src/Api/Controller/UpdateExtensionController.php index c701ae469..156d81b85 100644 --- a/src/Api/Controller/UpdateExtensionController.php +++ b/src/Api/Controller/UpdateExtensionController.php @@ -11,9 +11,9 @@ namespace Flarum\Api\Controller; -use Flarum\User\AssertPermissionTrait; use Flarum\Extension\ExtensionManager; use Flarum\Http\Controller\ControllerInterface; +use Flarum\User\AssertPermissionTrait; use Psr\Http\Message\ServerRequestInterface; class UpdateExtensionController implements ControllerInterface diff --git a/src/Api/Controller/UploadFaviconController.php b/src/Api/Controller/UploadFaviconController.php index 80b33abee..757d3f679 100644 --- a/src/Api/Controller/UploadFaviconController.php +++ b/src/Api/Controller/UploadFaviconController.php @@ -11,9 +11,9 @@ namespace Flarum\Api\Controller; -use Flarum\User\AssertPermissionTrait; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\User\AssertPermissionTrait; use Illuminate\Support\Str; use Intervention\Image\ImageManager; use League\Flysystem\Adapter\Local; diff --git a/src/Api/Controller/UploadLogoController.php b/src/Api/Controller/UploadLogoController.php index ed10a8b67..d6547d555 100644 --- a/src/Api/Controller/UploadLogoController.php +++ b/src/Api/Controller/UploadLogoController.php @@ -11,9 +11,9 @@ namespace Flarum\Api\Controller; -use Flarum\User\AssertPermissionTrait; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\User\AssertPermissionTrait; use Illuminate\Support\Str; use Intervention\Image\ImageManager; use League\Flysystem\Adapter\Local; diff --git a/src/Api/Serializer/BasicPostSerializer.php b/src/Api/Serializer/BasicPostSerializer.php index b63b6dec6..a2a10feeb 100644 --- a/src/Api/Serializer/BasicPostSerializer.php +++ b/src/Api/Serializer/BasicPostSerializer.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Serializer; -use Flarum\Post\Post; use Flarum\Post\CommentPost; +use Flarum\Post\Post; use InvalidArgumentException; class BasicPostSerializer extends AbstractSerializer diff --git a/src/Api/Serializer/DiscussionSerializer.php b/src/Api/Serializer/DiscussionSerializer.php index 17c43e970..e31811127 100644 --- a/src/Api/Serializer/DiscussionSerializer.php +++ b/src/Api/Serializer/DiscussionSerializer.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Serializer; -use Flarum\User\Gate; use Flarum\Discussion\Discussion; +use Flarum\User\Gate; class DiscussionSerializer extends BasicDiscussionSerializer { diff --git a/src/Api/Serializer/PostSerializer.php b/src/Api/Serializer/PostSerializer.php index 9f22c5704..613392427 100644 --- a/src/Api/Serializer/PostSerializer.php +++ b/src/Api/Serializer/PostSerializer.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Serializer; -use Flarum\User\Gate; use Flarum\Post\CommentPost; +use Flarum\User\Gate; class PostSerializer extends BasicPostSerializer { diff --git a/src/Api/routes.php b/src/Api/routes.php index f394141a7..b83c57ea9 100644 --- a/src/Api/routes.php +++ b/src/Api/routes.php @@ -10,8 +10,8 @@ */ use Flarum\Api\Controller; -use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; +use Flarum\Http\RouteHandlerFactory; return function (RouteCollection $map, RouteHandlerFactory $route) { // Get forum information diff --git a/src/Console/Server.php b/src/Console/Server.php index 45366ec83..f7ad12cbb 100644 --- a/src/Console/Server.php +++ b/src/Console/Server.php @@ -12,11 +12,11 @@ namespace Flarum\Console; use Flarum\Database\Console\GenerateMigrationCommand; +use Flarum\Database\Console\MigrateCommand; +use Flarum\Foundation\AbstractServer; use Flarum\Foundation\Console\CacheClearCommand; use Flarum\Foundation\Console\InfoCommand; -use Flarum\Foundation\AbstractServer; use Flarum\Install\Console\InstallCommand; -use Flarum\Database\Console\MigrateCommand; use Symfony\Component\Console\Application; class Server extends AbstractServer diff --git a/src/Database/ScopeVisibilityTrait.php b/src/Database/ScopeVisibilityTrait.php index 276f6a39d..03c18e341 100644 --- a/src/Database/ScopeVisibilityTrait.php +++ b/src/Database/ScopeVisibilityTrait.php @@ -11,8 +11,8 @@ namespace Flarum\Database; -use Flarum\User\User; use Flarum\Event\ScopeModelVisibility; +use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; trait ScopeVisibilityTrait diff --git a/src/Discussion/Discussion.php b/src/Discussion/Discussion.php index 2c73a5aea..38e7bb048 100644 --- a/src/Discussion/Discussion.php +++ b/src/Discussion/Discussion.php @@ -11,18 +11,17 @@ namespace Flarum\Discussion; -use Flarum\Discussion\UserState; -use Flarum\Post\MergeableInterface; -use Flarum\Foundation\EventGeneratorTrait; -use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; +use Flarum\Database\ScopeVisibilityTrait; use Flarum\Discussion\Event\Deleted; use Flarum\Discussion\Event\Hidden; use Flarum\Discussion\Event\Renamed; use Flarum\Discussion\Event\Restored; use Flarum\Discussion\Event\Started; -use Flarum\Post\Event\Deleted as PostDeleted; use Flarum\Event\ScopePostVisibility; +use Flarum\Foundation\EventGeneratorTrait; +use Flarum\Post\Event\Deleted as PostDeleted; +use Flarum\Post\MergeableInterface; use Flarum\Post\Post; use Flarum\User\Guest; use Flarum\User\User; diff --git a/src/Discussion/DiscussionMetadataUpdater.php b/src/Discussion/DiscussionMetadataUpdater.php index 123d8d8c0..b1f894f4c 100755 --- a/src/Discussion/DiscussionMetadataUpdater.php +++ b/src/Discussion/DiscussionMetadataUpdater.php @@ -11,11 +11,11 @@ namespace Flarum\Discussion; -use Flarum\Post\Post; use Flarum\Post\Event\Deleted; use Flarum\Post\Event\Hidden; use Flarum\Post\Event\Posted; use Flarum\Post\Event\Restored; +use Flarum\Post\Post; use Illuminate\Contracts\Events\Dispatcher; class DiscussionMetadataUpdater diff --git a/src/Discussion/DiscussionPolicy.php b/src/Discussion/DiscussionPolicy.php index b43345727..2839f239f 100644 --- a/src/Discussion/DiscussionPolicy.php +++ b/src/Discussion/DiscussionPolicy.php @@ -12,7 +12,6 @@ namespace Flarum\Discussion; use Carbon\Carbon; -use Flarum\Discussion\Discussion; use Flarum\Event\ScopeHiddenDiscussionVisibility; use Flarum\Event\ScopePrivateDiscussionVisibility; use Flarum\Settings\SettingsRepositoryInterface; diff --git a/src/Discussion/DiscussionRenamedLogger.php b/src/Discussion/DiscussionRenamedLogger.php index 8ccf74ff9..961bde5fb 100755 --- a/src/Discussion/DiscussionRenamedLogger.php +++ b/src/Discussion/DiscussionRenamedLogger.php @@ -11,10 +11,10 @@ namespace Flarum\Discussion; +use Flarum\Discussion\Event\Renamed; use Flarum\Notification\Blueprint\DiscussionRenamedBlueprint; use Flarum\Notification\NotificationSyncer; use Flarum\Post\DiscussionRenamedPost; -use Flarum\Discussion\Event\Renamed; use Illuminate\Contracts\Events\Dispatcher; class DiscussionRenamedLogger diff --git a/src/Discussion/Search/DiscussionSearcher.php b/src/Discussion/Search/DiscussionSearcher.php index 81ac2803a..9a6e215ae 100644 --- a/src/Discussion/Search/DiscussionSearcher.php +++ b/src/Discussion/Search/DiscussionSearcher.php @@ -13,13 +13,10 @@ namespace Flarum\Discussion\Search; use Flarum\Discussion\Discussion; use Flarum\Discussion\DiscussionRepository; -use Flarum\Discussion\Search\DiscussionSearch; +use Flarum\Event\ConfigureDiscussionSearch; use Flarum\Post\PostRepository; use Flarum\Search\ApplySearchParametersTrait; use Flarum\Search\GambitManager; -use Flarum\Search\SearchCriteria; -use Flarum\Search\SearchResults; -use Flarum\Event\ConfigureDiscussionSearch; use Illuminate\Database\Eloquent\Collection; /** diff --git a/src/Discussion/Search/Gambit/AuthorGambit.php b/src/Discussion/Search/Gambit/AuthorGambit.php index 15e425512..d3f4544ab 100644 --- a/src/Discussion/Search/Gambit/AuthorGambit.php +++ b/src/Discussion/Search/Gambit/AuthorGambit.php @@ -11,10 +11,10 @@ namespace Flarum\Discussion\Search\Gambit; -use Flarum\User\UserRepository; +use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Search\AbstractRegexGambit; use Flarum\Search\AbstractSearch; -use Flarum\Discussion\Search\DiscussionSearch; +use Flarum\User\UserRepository; use LogicException; class AuthorGambit extends AbstractRegexGambit diff --git a/src/Discussion/Search/Gambit/CreatedGambit.php b/src/Discussion/Search/Gambit/CreatedGambit.php index 0b38fec35..6241c0e16 100644 --- a/src/Discussion/Search/Gambit/CreatedGambit.php +++ b/src/Discussion/Search/Gambit/CreatedGambit.php @@ -11,9 +11,9 @@ namespace Flarum\Discussion\Search\Gambit; +use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Search\AbstractRegexGambit; use Flarum\Search\AbstractSearch; -use Flarum\Discussion\Search\DiscussionSearch; use LogicException; class CreatedGambit extends AbstractRegexGambit diff --git a/src/Discussion/Search/Gambit/FulltextGambit.php b/src/Discussion/Search/Gambit/FulltextGambit.php index da54f358f..3019f9f0f 100644 --- a/src/Discussion/Search/Gambit/FulltextGambit.php +++ b/src/Discussion/Search/Gambit/FulltextGambit.php @@ -11,9 +11,9 @@ namespace Flarum\Discussion\Search\Gambit; -use Flarum\Search\AbstractSearch; use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Discussion\Search\Fulltext\DriverInterface; +use Flarum\Search\AbstractSearch; use Flarum\Search\GambitInterface; use LogicException; diff --git a/src/Discussion/Search/Gambit/HiddenGambit.php b/src/Discussion/Search/Gambit/HiddenGambit.php index 9bd1c7b24..907991546 100644 --- a/src/Discussion/Search/Gambit/HiddenGambit.php +++ b/src/Discussion/Search/Gambit/HiddenGambit.php @@ -11,9 +11,9 @@ namespace Flarum\Discussion\Search\Gambit; +use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Search\AbstractRegexGambit; use Flarum\Search\AbstractSearch; -use Flarum\Discussion\Search\DiscussionSearch; use LogicException; class HiddenGambit extends AbstractRegexGambit diff --git a/src/Discussion/Search/Gambit/UnreadGambit.php b/src/Discussion/Search/Gambit/UnreadGambit.php index 87eb7cfe2..bd9a60629 100644 --- a/src/Discussion/Search/Gambit/UnreadGambit.php +++ b/src/Discussion/Search/Gambit/UnreadGambit.php @@ -12,9 +12,9 @@ namespace Flarum\Discussion\Search\Gambit; use Flarum\Discussion\DiscussionRepository; +use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Search\AbstractRegexGambit; use Flarum\Search\AbstractSearch; -use Flarum\Discussion\Search\DiscussionSearch; use LogicException; class UnreadGambit extends AbstractRegexGambit diff --git a/src/Discussion/UserState.php b/src/Discussion/UserState.php index 68a9ad714..481893f91 100644 --- a/src/Discussion/UserState.php +++ b/src/Discussion/UserState.php @@ -11,10 +11,9 @@ namespace Flarum\Discussion; -use Flarum\Discussion\Discussion; -use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\AbstractModel; use Flarum\Discussion\Event\UserRead; +use Flarum\Foundation\EventGeneratorTrait; use Illuminate\Database\Eloquent\Builder; /** diff --git a/src/Event/AbstractConfigureRoutes.php b/src/Event/AbstractConfigureRoutes.php index fec628648..c09ab958c 100644 --- a/src/Event/AbstractConfigureRoutes.php +++ b/src/Event/AbstractConfigureRoutes.php @@ -11,8 +11,8 @@ namespace Flarum\Event; -use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; +use Flarum\Http\RouteHandlerFactory; abstract class AbstractConfigureRoutes { diff --git a/src/Extension/ExtensionManager.php b/src/Extension/ExtensionManager.php index 724250aec..404638fd5 100644 --- a/src/Extension/ExtensionManager.php +++ b/src/Extension/ExtensionManager.php @@ -13,10 +13,10 @@ namespace Flarum\Extension; use Flarum\Database\Migrator; use Flarum\Extension\Event\Disabled; -use Flarum\Extension\Event\Enabled; -use Flarum\Extension\Event\Uninstalled; use Flarum\Extension\Event\Disabling; +use Flarum\Extension\Event\Enabled; use Flarum\Extension\Event\Enabling; +use Flarum\Extension\Event\Uninstalled; use Flarum\Foundation\Application; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; diff --git a/src/Forum/Controller/DiscussionController.php b/src/Forum/Controller/DiscussionController.php index 4b60ecc84..f952ba799 100644 --- a/src/Forum/Controller/DiscussionController.php +++ b/src/Forum/Controller/DiscussionController.php @@ -12,8 +12,8 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; -use Flarum\Forum\UrlGenerator; use Flarum\Forum\Frontend; +use Flarum\Forum\UrlGenerator; use Flarum\Http\Exception\RouteNotFoundException; use Flarum\User\User; use Illuminate\Contracts\Events\Dispatcher; diff --git a/src/Forum/Controller/IndexController.php b/src/Forum/Controller/IndexController.php index 278710aab..2df0c2158 100644 --- a/src/Forum/Controller/IndexController.php +++ b/src/Forum/Controller/IndexController.php @@ -12,8 +12,8 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client as ApiClient; -use Flarum\User\User; use Flarum\Forum\Frontend; +use Flarum\User\User; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; diff --git a/src/Forum/Controller/LogInController.php b/src/Forum/Controller/LogInController.php index 5cabd47dd..493f301df 100644 --- a/src/Forum/Controller/LogInController.php +++ b/src/Forum/Controller/LogInController.php @@ -13,12 +13,12 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; use Flarum\Api\Controller\TokenController; -use Flarum\User\UserRepository; -use Flarum\User\Event\LoggedIn; use Flarum\Http\AccessToken; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Rememberer; use Flarum\Http\SessionAuthenticator; +use Flarum\User\Event\LoggedIn; +use Flarum\User\UserRepository; use Psr\Http\Message\ServerRequestInterface as Request; use Zend\Diactoros\Response\EmptyResponse; use Zend\Diactoros\Response\JsonResponse; diff --git a/src/Forum/Controller/LogOutController.php b/src/Forum/Controller/LogOutController.php index af220a6b6..d5d191f7e 100644 --- a/src/Forum/Controller/LogOutController.php +++ b/src/Forum/Controller/LogOutController.php @@ -11,13 +11,13 @@ namespace Flarum\Forum\Controller; -use Flarum\User\AssertPermissionTrait; -use Flarum\User\Event\LoggedOut; use Flarum\Foundation\Application; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Exception\TokenMismatchException; use Flarum\Http\Rememberer; use Flarum\Http\SessionAuthenticator; +use Flarum\User\AssertPermissionTrait; +use Flarum\User\Event\LoggedOut; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; use Zend\Diactoros\Response\RedirectResponse; diff --git a/src/Forum/Controller/ResetPasswordController.php b/src/Forum/Controller/ResetPasswordController.php index 36e313a2e..641da9b42 100644 --- a/src/Forum/Controller/ResetPasswordController.php +++ b/src/Forum/Controller/ResetPasswordController.php @@ -12,9 +12,9 @@ namespace Flarum\Forum\Controller; use DateTime; +use Flarum\Http\Controller\AbstractHtmlController; use Flarum\User\Exception\InvalidConfirmationTokenException; use Flarum\User\PasswordToken; -use Flarum\Http\Controller\AbstractHtmlController; use Illuminate\Contracts\View\Factory; use Psr\Http\Message\ServerRequestInterface as Request; use Symfony\Component\Translation\TranslatorInterface; diff --git a/src/Forum/Controller/SavePasswordController.php b/src/Forum/Controller/SavePasswordController.php index 20623cf8f..541113ebd 100644 --- a/src/Forum/Controller/SavePasswordController.php +++ b/src/Forum/Controller/SavePasswordController.php @@ -11,11 +11,11 @@ namespace Flarum\Forum\Controller; -use Flarum\User\PasswordToken; -use Flarum\User\UserValidator; use Flarum\Forum\UrlGenerator; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\SessionAuthenticator; +use Flarum\User\PasswordToken; +use Flarum\User\UserValidator; use Illuminate\Contracts\Validation\Factory; use Illuminate\Contracts\Validation\ValidationException; use Psr\Http\Message\ServerRequestInterface as Request; diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 8b96164a6..7526ad4b7 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -14,10 +14,10 @@ namespace Flarum\Forum; use Flarum\Event\ConfigureForumRoutes; use Flarum\Extension\Event\Disabled; use Flarum\Extension\Event\Enabled; -use Flarum\Settings\Event\Saved; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; +use Flarum\Http\RouteHandlerFactory; +use Flarum\Settings\Event\Saved; class ForumServiceProvider extends AbstractServiceProvider { diff --git a/src/Forum/routes.php b/src/Forum/routes.php index 028fe37dd..00f7bf303 100644 --- a/src/Forum/routes.php +++ b/src/Forum/routes.php @@ -10,8 +10,8 @@ */ use Flarum\Forum\Controller; -use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; +use Flarum\Http\RouteHandlerFactory; return function (RouteCollection $map, RouteHandlerFactory $route) { $map->get( diff --git a/src/Frontend/FrontendAssets.php b/src/Frontend/FrontendAssets.php index e3bce2f16..277b39547 100644 --- a/src/Frontend/FrontendAssets.php +++ b/src/Frontend/FrontendAssets.php @@ -11,9 +11,9 @@ namespace Flarum\Frontend; +use Flarum\Foundation\Application; use Flarum\Frontend\Asset\JsCompiler; use Flarum\Frontend\Asset\LessCompiler; -use Flarum\Foundation\Application; use Flarum\Frontend\Asset\LocaleJsCompiler as LocaleJsCompiler; use Flarum\Locale\LocaleManager; use Illuminate\Contracts\Cache\Repository; diff --git a/src/Frontend/FrontendView.php b/src/Frontend/FrontendView.php index 0593e070a..7a40c7169 100644 --- a/src/Frontend/FrontendView.php +++ b/src/Frontend/FrontendView.php @@ -13,8 +13,8 @@ namespace Flarum\Frontend; use Flarum\Api\Client; use Flarum\Api\Serializer\AbstractSerializer; -use Flarum\Frontend\Asset\CompilerInterface; use Flarum\Foundation\Application; +use Flarum\Frontend\Asset\CompilerInterface; use Flarum\Frontend\Asset\LocaleJsCompiler; use Flarum\Locale\LocaleManager; use Illuminate\View\Factory; diff --git a/src/Group/Group.php b/src/Group/Group.php index dd30cbb53..4af4a4d61 100755 --- a/src/Group/Group.php +++ b/src/Group/Group.php @@ -11,9 +11,9 @@ namespace Flarum\Group; -use Flarum\Foundation\EventGeneratorTrait; -use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; +use Flarum\Database\ScopeVisibilityTrait; +use Flarum\Foundation\EventGeneratorTrait; use Flarum\Group\Event\Created; use Flarum\Group\Event\Deleting; use Flarum\Group\Event\Renamed; diff --git a/src/Http/AbstractServer.php b/src/Http/AbstractServer.php index de6f923c2..0cf7bd39d 100644 --- a/src/Http/AbstractServer.php +++ b/src/Http/AbstractServer.php @@ -11,11 +11,11 @@ namespace Flarum\Http; +use Flarum\Foundation\AbstractServer as BaseAbstractServer; +use Flarum\Foundation\Application; use Flarum\User\AuthToken; use Flarum\User\EmailToken; use Flarum\User\PasswordToken; -use Flarum\Foundation\AbstractServer as BaseAbstractServer; -use Flarum\Foundation\Application; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Zend\Diactoros\Server; diff --git a/src/Http/Middleware/AuthenticateWithHeader.php b/src/Http/Middleware/AuthenticateWithHeader.php index c13313754..85ad9bf1f 100644 --- a/src/Http/Middleware/AuthenticateWithHeader.php +++ b/src/Http/Middleware/AuthenticateWithHeader.php @@ -12,8 +12,8 @@ namespace Flarum\Http\Middleware; use Flarum\Api\ApiKey; -use Flarum\User\User; use Flarum\Http\AccessToken; +use Flarum\User\User; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Zend\Stratigility\MiddlewareInterface; diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index c75928601..f7f9d3a98 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -13,10 +13,10 @@ namespace Flarum\Install\Console; use Exception; use Flarum\Console\AbstractCommand; +use Flarum\Database\AbstractModel; use Flarum\Group\Group; use Flarum\Group\Permission; use Flarum\User\User; -use Flarum\Database\AbstractModel; use Illuminate\Contracts\Foundation\Application; use Illuminate\Filesystem\Filesystem; use Illuminate\Validation\Factory; diff --git a/src/Install/InstallServiceProvider.php b/src/Install/InstallServiceProvider.php index 26c089c06..733a1ce9e 100644 --- a/src/Install/InstallServiceProvider.php +++ b/src/Install/InstallServiceProvider.php @@ -12,8 +12,8 @@ namespace Flarum\Install; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; +use Flarum\Http\RouteHandlerFactory; use Flarum\Install\Prerequisite\Composite; use Flarum\Install\Prerequisite\PhpExtensions; use Flarum\Install\Prerequisite\PhpVersion; diff --git a/src/Notification/NotificationSyncer.php b/src/Notification/NotificationSyncer.php index 5abef59e2..7065c461d 100644 --- a/src/Notification/NotificationSyncer.php +++ b/src/Notification/NotificationSyncer.php @@ -12,8 +12,8 @@ namespace Flarum\Notification; use Carbon\Carbon; -use Flarum\Notification\Event\Sending; use Flarum\Notification\Blueprint\BlueprintInterface; +use Flarum\Notification\Event\Sending; use Flarum\User\User; /** diff --git a/src/Post/CommentPost.php b/src/Post/CommentPost.php index e42403b7e..f8edc6834 100755 --- a/src/Post/CommentPost.php +++ b/src/Post/CommentPost.php @@ -11,11 +11,11 @@ namespace Flarum\Post; +use Flarum\Formatter\Formatter; use Flarum\Post\Event\Hidden; use Flarum\Post\Event\Posted; use Flarum\Post\Event\Restored; use Flarum\Post\Event\Revised; -use Flarum\Formatter\Formatter; use Flarum\User\User; /** diff --git a/src/Post/Post.php b/src/Post/Post.php index c85538582..d603c0e03 100755 --- a/src/Post/Post.php +++ b/src/Post/Post.php @@ -11,9 +11,9 @@ namespace Flarum\Post; -use Flarum\Foundation\EventGeneratorTrait; -use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; +use Flarum\Database\ScopeVisibilityTrait; +use Flarum\Foundation\EventGeneratorTrait; use Flarum\Post\Event\Deleted; use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; diff --git a/src/Update/Controller/UpdateController.php b/src/Update/Controller/UpdateController.php index 2a0335030..390aff798 100644 --- a/src/Update/Controller/UpdateController.php +++ b/src/Update/Controller/UpdateController.php @@ -12,9 +12,9 @@ namespace Flarum\Update\Controller; use Exception; +use Flarum\Database\Console\MigrateCommand; use Flarum\Foundation\Application; use Flarum\Http\Controller\ControllerInterface; -use Flarum\Database\Console\MigrateCommand; use Psr\Http\Message\ServerRequestInterface as Request; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\StreamOutput; diff --git a/src/Update/UpdateServiceProvider.php b/src/Update/UpdateServiceProvider.php index f45364230..7fc93cdc0 100644 --- a/src/Update/UpdateServiceProvider.php +++ b/src/Update/UpdateServiceProvider.php @@ -12,8 +12,8 @@ namespace Flarum\Update; use Flarum\Foundation\AbstractServiceProvider; -use Flarum\Http\RouteHandlerFactory; use Flarum\Http\RouteCollection; +use Flarum\Http\RouteHandlerFactory; class UpdateServiceProvider extends AbstractServiceProvider { diff --git a/src/User/AuthToken.php b/src/User/AuthToken.php index dd785b72a..2458baca5 100644 --- a/src/User/AuthToken.php +++ b/src/User/AuthToken.php @@ -12,8 +12,8 @@ namespace Flarum\User; use DateTime; -use Flarum\User\Exception\InvalidConfirmationTokenException; use Flarum\Database\AbstractModel; +use Flarum\User\Exception\InvalidConfirmationTokenException; /** * @todo document database columns with @property diff --git a/src/User/Command/UploadAvatarHandler.php b/src/User/Command/UploadAvatarHandler.php index 454373099..c674d44b8 100644 --- a/src/User/Command/UploadAvatarHandler.php +++ b/src/User/Command/UploadAvatarHandler.php @@ -16,8 +16,8 @@ use Flarum\Event\AvatarWillBeSaved; use Flarum\Foundation\Application; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; -use Flarum\User\UserRepository; use Flarum\User\AvatarValidator; +use Flarum\User\UserRepository; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Support\Str; use Intervention\Image\ImageManager; diff --git a/src/User/EmailConfirmationMailer.php b/src/User/EmailConfirmationMailer.php index b02c3f037..9ff225dc9 100755 --- a/src/User/EmailConfirmationMailer.php +++ b/src/User/EmailConfirmationMailer.php @@ -11,10 +11,10 @@ namespace Flarum\User; -use Flarum\User\Event\EmailChangeRequested; -use Flarum\User\Event\Registered; use Flarum\Forum\UrlGenerator; use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\User\Event\EmailChangeRequested; +use Flarum\User\Event\Registered; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Mail\Message; diff --git a/src/User/EmailToken.php b/src/User/EmailToken.php index f60d35c89..ac143ea12 100644 --- a/src/User/EmailToken.php +++ b/src/User/EmailToken.php @@ -12,8 +12,8 @@ namespace Flarum\User; use DateTime; -use Flarum\User\Exception\InvalidConfirmationTokenException; use Flarum\Database\AbstractModel; +use Flarum\User\Exception\InvalidConfirmationTokenException; /** * @todo document database columns with @property diff --git a/src/User/Event/LoggedIn.php b/src/User/Event/LoggedIn.php index 32d17b695..3659a0e40 100644 --- a/src/User/Event/LoggedIn.php +++ b/src/User/Event/LoggedIn.php @@ -11,8 +11,8 @@ namespace Flarum\User\Event; -use Flarum\User\User; use Flarum\Http\AccessToken; +use Flarum\User\User; class LoggedIn { diff --git a/src/User/Search/UserSearcher.php b/src/User/Search/UserSearcher.php index 2cb5cab2b..518b4c85e 100644 --- a/src/User/Search/UserSearcher.php +++ b/src/User/Search/UserSearcher.php @@ -11,12 +11,12 @@ namespace Flarum\User\Search; -use Flarum\User\UserRepository; +use Flarum\Event\ConfigureUserSearch; use Flarum\Search\ApplySearchParametersTrait; use Flarum\Search\GambitManager; use Flarum\Search\SearchCriteria; use Flarum\Search\SearchResults; -use Flarum\Event\ConfigureUserSearch; +use Flarum\User\UserRepository; /** * Takes a UserSearchCriteria object, performs a search using gambits, diff --git a/src/User/User.php b/src/User/User.php index ea222484f..b035a58f4 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -12,26 +12,26 @@ namespace Flarum\User; use DomainException; -use Flarum\Group\Group; -use Flarum\Notification\Notification; -use Flarum\Group\Permission; -use Flarum\Foundation\EventGeneratorTrait; -use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; +use Flarum\Database\ScopeVisibilityTrait; use Flarum\Event\CheckUserPassword; use Flarum\Event\ConfigureUserPreferences; -use Flarum\Post\Event\Deleted as PostDeleted; use Flarum\Event\PrepareUserGroups; +use Flarum\Foundation\Application; +use Flarum\Foundation\EventGeneratorTrait; +use Flarum\Group\Group; +use Flarum\Group\Permission; +use Flarum\Notification\Notification; +use Flarum\Post\Event\Deleted as PostDeleted; +use Flarum\User\Event\Activated; use Flarum\User\Event\AvatarChanged; use Flarum\User\Event\BioChanged; -use Flarum\User\Event\EmailChangeRequested; -use Flarum\User\Event\EmailChanged; -use Flarum\User\Event\PasswordChanged; -use Flarum\User\Event\Activated; use Flarum\User\Event\Deleted; +use Flarum\User\Event\EmailChanged; +use Flarum\User\Event\EmailChangeRequested; +use Flarum\User\Event\PasswordChanged; use Flarum\User\Event\Registered; use Flarum\User\Event\Renamed; -use Flarum\Foundation\Application; use Illuminate\Contracts\Hashing\Hasher; use Symfony\Component\HttpFoundation\Session\SessionInterface; diff --git a/src/User/UserPolicy.php b/src/User/UserPolicy.php index 3a52fcaf0..73754f0b8 100644 --- a/src/User/UserPolicy.php +++ b/src/User/UserPolicy.php @@ -11,7 +11,6 @@ namespace Flarum\User; -use Flarum\User\AbstractPolicy; use Illuminate\Database\Eloquent\Builder; class UserPolicy extends AbstractPolicy From f824dcfb53bceebe10c2dd5f34fbef31f6876a1b Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sun, 25 Jun 2017 17:04:33 +0200 Subject: [PATCH 36/86] Move more event classes to appropriate namespaces --- .../Event/Searching.php} | 4 ++-- src/Discussion/Search/DiscussionSearcher.php | 4 ++-- src/User/Command/DeleteAvatarHandler.php | 4 ++-- src/User/Command/UploadAvatarHandler.php | 4 ++-- .../AvatarWillBeDeleted.php => User/Event/AvatarDeleting.php} | 4 ++-- .../AvatarWillBeSaved.php => User/Event/AvatarSaving.php} | 4 ++-- .../ConfigureUserSearch.php => User/Event/Searching.php} | 4 ++-- src/User/Search/UserSearcher.php | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) rename src/{Event/ConfigureDiscussionSearch.php => Discussion/Event/Searching.php} (92%) rename src/{Event/AvatarWillBeDeleted.php => User/Event/AvatarDeleting.php} (93%) rename src/{Event/AvatarWillBeSaved.php => User/Event/AvatarSaving.php} (95%) rename src/{Event/ConfigureUserSearch.php => User/Event/Searching.php} (93%) diff --git a/src/Event/ConfigureDiscussionSearch.php b/src/Discussion/Event/Searching.php similarity index 92% rename from src/Event/ConfigureDiscussionSearch.php rename to src/Discussion/Event/Searching.php index 2b126046e..5735bffdc 100644 --- a/src/Event/ConfigureDiscussionSearch.php +++ b/src/Discussion/Event/Searching.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Discussion\Event; use Flarum\Discussion\Search\DiscussionSearch; use Flarum\Search\SearchCriteria; -class ConfigureDiscussionSearch +class Searching { /** * @var DiscussionSearch diff --git a/src/Discussion/Search/DiscussionSearcher.php b/src/Discussion/Search/DiscussionSearcher.php index 9a6e215ae..5628dcf2f 100644 --- a/src/Discussion/Search/DiscussionSearcher.php +++ b/src/Discussion/Search/DiscussionSearcher.php @@ -13,7 +13,7 @@ namespace Flarum\Discussion\Search; use Flarum\Discussion\Discussion; use Flarum\Discussion\DiscussionRepository; -use Flarum\Event\ConfigureDiscussionSearch; +use Flarum\Discussion\Event\Searching; use Flarum\Post\PostRepository; use Flarum\Search\ApplySearchParametersTrait; use Flarum\Search\GambitManager; @@ -81,7 +81,7 @@ class DiscussionSearcher $this->applyLimit($search, $limit + 1); // TODO: inject dispatcher - event(new ConfigureDiscussionSearch($search, $criteria)); + event(new Searching($search, $criteria)); // Execute the search query and retrieve the results. We get one more // results than the user asked for, so that we can say if there are more diff --git a/src/User/Command/DeleteAvatarHandler.php b/src/User/Command/DeleteAvatarHandler.php index f75bea567..e920f7192 100644 --- a/src/User/Command/DeleteAvatarHandler.php +++ b/src/User/Command/DeleteAvatarHandler.php @@ -11,7 +11,7 @@ namespace Flarum\User\Command; -use Flarum\Event\AvatarWillBeDeleted; +use Flarum\User\Event\AvatarDeleting; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; use Flarum\User\UserRepository; @@ -64,7 +64,7 @@ class DeleteAvatarHandler $user->changeAvatarPath(null); $this->events->fire( - new AvatarWillBeDeleted($user, $actor) + new AvatarDeleting($user, $actor) ); $user->save(); diff --git a/src/User/Command/UploadAvatarHandler.php b/src/User/Command/UploadAvatarHandler.php index c674d44b8..2aa28044a 100644 --- a/src/User/Command/UploadAvatarHandler.php +++ b/src/User/Command/UploadAvatarHandler.php @@ -12,7 +12,7 @@ namespace Flarum\User\Command; use Exception; -use Flarum\Event\AvatarWillBeSaved; +use Flarum\User\Event\AvatarSaving; use Flarum\Foundation\Application; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; @@ -110,7 +110,7 @@ class UploadAvatarHandler file_put_contents($tmpFile, $encodedImage); $this->events->fire( - new AvatarWillBeSaved($user, $actor, $tmpFile) + new AvatarSaving($user, $actor, $tmpFile) ); $mount = new MountManager([ diff --git a/src/Event/AvatarWillBeDeleted.php b/src/User/Event/AvatarDeleting.php similarity index 93% rename from src/Event/AvatarWillBeDeleted.php rename to src/User/Event/AvatarDeleting.php index df862684a..c991acb8d 100644 --- a/src/Event/AvatarWillBeDeleted.php +++ b/src/User/Event/AvatarDeleting.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; use Flarum\User\User; -class AvatarWillBeDeleted +class AvatarDeleting { /** * The user whose avatar will be deleted. diff --git a/src/Event/AvatarWillBeSaved.php b/src/User/Event/AvatarSaving.php similarity index 95% rename from src/Event/AvatarWillBeSaved.php rename to src/User/Event/AvatarSaving.php index 3737bb350..d3b82f741 100644 --- a/src/Event/AvatarWillBeSaved.php +++ b/src/User/Event/AvatarSaving.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; use Flarum\User\User; -class AvatarWillBeSaved +class AvatarSaving { /** * The user whose avatar will be saved. diff --git a/src/Event/ConfigureUserSearch.php b/src/User/Event/Searching.php similarity index 93% rename from src/Event/ConfigureUserSearch.php rename to src/User/Event/Searching.php index 1b9a235e4..5f6b0695f 100644 --- a/src/Event/ConfigureUserSearch.php +++ b/src/User/Event/Searching.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; use Flarum\Search\SearchCriteria; use Flarum\User\Search\UserSearch; -class ConfigureUserSearch +class Searching { /** * @var \Flarum\User\Search\UserSearch diff --git a/src/User/Search/UserSearcher.php b/src/User/Search/UserSearcher.php index 518b4c85e..55ce2b5ff 100644 --- a/src/User/Search/UserSearcher.php +++ b/src/User/Search/UserSearcher.php @@ -11,7 +11,7 @@ namespace Flarum\User\Search; -use Flarum\Event\ConfigureUserSearch; +use Flarum\User\Event\Searching; use Flarum\Search\ApplySearchParametersTrait; use Flarum\Search\GambitManager; use Flarum\Search\SearchCriteria; @@ -69,7 +69,7 @@ class UserSearcher $this->applyOffset($search, $offset); $this->applyLimit($search, $limit + 1); - event(new ConfigureUserSearch($search, $criteria)); + event(new Searching($search, $criteria)); // Execute the search query and retrieve the results. We get one more // results than the user asked for, so that we can say if there are more From b72407440d766a1186996f84ebdb70ee33d5d287 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sun, 25 Jun 2017 23:33:02 +0200 Subject: [PATCH 37/86] Combine URL generator classes into one --- src/Admin/AdminServiceProvider.php | 5 +- src/Admin/UrlGenerator.php | 22 ------- src/Api/ApiServiceProvider.php | 5 +- .../Controller/ListDiscussionsController.php | 4 +- src/Api/Controller/ListUsersController.php | 4 +- .../SendConfirmationEmailController.php | 4 +- src/Api/Serializer/ForumSerializer.php | 6 +- src/Api/UrlGenerator.php | 22 ------- src/Forum/Controller/DiscussionController.php | 4 +- .../Controller/SavePasswordController.php | 6 +- src/Forum/ForumServiceProvider.php | 5 +- src/Forum/UrlGenerator.php | 18 ------ ...or.php => RouteCollectionUrlGenerator.php} | 31 ++++------ src/Http/UrlGenerator.php | 59 +++++++++++++++++++ .../Command/RequestPasswordResetHandler.php | 4 +- src/User/EmailConfirmationMailer.php | 4 +- src/User/User.php | 4 +- views/index.blade.php | 6 +- views/reset.blade.php | 2 +- 19 files changed, 104 insertions(+), 111 deletions(-) delete mode 100644 src/Admin/UrlGenerator.php delete mode 100644 src/Api/UrlGenerator.php delete mode 100644 src/Forum/UrlGenerator.php rename src/Http/{AbstractUrlGenerator.php => RouteCollectionUrlGenerator.php} (64%) create mode 100644 src/Http/UrlGenerator.php diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index 1166ee120..913c6493a 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -16,6 +16,7 @@ use Flarum\Extension\Event\Enabled; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Http\RouteCollection; use Flarum\Http\RouteHandlerFactory; +use Flarum\Http\UrlGenerator; use Flarum\Settings\Event\Saved; class AdminServiceProvider extends AbstractServiceProvider @@ -25,8 +26,8 @@ class AdminServiceProvider extends AbstractServiceProvider */ public function register() { - $this->app->singleton(UrlGenerator::class, function () { - return new UrlGenerator($this->app, $this->app->make('flarum.admin.routes')); + $this->app->extend(UrlGenerator::class, function (UrlGenerator $url) { + return $url->addCollection('admin', $this->app->make('flarum.admin.routes'), 'admin'); }); $this->app->singleton('flarum.admin.routes', function () { diff --git a/src/Admin/UrlGenerator.php b/src/Admin/UrlGenerator.php deleted file mode 100644 index efa1a8a45..000000000 --- a/src/Admin/UrlGenerator.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Admin; - -use Flarum\Http\AbstractUrlGenerator; - -class UrlGenerator extends AbstractUrlGenerator -{ - /** - * {@inheritdoc} - */ - protected $path = 'admin'; -} diff --git a/src/Api/ApiServiceProvider.php b/src/Api/ApiServiceProvider.php index c886b25ec..ed4f916f3 100644 --- a/src/Api/ApiServiceProvider.php +++ b/src/Api/ApiServiceProvider.php @@ -19,6 +19,7 @@ use Flarum\Event\ConfigureNotificationTypes; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Http\RouteCollection; use Flarum\Http\RouteHandlerFactory; +use Flarum\Http\UrlGenerator; use Tobscure\JsonApi\ErrorHandler; use Tobscure\JsonApi\Exception\Handler\FallbackExceptionHandler; use Tobscure\JsonApi\Exception\Handler\InvalidParameterExceptionHandler; @@ -30,8 +31,8 @@ class ApiServiceProvider extends AbstractServiceProvider */ public function register() { - $this->app->singleton(UrlGenerator::class, function () { - return new UrlGenerator($this->app, $this->app->make('flarum.api.routes')); + $this->app->extend(UrlGenerator::class, function (UrlGenerator $url) { + return $url->addCollection('api', $this->app->make('flarum.api.routes'), 'api'); }); $this->app->singleton('flarum.api.routes', function () { diff --git a/src/Api/Controller/ListDiscussionsController.php b/src/Api/Controller/ListDiscussionsController.php index d69e07de6..ee75abc60 100644 --- a/src/Api/Controller/ListDiscussionsController.php +++ b/src/Api/Controller/ListDiscussionsController.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Controller; -use Flarum\Api\UrlGenerator; use Flarum\Discussion\Search\DiscussionSearcher; +use Flarum\Http\UrlGenerator; use Flarum\Search\SearchCriteria; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -86,7 +86,7 @@ class ListDiscussionsController extends AbstractListController $results = $this->searcher->search($criteria, $limit, $offset, $load); $document->addPaginationLinks( - $this->url->toRoute('discussions.index'), + $this->url->to('api')->route('discussions.index'), $request->getQueryParams(), $offset, $limit, diff --git a/src/Api/Controller/ListUsersController.php b/src/Api/Controller/ListUsersController.php index d27369655..679230a98 100644 --- a/src/Api/Controller/ListUsersController.php +++ b/src/Api/Controller/ListUsersController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Api\UrlGenerator; +use Flarum\Http\UrlGenerator; use Flarum\Search\SearchCriteria; use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\Search\UserSearcher; @@ -84,7 +84,7 @@ class ListUsersController extends AbstractListController $results = $this->searcher->search($criteria, $limit, $offset, $load); $document->addPaginationLinks( - $this->url->toRoute('users.index'), + $this->url->to('api')->route('users.index'), $request->getQueryParams(), $offset, $limit, diff --git a/src/Api/Controller/SendConfirmationEmailController.php b/src/Api/Controller/SendConfirmationEmailController.php index 2718501ea..2935f0067 100644 --- a/src/Api/Controller/SendConfirmationEmailController.php +++ b/src/Api/Controller/SendConfirmationEmailController.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Controller; -use Flarum\Forum\UrlGenerator; use Flarum\Http\Controller\ControllerInterface; +use Flarum\Http\UrlGenerator; use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\AssertPermissionTrait; use Flarum\User\EmailToken; @@ -80,7 +80,7 @@ class SendConfirmationEmailController implements ControllerInterface $data = [ '{username}' => $actor->username, - '{url}' => $this->url->toRoute('confirmEmail', ['token' => $token->id]), + '{url}' => $this->url->to('forum')->route('confirmEmail', ['token' => $token->id]), '{forum}' => $this->settings->get('forum_title') ]; diff --git a/src/Api/Serializer/ForumSerializer.php b/src/Api/Serializer/ForumSerializer.php index 852ec08a6..399fcfd83 100644 --- a/src/Api/Serializer/ForumSerializer.php +++ b/src/Api/Serializer/ForumSerializer.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Serializer; -use Flarum\Forum\UrlGenerator; use Flarum\Foundation\Application; +use Flarum\Http\UrlGenerator; use Flarum\Settings\SettingsRepositoryInterface; class ForumSerializer extends AbstractSerializer @@ -107,7 +107,7 @@ class ForumSerializer extends AbstractSerializer { $logoPath = $this->settings->get('logo_path'); - return $logoPath ? $this->url->toPath('assets/'.$logoPath) : null; + return $logoPath ? $this->url->to('forum')->path('assets/'.$logoPath) : null; } /** @@ -117,6 +117,6 @@ class ForumSerializer extends AbstractSerializer { $faviconPath = $this->settings->get('favicon_path'); - return $faviconPath ? $this->url->toPath('assets/'.$faviconPath) : null; + return $faviconPath ? $this->url->to('forum')->path('assets/'.$faviconPath) : null; } } diff --git a/src/Api/UrlGenerator.php b/src/Api/UrlGenerator.php deleted file mode 100644 index 71dfbfc40..000000000 --- a/src/Api/UrlGenerator.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Api; - -use Flarum\Http\AbstractUrlGenerator; - -class UrlGenerator extends AbstractUrlGenerator -{ - /** - * {@inheritdoc} - */ - protected $path = 'api'; -} diff --git a/src/Forum/Controller/DiscussionController.php b/src/Forum/Controller/DiscussionController.php index f952ba799..216f72961 100644 --- a/src/Forum/Controller/DiscussionController.php +++ b/src/Forum/Controller/DiscussionController.php @@ -13,8 +13,8 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; use Flarum\Forum\Frontend; -use Flarum\Forum\UrlGenerator; use Flarum\Http\Exception\RouteNotFoundException; +use Flarum\Http\UrlGenerator; use Flarum\User\User; use Illuminate\Contracts\Events\Dispatcher; use Psr\Http\Message\ServerRequestInterface as Request; @@ -73,7 +73,7 @@ class DiscussionController extends FrontendController $newQueryParams = array_merge($queryParams, $newQueryParams); $queryString = http_build_query($newQueryParams); - return $this->url->toRoute('discussion', ['id' => $document->data->id]). + return $this->url->to('forum')->route('discussion', ['id' => $document->data->id]). ($queryString ? '?'.$queryString : ''); }; diff --git a/src/Forum/Controller/SavePasswordController.php b/src/Forum/Controller/SavePasswordController.php index 541113ebd..0d1c76fa0 100644 --- a/src/Forum/Controller/SavePasswordController.php +++ b/src/Forum/Controller/SavePasswordController.php @@ -11,9 +11,9 @@ namespace Flarum\Forum\Controller; -use Flarum\Forum\UrlGenerator; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\SessionAuthenticator; +use Flarum\Http\UrlGenerator; use Flarum\User\PasswordToken; use Flarum\User\UserValidator; use Illuminate\Contracts\Validation\Factory; @@ -81,7 +81,7 @@ class SavePasswordController implements ControllerInterface } catch (ValidationException $e) { $request->getAttribute('session')->set('error', $e->errors()->first()); - return new RedirectResponse($this->url->toRoute('resetPassword', ['token' => $token->id])); + return new RedirectResponse($this->url->to('forum')->route('resetPassword', ['token' => $token->id])); } $token->user->changePassword($password); @@ -92,6 +92,6 @@ class SavePasswordController implements ControllerInterface $session = $request->getAttribute('session'); $this->authenticator->logIn($session, $token->user->id); - return new RedirectResponse($this->url->toBase()); + return new RedirectResponse($this->url->to('forum')->base()); } } diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 7526ad4b7..682d8194b 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -17,6 +17,7 @@ use Flarum\Extension\Event\Enabled; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Http\RouteCollection; use Flarum\Http\RouteHandlerFactory; +use Flarum\Http\UrlGenerator; use Flarum\Settings\Event\Saved; class ForumServiceProvider extends AbstractServiceProvider @@ -26,8 +27,8 @@ class ForumServiceProvider extends AbstractServiceProvider */ public function register() { - $this->app->singleton(UrlGenerator::class, function () { - return new UrlGenerator($this->app, $this->app->make('flarum.forum.routes')); + $this->app->extend(UrlGenerator::class, function (UrlGenerator $url) { + return $url->addCollection('forum', $this->app->make('flarum.forum.routes')); }); $this->app->singleton('flarum.forum.routes', function () { diff --git a/src/Forum/UrlGenerator.php b/src/Forum/UrlGenerator.php deleted file mode 100644 index b18fbb42f..000000000 --- a/src/Forum/UrlGenerator.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Forum; - -use Flarum\Http\AbstractUrlGenerator; - -class UrlGenerator extends AbstractUrlGenerator -{ -} diff --git a/src/Http/AbstractUrlGenerator.php b/src/Http/RouteCollectionUrlGenerator.php similarity index 64% rename from src/Http/AbstractUrlGenerator.php rename to src/Http/RouteCollectionUrlGenerator.php index ccd0d78ef..dbcb8927e 100644 --- a/src/Http/AbstractUrlGenerator.php +++ b/src/Http/RouteCollectionUrlGenerator.php @@ -11,14 +11,12 @@ namespace Flarum\Http; -use Flarum\Foundation\Application; - -class AbstractUrlGenerator +class RouteCollectionUrlGenerator { /** - * @var Application + * @var string|null */ - protected $app; + protected $baseUrl; /** * @var RouteCollection @@ -26,17 +24,12 @@ class AbstractUrlGenerator protected $routes; /** - * @var string|null - */ - protected $path; - - /** - * @param Application $app + * @param string $baseUrl * @param RouteCollection $routes */ - public function __construct(Application $app, RouteCollection $routes) + public function __construct($baseUrl, RouteCollection $routes) { - $this->app = $app; + $this->baseUrl = $baseUrl; $this->routes = $routes; } @@ -47,12 +40,12 @@ class AbstractUrlGenerator * @param array $parameters * @return string */ - public function toRoute($name, $parameters = []) + public function route($name, $parameters = []) { $path = $this->routes->getPath($name, $parameters); $path = ltrim($path, '/'); - return $this->toBase().'/'.$path; + return $this->baseUrl.'/'.$path; } /** @@ -61,9 +54,9 @@ class AbstractUrlGenerator * @param string $path * @return string */ - public function toPath($path) + public function path($path) { - return $this->toBase().'/'.$path; + return $this->baseUrl.'/'.$path; } /** @@ -71,8 +64,8 @@ class AbstractUrlGenerator * * @return string */ - public function toBase() + public function base() { - return $this->app->url($this->path); + return $this->baseUrl; } } diff --git a/src/Http/UrlGenerator.php b/src/Http/UrlGenerator.php new file mode 100644 index 000000000..86e814731 --- /dev/null +++ b/src/Http/UrlGenerator.php @@ -0,0 +1,59 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Http; + +use Flarum\Foundation\Application; + +class UrlGenerator +{ + /** + * @var array + */ + protected $routes = []; + + /** + * @param Application $app + */ + public function __construct(Application $app) + { + $this->app = $app; + } + + /** + * Register a named route collection for URL generation. + * + * @param string $key + * @param RouteCollection $routes + * @param string $prefix + * @return static + */ + public function addCollection($key, RouteCollection $routes, $prefix = null) + { + $this->routes[$key] = new RouteCollectionUrlGenerator( + $this->app->url($prefix), + $routes + ); + + return $this; + } + + /** + * Retrieve an URL generator instance for the given named route collection. + * + * @param string $collection + * @return RouteCollectionUrlGenerator + */ + public function to($collection) + { + return $this->routes[$collection]; + } +} diff --git a/src/User/Command/RequestPasswordResetHandler.php b/src/User/Command/RequestPasswordResetHandler.php index ba464a698..c0ac0c7fd 100644 --- a/src/User/Command/RequestPasswordResetHandler.php +++ b/src/User/Command/RequestPasswordResetHandler.php @@ -11,7 +11,7 @@ namespace Flarum\User\Command; -use Flarum\Forum\UrlGenerator; +use Flarum\Http\UrlGenerator; use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\PasswordToken; use Flarum\User\UserRepository; @@ -107,7 +107,7 @@ class RequestPasswordResetHandler $data = [ '{username}' => $user->username, - '{url}' => $this->url->toRoute('resetPassword', ['token' => $token->id]), + '{url}' => $this->url->to('forum')->route('resetPassword', ['token' => $token->id]), '{forum}' => $this->settings->get('forum_title'), ]; diff --git a/src/User/EmailConfirmationMailer.php b/src/User/EmailConfirmationMailer.php index 9ff225dc9..3273690b1 100755 --- a/src/User/EmailConfirmationMailer.php +++ b/src/User/EmailConfirmationMailer.php @@ -11,7 +11,7 @@ namespace Flarum\User; -use Flarum\Forum\UrlGenerator; +use Flarum\Http\UrlGenerator; use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\Event\EmailChangeRequested; use Flarum\User\Event\Registered; @@ -128,7 +128,7 @@ class EmailConfirmationMailer return [ '{username}' => $user->username, - '{url}' => $this->url->toRoute('confirmEmail', ['token' => $token->id]), + '{url}' => $this->url->to('forum')->route('confirmEmail', ['token' => $token->id]), '{forum}' => $this->settings->get('forum_title') ]; } diff --git a/src/User/User.php b/src/User/User.php index b035a58f4..8c9cce87f 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -325,9 +325,9 @@ class User extends AbstractModel */ public function getAvatarUrlAttribute() { - $urlGenerator = app('Flarum\Forum\UrlGenerator'); + $urlGenerator = app('Flarum\Http\UrlGenerator'); - return $this->avatar_path ? $urlGenerator->toPath('assets/avatars/'.$this->avatar_path) : null; + return $this->avatar_path ? $urlGenerator->to('forum')->path('assets/avatars/'.$this->avatar_path) : null; } /** diff --git a/views/index.blade.php b/views/index.blade.php index cbde0cff7..ce3a54feb 100644 --- a/views/index.blade.php +++ b/views/index.blade.php @@ -1,5 +1,5 @@ <?php -$url = app('Flarum\Forum\UrlGenerator'); +$url = app('Flarum\Http\UrlGenerator'); ?> <div class="container"> <h2>{{ $translator->trans('core.views.index.all_discussions_heading') }}</h2> @@ -7,7 +7,7 @@ $url = app('Flarum\Forum\UrlGenerator'); <ul> @foreach ($document->data as $discussion) <li> - <a href="{{ $url->toRoute('discussion', [ + <a href="{{ $url->to('forum')->route('discussion', [ 'id' => $discussion->id . '-' . $discussion->attributes->slug ]) }}"> {{ $discussion->attributes->title }} @@ -16,5 +16,5 @@ $url = app('Flarum\Forum\UrlGenerator'); @endforeach </ul> - <a href="{{ $url->toRoute('index') }}?page={{ $page + 1 }}">{{ $translator->trans('core.views.index.next_page_button') }} »</a> + <a href="{{ $url->to('forum')->route('index') }}?page={{ $page + 1 }}">{{ $translator->trans('core.views.index.next_page_button') }} »</a> </div> diff --git a/views/reset.blade.php b/views/reset.blade.php index 671157b38..fd4a254c9 100644 --- a/views/reset.blade.php +++ b/views/reset.blade.php @@ -15,7 +15,7 @@ <p style="color:red">{{ $error }}</p> @endif - <form class="form-horizontal" role="form" method="POST" action="{{ app('Flarum\Forum\UrlGenerator')->toRoute('savePassword') }}"> + <form class="form-horizontal" role="form" method="POST" action="{{ app('Flarum\Http\UrlGenerator')->to('forum')->route('savePassword') }}"> <input type="hidden" name="csrfToken" value="{{ $csrfToken }}"> <input type="hidden" name="passwordToken" value="{{ $passwordToken }}"> From 9c77475985f0c086581b8ac4aeca88b560686525 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Mon, 26 Jun 2017 09:06:32 +0200 Subject: [PATCH 38/86] Fix order of namespace imports --- src/User/Command/DeleteAvatarHandler.php | 2 +- src/User/Command/UploadAvatarHandler.php | 2 +- src/User/Search/UserSearcher.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/User/Command/DeleteAvatarHandler.php b/src/User/Command/DeleteAvatarHandler.php index e920f7192..e1f5aeecf 100644 --- a/src/User/Command/DeleteAvatarHandler.php +++ b/src/User/Command/DeleteAvatarHandler.php @@ -11,9 +11,9 @@ namespace Flarum\User\Command; -use Flarum\User\Event\AvatarDeleting; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; +use Flarum\User\Event\AvatarDeleting; use Flarum\User\UserRepository; use Illuminate\Contracts\Events\Dispatcher; use League\Flysystem\FilesystemInterface; diff --git a/src/User/Command/UploadAvatarHandler.php b/src/User/Command/UploadAvatarHandler.php index 2aa28044a..6bc1aa181 100644 --- a/src/User/Command/UploadAvatarHandler.php +++ b/src/User/Command/UploadAvatarHandler.php @@ -12,11 +12,11 @@ namespace Flarum\User\Command; use Exception; -use Flarum\User\Event\AvatarSaving; use Flarum\Foundation\Application; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; use Flarum\User\AvatarValidator; +use Flarum\User\Event\AvatarSaving; use Flarum\User\UserRepository; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Support\Str; diff --git a/src/User/Search/UserSearcher.php b/src/User/Search/UserSearcher.php index 55ce2b5ff..7bc268c23 100644 --- a/src/User/Search/UserSearcher.php +++ b/src/User/Search/UserSearcher.php @@ -11,11 +11,11 @@ namespace Flarum\User\Search; -use Flarum\User\Event\Searching; use Flarum\Search\ApplySearchParametersTrait; use Flarum\Search\GambitManager; use Flarum\Search\SearchCriteria; use Flarum\Search\SearchResults; +use Flarum\User\Event\Searching; use Flarum\User\UserRepository; /** From 3ece3ca9765a9fc88dbb83aecb154de66ed29190 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Mon, 26 Jun 2017 23:28:41 +0200 Subject: [PATCH 39/86] Move events to Flarum\Api namespace --- src/Api/Controller/AbstractSerializeController.php | 8 ++++---- .../Event/Serializing.php} | 6 +++--- .../Event/WillGetData.php} | 4 ++-- .../Event/WillSerializeData.php} | 4 ++-- src/Api/Serializer/AbstractSerializer.php | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) rename src/{Event/PrepareApiAttributes.php => Api/Event/Serializing.php} (92%) rename src/{Event/ConfigureApiController.php => Api/Event/WillGetData.php} (98%) rename src/{Event/PrepareApiData.php => Api/Event/WillSerializeData.php} (96%) diff --git a/src/Api/Controller/AbstractSerializeController.php b/src/Api/Controller/AbstractSerializeController.php index 5bcdfb274..a7ea98986 100644 --- a/src/Api/Controller/AbstractSerializeController.php +++ b/src/Api/Controller/AbstractSerializeController.php @@ -11,9 +11,9 @@ namespace Flarum\Api\Controller; +use Flarum\Api\Event\WillGetData; +use Flarum\Api\Event\WillSerializeData; use Flarum\Api\JsonApiResponse; -use Flarum\Event\ConfigureApiController; -use Flarum\Event\PrepareApiData; use Flarum\Http\Controller\ControllerInterface; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Events\Dispatcher; @@ -91,13 +91,13 @@ abstract class AbstractSerializeController implements ControllerInterface $document = new Document; static::$events->fire( - new ConfigureApiController($this) + new WillGetData($this) ); $data = $this->data($request, $document); static::$events->fire( - new PrepareApiData($this, $data, $request, $document) + new WillSerializeData($this, $data, $request, $document) ); $serializer = static::$container->make($this->serializer); diff --git a/src/Event/PrepareApiAttributes.php b/src/Api/Event/Serializing.php similarity index 92% rename from src/Event/PrepareApiAttributes.php rename to src/Api/Event/Serializing.php index c97ad794e..d84c9c1fe 100644 --- a/src/Event/PrepareApiAttributes.php +++ b/src/Api/Event/Serializing.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Api\Event; use DateTime; use Flarum\Api\Serializer\AbstractSerializer; @@ -17,10 +17,10 @@ use Flarum\Api\Serializer\AbstractSerializer; /** * Prepare API attributes. * - * This event is fired when a serialize is constructing an array of resource + * This event is fired when a serializer is constructing an array of resource * attributes for API output. */ -class PrepareApiAttributes +class Serializing { /** * The class doing the serializing. diff --git a/src/Event/ConfigureApiController.php b/src/Api/Event/WillGetData.php similarity index 98% rename from src/Event/ConfigureApiController.php rename to src/Api/Event/WillGetData.php index 974944674..790c546b0 100644 --- a/src/Event/ConfigureApiController.php +++ b/src/Api/Event/WillGetData.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Api\Event; use Flarum\Api\Controller\AbstractSerializeController; -class ConfigureApiController +class WillGetData { /** * @var AbstractSerializeController diff --git a/src/Event/PrepareApiData.php b/src/Api/Event/WillSerializeData.php similarity index 96% rename from src/Event/PrepareApiData.php rename to src/Api/Event/WillSerializeData.php index 6d9b8f547..700bb9ee6 100644 --- a/src/Event/PrepareApiData.php +++ b/src/Api/Event/WillSerializeData.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Api\Event; use Flarum\Api\Controller\AbstractSerializeController; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; -class PrepareApiData +class WillSerializeData { /** * @var AbstractSerializeController diff --git a/src/Api/Serializer/AbstractSerializer.php b/src/Api/Serializer/AbstractSerializer.php index a11c9e28a..279c976a5 100644 --- a/src/Api/Serializer/AbstractSerializer.php +++ b/src/Api/Serializer/AbstractSerializer.php @@ -13,8 +13,8 @@ namespace Flarum\Api\Serializer; use Closure; use DateTime; +use Flarum\Api\Event\Serializing; use Flarum\Event\GetApiRelationship; -use Flarum\Event\PrepareApiAttributes; use Flarum\User\User; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Events\Dispatcher; @@ -71,7 +71,7 @@ abstract class AbstractSerializer extends BaseAbstractSerializer $attributes = $this->getDefaultAttributes($model); static::$dispatcher->fire( - new PrepareApiAttributes($this, $model, $attributes) + new Serializing($this, $model, $attributes) ); return $attributes; From b4c7f8ca8968e119bb69fd2b798e1ee129531955 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Mon, 26 Jun 2017 23:30:51 +0200 Subject: [PATCH 40/86] Move event to Flarum\User namespace --- .../CheckUserPassword.php => User/Event/CheckingPassword.php} | 4 ++-- src/User/User.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/{Event/CheckUserPassword.php => User/Event/CheckingPassword.php} (91%) diff --git a/src/Event/CheckUserPassword.php b/src/User/Event/CheckingPassword.php similarity index 91% rename from src/Event/CheckUserPassword.php rename to src/User/Event/CheckingPassword.php index fa9ef2277..97f73227c 100644 --- a/src/Event/CheckUserPassword.php +++ b/src/User/Event/CheckingPassword.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\User\Event; use Flarum\User\User; -class CheckUserPassword +class CheckingPassword { /** * @var User diff --git a/src/User/User.php b/src/User/User.php index 8c9cce87f..78858643e 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -14,7 +14,6 @@ namespace Flarum\User; use DomainException; use Flarum\Database\AbstractModel; use Flarum\Database\ScopeVisibilityTrait; -use Flarum\Event\CheckUserPassword; use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\PrepareUserGroups; use Flarum\Foundation\Application; @@ -26,6 +25,7 @@ use Flarum\Post\Event\Deleted as PostDeleted; use Flarum\User\Event\Activated; use Flarum\User\Event\AvatarChanged; use Flarum\User\Event\BioChanged; +use Flarum\User\Event\CheckingPassword; use Flarum\User\Event\Deleted; use Flarum\User\Event\EmailChanged; use Flarum\User\Event\EmailChangeRequested; @@ -350,7 +350,7 @@ class User extends AbstractModel */ public function checkPassword($password) { - $valid = static::$dispatcher->until(new CheckUserPassword($this, $password)); + $valid = static::$dispatcher->until(new CheckingPassword($this, $password)); if ($valid !== null) { return $valid; From 69b517ea79560eb82cb9702ee16880a64054f090 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Fri, 30 Jun 2017 12:07:20 +0200 Subject: [PATCH 41/86] Get rid of Server classes for Admin, API and Forum The various middleware can be registered in the service provider, and the rest of the logic can all go through one single front controller (index.php in flarum/flarum, and Flarum\Http\Server in flarum/core). This will also simplify the necessary server setup, as only one rewrite rule remains. --- src/Admin/AdminServiceProvider.php | 33 ++++++ src/Admin/Server.php | 58 ----------- src/Api/ApiServiceProvider.php | 32 ++++++ src/Api/Server.php | 62 ----------- src/Event/ConfigureMiddleware.php | 27 ++--- src/Forum/ForumServiceProvider.php | 31 ++++++ src/Forum/Server.php | 61 ----------- src/Http/AbstractServer.php | 81 --------------- src/Http/FullStackServer.php | 37 ------- src/Http/Server.php | 159 +++++++++++++++++++++++++++++ 10 files changed, 263 insertions(+), 318 deletions(-) delete mode 100644 src/Admin/Server.php delete mode 100644 src/Api/Server.php delete mode 100644 src/Forum/Server.php delete mode 100644 src/Http/AbstractServer.php delete mode 100644 src/Http/FullStackServer.php create mode 100644 src/Http/Server.php diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index 913c6493a..f7da26d04 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -11,13 +11,23 @@ namespace Flarum\Admin; +use Flarum\Admin\Middleware\RequireAdministrateAbility; +use Flarum\Event\ConfigureMiddleware; use Flarum\Extension\Event\Disabled; use Flarum\Extension\Event\Enabled; use Flarum\Foundation\AbstractServiceProvider; +use Flarum\Http\Middleware\AuthenticateWithSession; +use Flarum\Http\Middleware\DispatchRoute; +use Flarum\Http\Middleware\HandleErrors; +use Flarum\Http\Middleware\ParseJsonBody; +use Flarum\Http\Middleware\RememberFromCookie; +use Flarum\Http\Middleware\SetLocale; +use Flarum\Http\Middleware\StartSession; use Flarum\Http\RouteCollection; use Flarum\Http\RouteHandlerFactory; use Flarum\Http\UrlGenerator; use Flarum\Settings\Event\Saved; +use Zend\Stratigility\MiddlewarePipe; class AdminServiceProvider extends AbstractServiceProvider { @@ -33,6 +43,29 @@ class AdminServiceProvider extends AbstractServiceProvider $this->app->singleton('flarum.admin.routes', function () { return new RouteCollection; }); + + $this->app->singleton('flarum.admin.middleware', function ($app) { + $pipe = new MiddlewarePipe; + $pipe->raiseThrowables(); + + // All requests should first be piped through our global error handler + $debugMode = ! $app->isUpToDate() || $app->inDebugMode(); + $errorDir = __DIR__.'/../../error'; + $pipe->pipe(new HandleErrors($errorDir, $app->make('log'), $debugMode)); + + $pipe->pipe($app->make(ParseJsonBody::class)); + $pipe->pipe($app->make(StartSession::class)); + $pipe->pipe($app->make(RememberFromCookie::class)); + $pipe->pipe($app->make(AuthenticateWithSession::class)); + $pipe->pipe($app->make(SetLocale::class)); + $pipe->pipe($app->make(RequireAdministrateAbility::class)); + + event(new ConfigureMiddleware($pipe, 'admin')); + + $pipe->pipe($app->make(DispatchRoute::class, ['routes' => $app->make('flarum.admin.routes')])); + + return $pipe; + }); } /** diff --git a/src/Admin/Server.php b/src/Admin/Server.php deleted file mode 100644 index 43aa38116..000000000 --- a/src/Admin/Server.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Admin; - -use Flarum\Event\ConfigureMiddleware; -use Flarum\Foundation\Application; -use Flarum\Http\AbstractServer; -use Flarum\Http\Middleware\HandleErrors; -use Zend\Stratigility\MiddlewarePipe; - -class Server extends AbstractServer -{ - /** - * {@inheritdoc} - */ - protected function getMiddleware(Application $app) - { - $pipe = new MiddlewarePipe; - $pipe->raiseThrowables(); - - if ($app->isInstalled()) { - $path = parse_url($app->url('admin'), PHP_URL_PATH); - $errorDir = __DIR__.'/../../error'; - - // All requests should first be piped through our global error handler - $debugMode = ! $app->isUpToDate() || $app->inDebugMode(); - $pipe->pipe($path, new HandleErrors($errorDir, $app->make('log'), $debugMode)); - - if ($app->isUpToDate()) { - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\ParseJsonBody')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\StartSession')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\RememberFromCookie')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\AuthenticateWithSession')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\SetLocale')); - $pipe->pipe($path, $app->make('Flarum\Admin\Middleware\RequireAdministrateAbility')); - - event(new ConfigureMiddleware($pipe, $path, $this)); - - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\DispatchRoute', ['routes' => $app->make('flarum.admin.routes')])); - } else { - $app->register('Flarum\Update\UpdateServiceProvider'); - - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\DispatchRoute', ['routes' => $app->make('flarum.update.routes')])); - } - } - - return $pipe; - } -} diff --git a/src/Api/ApiServiceProvider.php b/src/Api/ApiServiceProvider.php index ed4f916f3..7360358a3 100644 --- a/src/Api/ApiServiceProvider.php +++ b/src/Api/ApiServiceProvider.php @@ -12,17 +12,28 @@ namespace Flarum\Api; use Flarum\Api\Controller\AbstractSerializeController; +use Flarum\Api\Middleware\FakeHttpMethods; +use Flarum\Api\Middleware\HandleErrors; use Flarum\Api\Serializer\AbstractSerializer; use Flarum\Api\Serializer\NotificationSerializer; use Flarum\Event\ConfigureApiRoutes; +use Flarum\Event\ConfigureMiddleware; use Flarum\Event\ConfigureNotificationTypes; use Flarum\Foundation\AbstractServiceProvider; +use Flarum\Http\Middleware\AuthenticateWithHeader; +use Flarum\Http\Middleware\AuthenticateWithSession; +use Flarum\Http\Middleware\DispatchRoute; +use Flarum\Http\Middleware\ParseJsonBody; +use Flarum\Http\Middleware\RememberFromCookie; +use Flarum\Http\Middleware\SetLocale; +use Flarum\Http\Middleware\StartSession; use Flarum\Http\RouteCollection; use Flarum\Http\RouteHandlerFactory; use Flarum\Http\UrlGenerator; use Tobscure\JsonApi\ErrorHandler; use Tobscure\JsonApi\Exception\Handler\FallbackExceptionHandler; use Tobscure\JsonApi\Exception\Handler\InvalidParameterExceptionHandler; +use Zend\Stratigility\MiddlewarePipe; class ApiServiceProvider extends AbstractServiceProvider { @@ -39,6 +50,27 @@ class ApiServiceProvider extends AbstractServiceProvider return new RouteCollection; }); + $this->app->singleton('flarum.api.middleware', function ($app) { + $pipe = new MiddlewarePipe; + $pipe->raiseThrowables(); + + $pipe->pipe($app->make(HandleErrors::class)); + + $pipe->pipe($app->make(ParseJsonBody::class)); + $pipe->pipe($app->make(FakeHttpMethods::class)); + $pipe->pipe($app->make(StartSession::class)); + $pipe->pipe($app->make(RememberFromCookie::class)); + $pipe->pipe($app->make(AuthenticateWithSession::class)); + $pipe->pipe($app->make(AuthenticateWithHeader::class)); + $pipe->pipe($app->make(SetLocale::class)); + + event(new ConfigureMiddleware($pipe, 'api')); + + $pipe->pipe($app->make(DispatchRoute::class, ['routes' => $app->make('flarum.api.routes')])); + + return $pipe; + }); + $this->app->singleton(ErrorHandler::class, function () { $handler = new ErrorHandler; diff --git a/src/Api/Server.php b/src/Api/Server.php deleted file mode 100644 index 79dbb03b6..000000000 --- a/src/Api/Server.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Api; - -use Flarum\Event\ConfigureMiddleware; -use Flarum\Foundation\Application; -use Flarum\Http\AbstractServer; -use Tobscure\JsonApi\Document; -use Zend\Stratigility\MiddlewarePipe; - -class Server extends AbstractServer -{ - /** - * {@inheritdoc} - */ - protected function getMiddleware(Application $app) - { - $pipe = new MiddlewarePipe; - $pipe->raiseThrowables(); - - $path = parse_url($app->url('api'), PHP_URL_PATH); - - if ($app->isInstalled() && $app->isUpToDate()) { - $pipe->pipe($path, $app->make('Flarum\Api\Middleware\HandleErrors')); - - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\ParseJsonBody')); - $pipe->pipe($path, $app->make('Flarum\Api\Middleware\FakeHttpMethods')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\StartSession')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\RememberFromCookie')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\AuthenticateWithSession')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\AuthenticateWithHeader')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\SetLocale')); - - event(new ConfigureMiddleware($pipe, $path, $this)); - - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\DispatchRoute', ['routes' => $app->make('flarum.api.routes')])); - } else { - $pipe->pipe($path, function () { - $document = new Document; - $document->setErrors([ - [ - 'code' => 503, - 'title' => 'Service Unavailable' - ] - ]); - - return new JsonApiResponse($document, 503); - }); - } - - return $pipe; - } -} diff --git a/src/Event/ConfigureMiddleware.php b/src/Event/ConfigureMiddleware.php index 80ebb649f..e602d5532 100644 --- a/src/Event/ConfigureMiddleware.php +++ b/src/Event/ConfigureMiddleware.php @@ -11,10 +11,6 @@ namespace Flarum\Event; -use Flarum\Admin\Server as AdminServer; -use Flarum\Api\Server as ApiServer; -use Flarum\Forum\Server as ForumServer; -use Flarum\Foundation\AbstractServer; use Zend\Stratigility\MiddlewarePipe; class ConfigureMiddleware @@ -27,42 +23,35 @@ class ConfigureMiddleware /** * @var string */ - public $path; - - /** - * @var AbstractServer - */ - public $server; + public $stackName; /** * @param MiddlewarePipe $pipe - * @param string $path - * @param AbstractServer $server + * @param string $stackName */ - public function __construct(MiddlewarePipe $pipe, $path, AbstractServer $server) + public function __construct(MiddlewarePipe $pipe, $stackName) { $this->pipe = $pipe; - $this->path = $path; - $this->server = $server; + $this->stackName = $stackName; } public function pipe(callable $middleware) { - $this->pipe->pipe($this->path, $middleware); + $this->pipe->pipe($middleware); } public function isForum() { - return $this->server instanceof ForumServer; + return $this->stackName === 'forum'; } public function isAdmin() { - return $this->server instanceof AdminServer; + return $this->stackName === 'admin'; } public function isApi() { - return $this->server instanceof ApiServer; + return $this->stackName === 'api'; } } diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 682d8194b..1e2e058b4 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -12,13 +12,22 @@ namespace Flarum\Forum; use Flarum\Event\ConfigureForumRoutes; +use Flarum\Event\ConfigureMiddleware; use Flarum\Extension\Event\Disabled; use Flarum\Extension\Event\Enabled; use Flarum\Foundation\AbstractServiceProvider; +use Flarum\Http\Middleware\AuthenticateWithSession; +use Flarum\Http\Middleware\DispatchRoute; +use Flarum\Http\Middleware\HandleErrors; +use Flarum\Http\Middleware\ParseJsonBody; +use Flarum\Http\Middleware\RememberFromCookie; +use Flarum\Http\Middleware\SetLocale; +use Flarum\Http\Middleware\StartSession; use Flarum\Http\RouteCollection; use Flarum\Http\RouteHandlerFactory; use Flarum\Http\UrlGenerator; use Flarum\Settings\Event\Saved; +use Zend\Stratigility\MiddlewarePipe; class ForumServiceProvider extends AbstractServiceProvider { @@ -34,6 +43,28 @@ class ForumServiceProvider extends AbstractServiceProvider $this->app->singleton('flarum.forum.routes', function () { return new RouteCollection; }); + + $this->app->singleton('flarum.forum.middleware', function ($app) { + $pipe = new MiddlewarePipe; + $pipe->raiseThrowables(); + + // All requests should first be piped through our global error handler + $debugMode = ! $app->isUpToDate() || $app->inDebugMode(); + $errorDir = __DIR__.'/../../error'; + $pipe->pipe(new HandleErrors($errorDir, $app->make('log'), $debugMode)); + + $pipe->pipe($app->make(ParseJsonBody::class)); + $pipe->pipe($app->make(StartSession::class)); + $pipe->pipe($app->make(RememberFromCookie::class)); + $pipe->pipe($app->make(AuthenticateWithSession::class)); + $pipe->pipe($app->make(SetLocale::class)); + + event(new ConfigureMiddleware($pipe, 'forum')); + + $pipe->pipe($app->make(DispatchRoute::class, ['routes' => $app->make('flarum.forum.routes')])); + + return $pipe; + }); } /** diff --git a/src/Forum/Server.php b/src/Forum/Server.php deleted file mode 100644 index 893ddc52c..000000000 --- a/src/Forum/Server.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Forum; - -use Flarum\Event\ConfigureMiddleware; -use Flarum\Foundation\Application; -use Flarum\Http\AbstractServer; -use Flarum\Http\Middleware\HandleErrors; -use Zend\Diactoros\Response\HtmlResponse; -use Zend\Stratigility\MiddlewarePipe; - -class Server extends AbstractServer -{ - /** - * {@inheritdoc} - */ - protected function getMiddleware(Application $app) - { - $pipe = new MiddlewarePipe; - $pipe->raiseThrowables(); - - $path = parse_url($app->url(), PHP_URL_PATH); - $errorDir = __DIR__.'/../../error'; - - if (! $app->isInstalled()) { - $app->register('Flarum\Install\InstallServiceProvider'); - - $pipe->pipe($path, new HandleErrors($errorDir, $app->make('log'), true)); - - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\StartSession')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\DispatchRoute', ['routes' => $app->make('flarum.install.routes')])); - } elseif ($app->isUpToDate() && ! $app->isDownForMaintenance()) { - $pipe->pipe($path, new HandleErrors($errorDir, $app->make('log'), $app->inDebugMode())); - - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\ParseJsonBody')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\StartSession')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\RememberFromCookie')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\AuthenticateWithSession')); - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\SetLocale')); - - event(new ConfigureMiddleware($pipe, $path, $this)); - - $pipe->pipe($path, $app->make('Flarum\Http\Middleware\DispatchRoute', ['routes' => $app->make('flarum.forum.routes')])); - } else { - $pipe->pipe($path, function () use ($errorDir) { - return new HtmlResponse(file_get_contents($errorDir.'/503.html', 503)); - }); - } - - return $pipe; - } -} diff --git a/src/Http/AbstractServer.php b/src/Http/AbstractServer.php deleted file mode 100644 index 0cf7bd39d..000000000 --- a/src/Http/AbstractServer.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Http; - -use Flarum\Foundation\AbstractServer as BaseAbstractServer; -use Flarum\Foundation\Application; -use Flarum\User\AuthToken; -use Flarum\User\EmailToken; -use Flarum\User\PasswordToken; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; -use Zend\Diactoros\Server; -use Zend\Stratigility\MiddlewareInterface; -use Zend\Stratigility\NoopFinalHandler; - -abstract class AbstractServer extends BaseAbstractServer -{ - public function listen() - { - Server::createServer( - $this, - $_SERVER, - $_GET, - $_POST, - $_COOKIE, - $_FILES - )->listen(new NoopFinalHandler()); - } - - /** - * Use as PSR-7 middleware. - * - * @param ServerRequestInterface $request - * @param ResponseInterface $response - * @param callable $out - * @return ResponseInterface - */ - public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out) - { - $app = $this->getApp(); - - $this->collectGarbage($app); - - $middleware = $this->getMiddleware($app); - - return $middleware($request, $response, $out); - } - - /** - * @param Application $app - * @return MiddlewareInterface - */ - abstract protected function getMiddleware(Application $app); - - private function collectGarbage() - { - if ($this->hitsLottery()) { - AccessToken::whereRaw('last_activity <= ? - lifetime', [time()])->delete(); - - $earliestToKeep = date('Y-m-d H:i:s', time() - 24 * 60 * 60); - - EmailToken::where('created_at', '<=', $earliestToKeep)->delete(); - PasswordToken::where('created_at', '<=', $earliestToKeep)->delete(); - AuthToken::where('created_at', '<=', $earliestToKeep)->delete(); - } - } - - private function hitsLottery() - { - return mt_rand(1, 100) <= 2; - } -} diff --git a/src/Http/FullStackServer.php b/src/Http/FullStackServer.php deleted file mode 100644 index 70b331aba..000000000 --- a/src/Http/FullStackServer.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Http; - -use Flarum\Admin\Server as AdminServer; -use Flarum\Api\Server as ApiServer; -use Flarum\Forum\Server as ForumServer; -use Flarum\Foundation\Application; -use Zend\Stratigility\MiddlewarePipe; - -class FullStackServer extends AbstractServer -{ - /** - * @param Application $app - * @return \Zend\Stratigility\MiddlewareInterface - */ - protected function getMiddleware(Application $app) - { - $pipe = new MiddlewarePipe; - $pipe->raiseThrowables(); - - $pipe->pipe(new ApiServer); - $pipe->pipe(new AdminServer); - $pipe->pipe(new ForumServer); - - return $pipe; - } -} diff --git a/src/Http/Server.php b/src/Http/Server.php new file mode 100644 index 000000000..832b58dce --- /dev/null +++ b/src/Http/Server.php @@ -0,0 +1,159 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Http; + +use Flarum\Foundation\AbstractServer; +use Flarum\Foundation\Application; +use Flarum\Http\Middleware\DispatchRoute; +use Flarum\Http\Middleware\HandleErrors; +use Flarum\Http\Middleware\StartSession; +use Flarum\Install\InstallServiceProvider; +use Flarum\Update\UpdateServiceProvider; +use Flarum\User\AuthToken; +use Flarum\User\EmailToken; +use Flarum\User\PasswordToken; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use Zend\Diactoros\Response\HtmlResponse; +use Zend\Diactoros\Server as DiactorosServer; +use Zend\Stratigility\MiddlewareInterface; +use Zend\Stratigility\MiddlewarePipe; +use Zend\Stratigility\NoopFinalHandler; + +class Server extends AbstractServer +{ + public function listen() + { + DiactorosServer::createServer( + $this, + $_SERVER, + $_GET, + $_POST, + $_COOKIE, + $_FILES + )->listen(new NoopFinalHandler()); + } + + /** + * Use as PSR-7 middleware. + * + * @param ServerRequestInterface $request + * @param ResponseInterface $response + * @param callable $out + * @return ResponseInterface + */ + public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out) + { + $app = $this->getApp(); + + $this->collectGarbage($app); + + $middleware = $this->getMiddleware($app, $request->getUri()->getPath()); + + return $middleware($request, $response, $out); + } + + /** + * @param Application $app + * @param string $requestPath + * @return MiddlewareInterface + */ + protected function getMiddleware(Application $app, $requestPath) + { + $pipe = new MiddlewarePipe; + $pipe->raiseThrowables(); + + if (! $app->isInstalled()) { + return $this->getInstallerMiddleware($pipe, $app); + } else if ($app->isDownForMaintenance()) { + return $this->getMaintenanceMiddleware($pipe); + } else if (! $app->isUpToDate()) { + return $this->getUpdaterMiddleware($pipe, $app); + } + + $forum = parse_url($app->url(''), PHP_URL_PATH) ?: '/'; + $admin = parse_url($app->url('admin'), PHP_URL_PATH); + $api = parse_url($app->url('api'), PHP_URL_PATH); + + if ($this->pathStartsWith($requestPath, $api)) { + $pipe->pipe($api, $app->make('flarum.api.middleware')); + } else if ($this->pathStartsWith($requestPath, $admin)) { + $pipe->pipe($admin, $app->make('flarum.admin.middleware')); + } else { + $pipe->pipe($forum, $app->make('flarum.forum.middleware')); + } + + return $pipe; + } + + private function pathStartsWith($path, $prefix) + { + return $path === $prefix || starts_with($path, "$prefix/"); + } + + protected function getInstallerMiddleware(MiddlewarePipe $pipe, Application $app) + { + $app->register(InstallServiceProvider::class); + + $pipe->pipe(new HandleErrors($this->getErrorDir(), $app->make('log'), true)); + + $pipe->pipe($app->make(StartSession::class)); + $pipe->pipe($app->make(DispatchRoute::class, ['routes' => $app->make('flarum.install.routes')])); + + return $pipe; + } + + protected function getMaintenanceMiddleware(MiddlewarePipe $pipe) + { + $pipe->pipe(function () { + return new HtmlResponse(file_get_contents($this->getErrorDir().'/503.html', 503)); + }); + + // TODO: FOR API render JSON-API error document for HTTP 503 + + return $pipe; + } + + protected function getUpdaterMiddleware(MiddlewarePipe $pipe, Application $app) + { + $app->register(UpdateServiceProvider::class); + + $pipe->pipe($app->make(DispatchRoute::class, ['routes' => $app->make('flarum.update.routes')])); + + // TODO: FOR API render JSON-API error document for HTTP 503 + + return $pipe; + } + + private function collectGarbage() + { + if ($this->hitsLottery()) { + AccessToken::whereRaw('last_activity <= ? - lifetime', [time()])->delete(); + + $earliestToKeep = date('Y-m-d H:i:s', time() - 24 * 60 * 60); + + EmailToken::where('created_at', '<=', $earliestToKeep)->delete(); + PasswordToken::where('created_at', '<=', $earliestToKeep)->delete(); + AuthToken::where('created_at', '<=', $earliestToKeep)->delete(); + } + } + + private function getErrorDir() + { + return __DIR__.'/../../error'; + } + + private function hitsLottery() + { + return mt_rand(1, 100) <= 2; + } +} From 051bb5acb8a8544974898496bfc898186178347b Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Fri, 30 Jun 2017 12:37:33 +0200 Subject: [PATCH 42/86] Fix code style --- src/Http/Server.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Http/Server.php b/src/Http/Server.php index 832b58dce..86ce0af6a 100644 --- a/src/Http/Server.php +++ b/src/Http/Server.php @@ -74,9 +74,9 @@ class Server extends AbstractServer if (! $app->isInstalled()) { return $this->getInstallerMiddleware($pipe, $app); - } else if ($app->isDownForMaintenance()) { + } elseif ($app->isDownForMaintenance()) { return $this->getMaintenanceMiddleware($pipe); - } else if (! $app->isUpToDate()) { + } elseif (! $app->isUpToDate()) { return $this->getUpdaterMiddleware($pipe, $app); } @@ -86,7 +86,7 @@ class Server extends AbstractServer if ($this->pathStartsWith($requestPath, $api)) { $pipe->pipe($api, $app->make('flarum.api.middleware')); - } else if ($this->pathStartsWith($requestPath, $admin)) { + } elseif ($this->pathStartsWith($requestPath, $admin)) { $pipe->pipe($admin, $app->make('flarum.admin.middleware')); } else { $pipe->pipe($forum, $app->make('flarum.forum.middleware')); From e46b3d54d1b7cef6f475b8a8f843eac3388360ae Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sun, 2 Jul 2017 13:30:02 +0200 Subject: [PATCH 43/86] Extract Flarum\Foundation\Site class This class holds all information relevant to a local Flarum site, such as paths and local configuration. From this information, it is able to instantiate a Flarum\Foundation\Application instance, which represents a Flarum installation's runtime. This will also be useful for setting up e.g. multi-tenant environments. --- src/Console/Server.php | 35 +++-- src/Foundation/Application.php | 3 +- .../{AbstractServer.php => Site.php} | 147 ++++++++---------- src/Http/Server.php | 81 ++++++---- 4 files changed, 143 insertions(+), 123 deletions(-) rename src/Foundation/{AbstractServer.php => Site.php} (61%) diff --git a/src/Console/Server.php b/src/Console/Server.php index f7ad12cbb..36cdea59d 100644 --- a/src/Console/Server.php +++ b/src/Console/Server.php @@ -13,14 +13,30 @@ namespace Flarum\Console; use Flarum\Database\Console\GenerateMigrationCommand; use Flarum\Database\Console\MigrateCommand; -use Flarum\Foundation\AbstractServer; +use Flarum\Foundation\Application; use Flarum\Foundation\Console\CacheClearCommand; use Flarum\Foundation\Console\InfoCommand; +use Flarum\Foundation\Site; use Flarum\Install\Console\InstallCommand; -use Symfony\Component\Console\Application; +use Flarum\Install\InstallServiceProvider; +use Symfony\Component\Console\Application as ConsoleApplication; -class Server extends AbstractServer +class Server { + /** + * @param Site $site + * @return Server + */ + public static function fromSite(Site $site) + { + return new static($site->boot()); + } + + public function __construct(Application $app) + { + $this->app = $app; + } + public function listen() { $console = $this->getConsoleApplication(); @@ -29,14 +45,13 @@ class Server extends AbstractServer } /** - * @return Application + * @return ConsoleApplication */ protected function getConsoleApplication() { - $app = $this->getApp(); - $console = new Application('Flarum', $app->version()); + $console = new ConsoleApplication('Flarum', $this->app->version()); - $app->register('Flarum\Install\InstallServiceProvider'); + $this->app->register(InstallServiceProvider::class); $commands = [ InstallCommand::class, @@ -44,7 +59,7 @@ class Server extends AbstractServer GenerateMigrationCommand::class, ]; - if ($app->isInstalled()) { + if ($this->app->isInstalled()) { $commands = array_merge($commands, [ InfoCommand::class, CacheClearCommand::class @@ -52,9 +67,9 @@ class Server extends AbstractServer } foreach ($commands as $command) { - $console->add($app->make( + $console->add($this->app->make( $command, - ['config' => $app->isInstalled() ? $app->make('flarum.config') : []] + ['config' => $this->app->isInstalled() ? $this->app->make('flarum.config') : []] )); } diff --git a/src/Foundation/Application.php b/src/Foundation/Application.php index a432bdbb8..85533ffd9 100644 --- a/src/Foundation/Application.php +++ b/src/Foundation/Application.php @@ -11,6 +11,7 @@ namespace Flarum\Foundation; +use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Container\Container; use Illuminate\Contracts\Foundation\Application as ApplicationContract; use Illuminate\Events\EventServiceProvider; @@ -125,7 +126,7 @@ class Application extends Container implements ApplicationContract public function isUpToDate() { - $settings = $this->make('Flarum\Settings\SettingsRepositoryInterface'); + $settings = $this->make(SettingsRepositoryInterface::class); try { $version = $settings->get('version'); diff --git a/src/Foundation/AbstractServer.php b/src/Foundation/Site.php similarity index 61% rename from src/Foundation/AbstractServer.php rename to src/Foundation/Site.php index bcc7c534b..d59b6f056 100644 --- a/src/Foundation/AbstractServer.php +++ b/src/Foundation/Site.php @@ -11,12 +11,35 @@ namespace Flarum\Foundation; +use Flarum\Admin\AdminServiceProvider; +use Flarum\Api\ApiServiceProvider; +use Flarum\Database\DatabaseServiceProvider; +use Flarum\Database\MigrationServiceProvider; +use Flarum\Discussion\DiscussionServiceProvider; +use Flarum\Extension\ExtensionServiceProvider; +use Flarum\Formatter\FormatterServiceProvider; +use Flarum\Forum\ForumServiceProvider; +use Flarum\Group\GroupServiceProvider; +use Flarum\Locale\LocaleServiceProvider; +use Flarum\Notification\NotificationServiceProvider; +use Flarum\Post\PostServiceProvider; +use Flarum\Search\SearchServiceProvider; +use Flarum\Settings\SettingsRepositoryInterface; +use Flarum\Settings\SettingsServiceProvider; +use Flarum\User\UserServiceProvider; +use Illuminate\Bus\BusServiceProvider; use Illuminate\Config\Repository as ConfigRepository; +use Illuminate\Filesystem\FilesystemServiceProvider; +use Illuminate\Hashing\HashServiceProvider; +use Illuminate\Mail\MailServiceProvider; +use Illuminate\Validation\ValidationServiceProvider; +use Illuminate\View\ViewServiceProvider; use Monolog\Formatter\LineFormatter; use Monolog\Handler\StreamHandler; use Monolog\Logger; -abstract class AbstractServer +// TODO: This should be an interface maybe? +class Site { /** * @var Application @@ -43,27 +66,12 @@ abstract class AbstractServer */ protected $config; - /** - * @var callable[] - */ - protected $extendCallbacks = []; + protected $extenders = []; - /** - * @param null $basePath - * @param null $publicPath - */ - public function __construct($basePath = null, $publicPath = null) + public function __construct() { - if ($basePath === null) { - $basePath = getcwd(); - } - - if ($publicPath === null) { - $publicPath = $basePath; - } - - $this->basePath = $basePath; - $this->publicPath = $publicPath; + $this->basePath = getcwd(); + $this->publicPath = $this->basePath; if (file_exists($file = $this->basePath.'/config.php')) { $this->config = include $file; @@ -71,81 +79,61 @@ abstract class AbstractServer } /** - * @return string + * @return Application */ - public function getBasePath() + public function boot() { - return $this->basePath; - } - - /** - * @return string - */ - public function getPublicPath() - { - return $this->publicPath; - } - - /** - * @return string - */ - public function getStoragePath() - { - return $this->storagePath; + return $this->getApp(); } /** * @param $basePath + * @return static */ public function setBasePath($basePath) { $this->basePath = $basePath; + + return $this; } /** * @param $publicPath + * @return static */ public function setPublicPath($publicPath) { $this->publicPath = $publicPath; + + return $this; } /** * @param $storagePath + * @return static */ public function setStoragePath($storagePath) { $this->storagePath = $storagePath; - } - /** - * @return array - */ - public function getConfig() - { - return $this->config; + return $this; } /** * @param array $config + * @return static */ public function setConfig(array $config) { $this->config = $config; - } - /** - * @param callable $callback - */ - public function extend(callable $callback) - { - $this->extendCallbacks[] = $callback; + return $this; } /** * @return Application */ - public function getApp() + protected function getApp() { if ($this->app !== null) { return $this->app; @@ -167,19 +155,19 @@ abstract class AbstractServer $this->registerCache($app); - $app->register('Flarum\Database\DatabaseServiceProvider'); - $app->register('Flarum\Database\MigrationServiceProvider'); - $app->register('Flarum\Settings\SettingsServiceProvider'); - $app->register('Flarum\Locale\LocaleServiceProvider'); - $app->register('Illuminate\Bus\BusServiceProvider'); - $app->register('Illuminate\Filesystem\FilesystemServiceProvider'); - $app->register('Illuminate\Hashing\HashServiceProvider'); - $app->register('Illuminate\Mail\MailServiceProvider'); - $app->register('Illuminate\View\ViewServiceProvider'); - $app->register('Illuminate\Validation\ValidationServiceProvider'); + $app->register(DatabaseServiceProvider::class); + $app->register(MigrationServiceProvider::class); + $app->register(SettingsServiceProvider::class); + $app->register(LocaleServiceProvider::class); + $app->register(BusServiceProvider::class); + $app->register(FilesystemServiceProvider::class); + $app->register(HashServiceProvider::class); + $app->register(MailServiceProvider::class); + $app->register(ViewServiceProvider::class); + $app->register(ValidationServiceProvider::class); if ($app->isInstalled() && $app->isUpToDate()) { - $settings = $app->make('Flarum\Settings\SettingsRepositoryInterface'); + $settings = $app->make(SettingsRepositoryInterface::class); $config->set('mail.driver', $settings->get('mail_driver')); $config->set('mail.host', $settings->get('mail_host')); @@ -190,25 +178,26 @@ abstract class AbstractServer $config->set('mail.username', $settings->get('mail_username')); $config->set('mail.password', $settings->get('mail_password')); - $app->register('Flarum\BusServiceProvider'); + $app->register(\Flarum\BusServiceProvider::class); - $app->register('Flarum\Discussion\DiscussionServiceProvider'); - $app->register('Flarum\Formatter\FormatterServiceProvider'); - $app->register('Flarum\Group\GroupServiceProvider'); - $app->register('Flarum\Notification\NotificationServiceProvider'); - $app->register('Flarum\Post\PostServiceProvider'); - $app->register('Flarum\Search\SearchServiceProvider'); - $app->register('Flarum\User\UserServiceProvider'); + $app->register(DiscussionServiceProvider::class); + $app->register(FormatterServiceProvider::class); + $app->register(GroupServiceProvider::class); + $app->register(NotificationServiceProvider::class); + $app->register(PostServiceProvider::class); + $app->register(SearchServiceProvider::class); + $app->register(UserServiceProvider::class); - $app->register('Flarum\Api\ApiServiceProvider'); - $app->register('Flarum\Forum\ForumServiceProvider'); - $app->register('Flarum\Admin\AdminServiceProvider'); + $app->register(ApiServiceProvider::class); + $app->register(ForumServiceProvider::class); + $app->register(AdminServiceProvider::class); - foreach ($this->extendCallbacks as $callback) { - $app->call($callback); + foreach ($this->extenders as $extender) { + // TODO: Create extenders architecture + // $extender->apply($app); } - $app->register('Flarum\Extension\ExtensionServiceProvider'); + $app->register(ExtensionServiceProvider::class); } $app->boot(); diff --git a/src/Http/Server.php b/src/Http/Server.php index 86ce0af6a..590a73a24 100644 --- a/src/Http/Server.php +++ b/src/Http/Server.php @@ -11,8 +11,8 @@ namespace Flarum\Http; -use Flarum\Foundation\AbstractServer; use Flarum\Foundation\Application; +use Flarum\Foundation\Site; use Flarum\Http\Middleware\DispatchRoute; use Flarum\Http\Middleware\HandleErrors; use Flarum\Http\Middleware\StartSession; @@ -29,8 +29,22 @@ use Zend\Stratigility\MiddlewareInterface; use Zend\Stratigility\MiddlewarePipe; use Zend\Stratigility\NoopFinalHandler; -class Server extends AbstractServer +class Server { + /** + * @param Site $site + * @return Server + */ + public static function fromSite(Site $site) + { + return new static($site->boot()); + } + + public function __construct(Application $app) + { + $this->app = $app; + } + public function listen() { DiactorosServer::createServer( @@ -53,43 +67,44 @@ class Server extends AbstractServer */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out) { - $app = $this->getApp(); + $this->collectGarbage(); - $this->collectGarbage($app); - - $middleware = $this->getMiddleware($app, $request->getUri()->getPath()); + $middleware = $this->getMiddleware($request->getUri()->getPath()); return $middleware($request, $response, $out); } /** - * @param Application $app * @param string $requestPath * @return MiddlewareInterface */ - protected function getMiddleware(Application $app, $requestPath) + protected function getMiddleware($requestPath) { $pipe = new MiddlewarePipe; $pipe->raiseThrowables(); - if (! $app->isInstalled()) { - return $this->getInstallerMiddleware($pipe, $app); - } elseif ($app->isDownForMaintenance()) { - return $this->getMaintenanceMiddleware($pipe); - } elseif (! $app->isUpToDate()) { - return $this->getUpdaterMiddleware($pipe, $app); + if (! $this->app->isInstalled()) { + return $this->getInstallerMiddleware($pipe); } - $forum = parse_url($app->url(''), PHP_URL_PATH) ?: '/'; - $admin = parse_url($app->url('admin'), PHP_URL_PATH); - $api = parse_url($app->url('api'), PHP_URL_PATH); + if ($this->app->isDownForMaintenance()) { + return $this->getMaintenanceMiddleware($pipe); + } + + if (! $this->app->isUpToDate()) { + return $this->getUpdaterMiddleware($pipe); + } + + $api = parse_url($this->app->url('api'), PHP_URL_PATH); + $admin = parse_url($this->app->url('admin'), PHP_URL_PATH); + $forum = parse_url($this->app->url(''), PHP_URL_PATH) ?: '/'; if ($this->pathStartsWith($requestPath, $api)) { - $pipe->pipe($api, $app->make('flarum.api.middleware')); + $pipe->pipe($api, $this->app->make('flarum.api.middleware')); } elseif ($this->pathStartsWith($requestPath, $admin)) { - $pipe->pipe($admin, $app->make('flarum.admin.middleware')); + $pipe->pipe($admin, $this->app->make('flarum.admin.middleware')); } else { - $pipe->pipe($forum, $app->make('flarum.forum.middleware')); + $pipe->pipe($forum, $this->app->make('flarum.forum.middleware')); } return $pipe; @@ -100,14 +115,14 @@ class Server extends AbstractServer return $path === $prefix || starts_with($path, "$prefix/"); } - protected function getInstallerMiddleware(MiddlewarePipe $pipe, Application $app) + protected function getInstallerMiddleware(MiddlewarePipe $pipe) { - $app->register(InstallServiceProvider::class); + $this->app->register(InstallServiceProvider::class); - $pipe->pipe(new HandleErrors($this->getErrorDir(), $app->make('log'), true)); + $pipe->pipe(new HandleErrors($this->getErrorDir(), $this->app->make('log'), true)); - $pipe->pipe($app->make(StartSession::class)); - $pipe->pipe($app->make(DispatchRoute::class, ['routes' => $app->make('flarum.install.routes')])); + $pipe->pipe($this->app->make(StartSession::class)); + $pipe->pipe($this->app->make(DispatchRoute::class, ['routes' => $this->app->make('flarum.install.routes')])); return $pipe; } @@ -123,11 +138,11 @@ class Server extends AbstractServer return $pipe; } - protected function getUpdaterMiddleware(MiddlewarePipe $pipe, Application $app) + protected function getUpdaterMiddleware(MiddlewarePipe $pipe) { - $app->register(UpdateServiceProvider::class); + $this->app->register(UpdateServiceProvider::class); - $pipe->pipe($app->make(DispatchRoute::class, ['routes' => $app->make('flarum.update.routes')])); + $pipe->pipe($this->app->make(DispatchRoute::class, ['routes' => $this->app->make('flarum.update.routes')])); // TODO: FOR API render JSON-API error document for HTTP 503 @@ -147,13 +162,13 @@ class Server extends AbstractServer } } - private function getErrorDir() - { - return __DIR__.'/../../error'; - } - private function hitsLottery() { return mt_rand(1, 100) <= 2; } + + private function getErrorDir() + { + return __DIR__.'/../../error'; + } } From 4aad7c1040681faf60c3c073afb9a2a9b00b1d86 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Sun, 2 Jul 2017 13:29:30 +0200 Subject: [PATCH 44/86] Cleanup code, typehints and class references --- src/Api/ApiKey.php | 8 ++-- src/Database/Migrator.php | 2 +- .../Command/StartDiscussionHandler.php | 1 + src/Discussion/DiscussionServiceProvider.php | 6 +-- src/Discussion/Search/DiscussionSearcher.php | 10 +++-- src/Discussion/UserState.php | 5 ++- src/Event/AbstractConfigureRoutes.php | 11 +---- src/Event/ConfigureForumRoutes.php | 4 +- src/Extension/DefaultLanguagePackGuard.php | 8 ++-- src/Formatter/FormatterServiceProvider.php | 2 +- src/Forum/Controller/DiscussionController.php | 2 +- src/Forum/Controller/RegisterController.php | 3 +- src/Frontend/Event/Rendering.php | 8 ++-- src/Group/Group.php | 9 ++-- src/Group/GroupServiceProvider.php | 2 +- src/Group/Permission.php | 2 +- src/Install/Console/InstallCommand.php | 45 ++++++++++++------- src/Install/Controller/IndexController.php | 2 +- src/Install/InstallServiceProvider.php | 3 +- src/Locale/LocaleServiceProvider.php | 10 +++-- .../Blueprint/DiscussionRenamedBlueprint.php | 3 +- src/Notification/Notification.php | 5 ++- .../NotificationServiceProvider.php | 5 ++- 23 files changed, 87 insertions(+), 69 deletions(-) diff --git a/src/Api/ApiKey.php b/src/Api/ApiKey.php index e6415df2b..baae2c01e 100644 --- a/src/Api/ApiKey.php +++ b/src/Api/ApiKey.php @@ -37,10 +37,8 @@ class ApiKey extends AbstractModel */ public static function generate() { - $key = new static; - - $key->id = str_random(40); - - return $key; + return new static([ + 'id' => str_random(40) + ]); } } diff --git a/src/Database/Migrator.php b/src/Database/Migrator.php index 15477df4c..926d994c6 100755 --- a/src/Database/Migrator.php +++ b/src/Database/Migrator.php @@ -299,7 +299,7 @@ class Migrator /** * Get the migration repository instance. * - * @return \Illuminate\Database\Migrations\MigrationRepositoryInterface + * @return MigrationRepositoryInterface */ public function getRepository() { diff --git a/src/Discussion/Command/StartDiscussionHandler.php b/src/Discussion/Command/StartDiscussionHandler.php index 01f99b832..c7399210a 100644 --- a/src/Discussion/Command/StartDiscussionHandler.php +++ b/src/Discussion/Command/StartDiscussionHandler.php @@ -16,6 +16,7 @@ use Flarum\Discussion\Discussion; use Flarum\Discussion\DiscussionValidator; use Flarum\Discussion\Event\Saving; use Flarum\Foundation\DispatchEventsTrait; +use Flarum\Post\Command\PostReply; use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher; use Illuminate\Contracts\Events\Dispatcher as EventDispatcher; diff --git a/src/Discussion/DiscussionServiceProvider.php b/src/Discussion/DiscussionServiceProvider.php index 5f8ca4216..e1c0c466a 100644 --- a/src/Discussion/DiscussionServiceProvider.php +++ b/src/Discussion/DiscussionServiceProvider.php @@ -22,8 +22,8 @@ class DiscussionServiceProvider extends AbstractServiceProvider { $events = $this->app->make('events'); - $events->subscribe('Flarum\Discussion\DiscussionMetadataUpdater'); - $events->subscribe('Flarum\Discussion\DiscussionPolicy'); - $events->subscribe('Flarum\Discussion\DiscussionRenamedLogger'); + $events->subscribe(DiscussionMetadataUpdater::class); + $events->subscribe(DiscussionPolicy::class); + $events->subscribe(DiscussionRenamedLogger::class); } } diff --git a/src/Discussion/Search/DiscussionSearcher.php b/src/Discussion/Search/DiscussionSearcher.php index 5628dcf2f..c3b5fdb59 100644 --- a/src/Discussion/Search/DiscussionSearcher.php +++ b/src/Discussion/Search/DiscussionSearcher.php @@ -17,6 +17,8 @@ use Flarum\Discussion\Event\Searching; use Flarum\Post\PostRepository; use Flarum\Search\ApplySearchParametersTrait; use Flarum\Search\GambitManager; +use Flarum\Search\SearchCriteria; +use Flarum\Search\SearchResults; use Illuminate\Database\Eloquent\Collection; /** @@ -58,13 +60,13 @@ class DiscussionSearcher } /** - * @param \Flarum\Search\SearchCriteria $criteria + * @param SearchCriteria $criteria * @param int|null $limit * @param int $offset * @param array $load An array of relationships to load on the results. - * @return \Flarum\Search\SearchResults + * @return SearchResults */ - public function search(\Flarum\Search\SearchCriteria $criteria, $limit = null, $offset = 0, array $load = []) + public function search(SearchCriteria $criteria, $limit = null, $offset = 0, array $load = []) { $actor = $criteria->actor; @@ -107,7 +109,7 @@ class DiscussionSearcher Discussion::setStateUser($actor); $discussions->load($load); - return new \Flarum\Search\SearchResults($discussions, $areMoreResults); + return new SearchResults($discussions, $areMoreResults); } /** diff --git a/src/Discussion/UserState.php b/src/Discussion/UserState.php index 481893f91..a8df0651c 100644 --- a/src/Discussion/UserState.php +++ b/src/Discussion/UserState.php @@ -14,6 +14,7 @@ namespace Flarum\Discussion; use Flarum\Database\AbstractModel; use Flarum\Discussion\Event\UserRead; use Flarum\Foundation\EventGeneratorTrait; +use Flarum\User\User; use Illuminate\Database\Eloquent\Builder; /** @@ -70,7 +71,7 @@ class UserState extends AbstractModel */ public function discussion() { - return $this->belongsTo('Flarum\Discussion\Discussion', 'discussion_id'); + return $this->belongsTo(Discussion::class, 'discussion_id'); } /** @@ -80,7 +81,7 @@ class UserState extends AbstractModel */ public function user() { - return $this->belongsTo('Flarum\User\User', 'user_id'); + return $this->belongsTo(User::class, 'user_id'); } /** diff --git a/src/Event/AbstractConfigureRoutes.php b/src/Event/AbstractConfigureRoutes.php index c09ab958c..3ce06cf61 100644 --- a/src/Event/AbstractConfigureRoutes.php +++ b/src/Event/AbstractConfigureRoutes.php @@ -84,15 +84,6 @@ abstract class AbstractConfigureRoutes */ protected function route($method, $url, $name, $controller) { - $this->routes->$method($url, $name, $this->toController($controller)); - } - - /** - * @param string $controller - * @return callable - */ - protected function toController($controller) - { - return $this->route->toController($controller); + $this->routes->$method($url, $name, $this->route->toController($controller)); } } diff --git a/src/Event/ConfigureForumRoutes.php b/src/Event/ConfigureForumRoutes.php index d2beb7e0e..934f27a48 100644 --- a/src/Event/ConfigureForumRoutes.php +++ b/src/Event/ConfigureForumRoutes.php @@ -11,6 +11,8 @@ namespace Flarum\Event; +use Flarum\Forum\Controller\FrontendController; + /** * Configure forum routes. * @@ -21,7 +23,7 @@ class ConfigureForumRoutes extends AbstractConfigureRoutes /** * {@inheritdoc} */ - public function get($url, $name, $handler = 'Flarum\Forum\Controller\WebAppController') + public function get($url, $name, $handler = FrontendController::class) { parent::get($url, $name, $handler); } diff --git a/src/Extension/DefaultLanguagePackGuard.php b/src/Extension/DefaultLanguagePackGuard.php index 68afffd91..3ec124edc 100644 --- a/src/Extension/DefaultLanguagePackGuard.php +++ b/src/Extension/DefaultLanguagePackGuard.php @@ -11,7 +11,7 @@ namespace Flarum\Extension; -use Flarum\Event\ExtensionWillBeDisabled; +use Flarum\Extension\Event\Disabling; use Flarum\Http\Exception\ForbiddenException; use Illuminate\Contracts\Events\Dispatcher; @@ -22,14 +22,14 @@ class DefaultLanguagePackGuard */ public function subscribe(Dispatcher $events) { - $events->listen(ExtensionWillBeDisabled::class, [$this, 'whenExtensionWillBeDisabled']); + $events->listen(Disabling::class, [$this, 'whenExtensionWillBeDisabled']); } /** - * @param ExtensionWillBeDisabled $event + * @param Disabling $event * @throws ForbiddenException */ - public function whenExtensionWillBeDisabled(ExtensionWillBeDisabled $event) + public function whenExtensionWillBeDisabled(Disabling $event) { if (in_array('flarum-locale', $event->extension->extra)) { $default_locale = $this->app->make('flarum.settings')->get('default_locale'); diff --git a/src/Formatter/FormatterServiceProvider.php b/src/Formatter/FormatterServiceProvider.php index de07468dd..25de9fe55 100644 --- a/src/Formatter/FormatterServiceProvider.php +++ b/src/Formatter/FormatterServiceProvider.php @@ -41,7 +41,7 @@ class FormatterServiceProvider extends AbstractServiceProvider ); }); - $this->app->alias('flarum.formatter', 'Flarum\Formatter\Formatter'); + $this->app->alias('flarum.formatter', Formatter::class); } public function flushFormatter() diff --git a/src/Forum/Controller/DiscussionController.php b/src/Forum/Controller/DiscussionController.php index 216f72961..a71fc436c 100644 --- a/src/Forum/Controller/DiscussionController.php +++ b/src/Forum/Controller/DiscussionController.php @@ -22,7 +22,7 @@ use Psr\Http\Message\ServerRequestInterface as Request; class DiscussionController extends FrontendController { /** - * @var ApiClient + * @var Client */ protected $api; diff --git a/src/Forum/Controller/RegisterController.php b/src/Forum/Controller/RegisterController.php index 58f392f15..9a83610ea 100644 --- a/src/Forum/Controller/RegisterController.php +++ b/src/Forum/Controller/RegisterController.php @@ -12,6 +12,7 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; +use Flarum\Api\Controller\CreateUserController; use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Rememberer; use Flarum\Http\SessionAuthenticator; @@ -53,7 +54,7 @@ class RegisterController implements ControllerInterface */ public function handle(Request $request) { - $controller = 'Flarum\Api\Controller\CreateUserController'; + $controller = CreateUserController::class; $actor = $request->getAttribute('actor'); $body = ['data' => ['attributes' => $request->getParsedBody()]]; diff --git a/src/Frontend/Event/Rendering.php b/src/Frontend/Event/Rendering.php index 6219c557f..a5d81c949 100644 --- a/src/Frontend/Event/Rendering.php +++ b/src/Frontend/Event/Rendering.php @@ -11,8 +11,8 @@ namespace Flarum\Frontend\Event; -use Flarum\Admin\Controller\FrontendController as AdminWebAppController; -use Flarum\Forum\Controller\FrontendController as ForumWebAppController; +use Flarum\Admin\Controller\FrontendController as AdminFrontendController; +use Flarum\Forum\Controller\FrontendController as ForumFrontendController; use Flarum\Frontend\AbstractFrontendController; use Flarum\Frontend\FrontendView; use Psr\Http\Message\ServerRequestInterface; @@ -48,12 +48,12 @@ class Rendering public function isForum() { - return $this->controller instanceof ForumWebAppController; + return $this->controller instanceof ForumFrontendController; } public function isAdmin() { - return $this->controller instanceof AdminWebAppController; + return $this->controller instanceof AdminFrontendController; } public function addAssets($files) diff --git a/src/Group/Group.php b/src/Group/Group.php index 4af4a4d61..14daf1b69 100755 --- a/src/Group/Group.php +++ b/src/Group/Group.php @@ -15,8 +15,9 @@ use Flarum\Database\AbstractModel; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Group\Event\Created; -use Flarum\Group\Event\Deleting; +use Flarum\Group\Event\Deleted; use Flarum\Group\Event\Renamed; +use Flarum\User\User; /** * @property int $id @@ -67,7 +68,7 @@ class Group extends AbstractModel parent::boot(); static::deleted(function (Group $group) { - $group->raise(new Deleting($group)); + $group->raise(new Deleted($group)); $group->permissions()->delete(); }); @@ -120,7 +121,7 @@ class Group extends AbstractModel */ public function users() { - return $this->belongsToMany('Flarum\User\User', 'users_groups'); + return $this->belongsToMany(User::class, 'users_groups'); } /** @@ -130,6 +131,6 @@ class Group extends AbstractModel */ public function permissions() { - return $this->hasMany('Flarum\Group\Permission'); + return $this->hasMany(Permission::class); } } diff --git a/src/Group/GroupServiceProvider.php b/src/Group/GroupServiceProvider.php index bdf1ceb15..ad923df9f 100644 --- a/src/Group/GroupServiceProvider.php +++ b/src/Group/GroupServiceProvider.php @@ -21,6 +21,6 @@ class GroupServiceProvider extends AbstractServiceProvider public function boot() { $events = $this->app->make('events'); - $events->subscribe('Flarum\Group\GroupPolicy'); + $events->subscribe(GroupPolicy::class); } } diff --git a/src/Group/Permission.php b/src/Group/Permission.php index 0ed470e3b..110c365b0 100755 --- a/src/Group/Permission.php +++ b/src/Group/Permission.php @@ -31,7 +31,7 @@ class Permission extends AbstractModel */ public function group() { - return $this->belongsTo('Flarum\Group\Group', 'group_id'); + return $this->belongsTo(Group::class, 'group_id'); } /** diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index f7f9d3a98..1255e6216 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -14,14 +14,29 @@ namespace Flarum\Install\Console; use Exception; use Flarum\Console\AbstractCommand; use Flarum\Database\AbstractModel; +use Flarum\Database\Migrator; +use Flarum\Discussion\DiscussionServiceProvider; +use Flarum\Extension\ExtensionManager; +use Flarum\Formatter\FormatterServiceProvider; use Flarum\Group\Group; +use Flarum\Group\GroupServiceProvider; use Flarum\Group\Permission; +use Flarum\Install\Prerequisite\PrerequisiteInterface; +use Flarum\Notification\NotificationServiceProvider; +use Flarum\Post\PostServiceProvider; +use Flarum\Search\SearchServiceProvider; +use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\User; +use Flarum\User\UserServiceProvider; use Illuminate\Contracts\Foundation\Application; +use Illuminate\Database\ConnectionInterface; +use Illuminate\Database\ConnectionResolverInterface; +use Illuminate\Database\Schema\Builder; use Illuminate\Filesystem\Filesystem; use Illuminate\Validation\Factory; use PDO; use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Translation\TranslatorInterface; class InstallCommand extends AbstractCommand { @@ -163,7 +178,7 @@ class InstallCommand extends AbstractCommand $this->storeConfiguration(); - $resolver = $this->application->make('Illuminate\Database\ConnectionResolverInterface'); + $resolver = $this->application->make(ConnectionResolverInterface::class); AbstractModel::setConnectionResolver($resolver); AbstractModel::setEventDispatcher($this->application->make('events')); @@ -171,13 +186,13 @@ class InstallCommand extends AbstractCommand $this->writeSettings(); - $this->application->register('Flarum\Formatter\FormatterServiceProvider'); - $this->application->register('Flarum\Discussion\DiscussionServiceProvider'); - $this->application->register('Flarum\Group\GroupServiceProvider'); - $this->application->register('Flarum\Notification\NotificationServiceProvider'); - $this->application->register('Flarum\Search\SearchServiceProvider'); - $this->application->register('Flarum\Post\PostServiceProvider'); - $this->application->register('Flarum\User\UserServiceProvider'); + $this->application->register(FormatterServiceProvider::class); + $this->application->register(DiscussionServiceProvider::class); + $this->application->register(GroupServiceProvider::class); + $this->application->register(NotificationServiceProvider::class); + $this->application->register(SearchServiceProvider::class); + $this->application->register(PostServiceProvider::class); + $this->application->register(UserServiceProvider::class); $this->seedGroups(); $this->seedPermissions(); @@ -240,11 +255,11 @@ class InstallCommand extends AbstractCommand protected function runMigrations() { - $this->application->bind('Illuminate\Database\Schema\Builder', function ($container) { - return $container->make('Illuminate\Database\ConnectionInterface')->getSchemaBuilder(); + $this->application->bind(Builder::class, function ($container) { + return $container->make(ConnectionInterface::class)->getSchemaBuilder(); }); - $migrator = $this->application->make('Flarum\Database\Migrator'); + $migrator = $this->application->make(Migrator::class); $migrator->getRepository()->createRepository(); $migrator->run(__DIR__.'/../../../migrations'); @@ -256,7 +271,7 @@ class InstallCommand extends AbstractCommand protected function writeSettings() { - $settings = $this->application->make('Flarum\Settings\SettingsRepositoryInterface'); + $settings = $this->application->make(SettingsRepositoryInterface::class); $this->info('Writing default settings'); @@ -341,7 +356,7 @@ class InstallCommand extends AbstractCommand protected function enableBundledExtensions() { - $extensions = $this->application->make('Flarum\Extension\ExtensionManager'); + $extensions = $this->application->make(ExtensionManager::class); $migrator = $extensions->getMigrator(); @@ -386,7 +401,7 @@ class InstallCommand extends AbstractCommand */ protected function getPrerequisites() { - return $this->application->make('Flarum\Install\Prerequisite\PrerequisiteInterface'); + return $this->application->make(PrerequisiteInterface::class); } /** @@ -394,7 +409,7 @@ class InstallCommand extends AbstractCommand */ protected function getValidator() { - return new Factory($this->application->make('Symfony\Component\Translation\TranslatorInterface')); + return new Factory($this->application->make(TranslatorInterface::class)); } protected function showErrors($errors) diff --git a/src/Install/Controller/IndexController.php b/src/Install/Controller/IndexController.php index 680b647b0..e96110969 100644 --- a/src/Install/Controller/IndexController.php +++ b/src/Install/Controller/IndexController.php @@ -40,7 +40,7 @@ class IndexController extends AbstractHtmlController /** * @param Request $request - * @return \Psr\Http\Message\ResponseInterface + * @return \Illuminate\Contracts\Support\Renderable */ public function render(Request $request) { diff --git a/src/Install/InstallServiceProvider.php b/src/Install/InstallServiceProvider.php index 733a1ce9e..e57f47ab1 100644 --- a/src/Install/InstallServiceProvider.php +++ b/src/Install/InstallServiceProvider.php @@ -17,6 +17,7 @@ use Flarum\Http\RouteHandlerFactory; use Flarum\Install\Prerequisite\Composite; use Flarum\Install\Prerequisite\PhpExtensions; use Flarum\Install\Prerequisite\PhpVersion; +use Flarum\Install\Prerequisite\PrerequisiteInterface; use Flarum\Install\Prerequisite\WritablePaths; class InstallServiceProvider extends AbstractServiceProvider @@ -27,7 +28,7 @@ class InstallServiceProvider extends AbstractServiceProvider public function register() { $this->app->bind( - 'Flarum\Install\Prerequisite\PrerequisiteInterface', + PrerequisiteInterface::class, function () { return new Composite( new PhpVersion('5.5.0'), diff --git a/src/Locale/LocaleServiceProvider.php b/src/Locale/LocaleServiceProvider.php index 034e21a1c..4ddcc46f5 100644 --- a/src/Locale/LocaleServiceProvider.php +++ b/src/Locale/LocaleServiceProvider.php @@ -15,6 +15,8 @@ use Flarum\Event\ConfigureLocales; use Flarum\Foundation\AbstractServiceProvider; use Illuminate\Contracts\Events\Dispatcher; use Symfony\Component\Translation\MessageSelector; +use Symfony\Component\Translation\Translator; +use Symfony\Component\Translation\TranslatorInterface; class LocaleServiceProvider extends AbstractServiceProvider { @@ -35,8 +37,8 @@ class LocaleServiceProvider extends AbstractServiceProvider */ public function register() { - $this->app->singleton('Flarum\Locale\LocaleManager'); - $this->app->alias('Flarum\Locale\LocaleManager', 'flarum.localeManager'); + $this->app->singleton(LocaleManager::class); + $this->app->alias(LocaleManager::class, 'flarum.localeManager'); $this->app->singleton('translator', function () { $defaultLocale = $this->getDefaultLocale(); @@ -47,8 +49,8 @@ class LocaleServiceProvider extends AbstractServiceProvider return $translator; }); - $this->app->alias('translator', 'Symfony\Component\Translation\Translator'); - $this->app->alias('translator', 'Symfony\Component\Translation\TranslatorInterface'); + $this->app->alias('translator', Translator::class); + $this->app->alias('translator', TranslatorInterface::class); } private function getDefaultLocale() diff --git a/src/Notification/Blueprint/DiscussionRenamedBlueprint.php b/src/Notification/Blueprint/DiscussionRenamedBlueprint.php index 996483c27..50d2e6146 100644 --- a/src/Notification/Blueprint/DiscussionRenamedBlueprint.php +++ b/src/Notification/Blueprint/DiscussionRenamedBlueprint.php @@ -11,6 +11,7 @@ namespace Flarum\Notification\Blueprint; +use Flarum\Discussion\Discussion; use Flarum\Post\DiscussionRenamedPost; class DiscussionRenamedBlueprint implements BlueprintInterface @@ -65,6 +66,6 @@ class DiscussionRenamedBlueprint implements BlueprintInterface */ public static function getSubjectModel() { - return 'Flarum\Discussion\Discussion'; + return Discussion::class; } } diff --git a/src/Notification/Notification.php b/src/Notification/Notification.php index 6a32fdd36..ad289ca08 100644 --- a/src/Notification/Notification.php +++ b/src/Notification/Notification.php @@ -12,6 +12,7 @@ namespace Flarum\Notification; use Flarum\Database\AbstractModel; +use Flarum\User\User; /** * Models a notification record in the database. @@ -113,7 +114,7 @@ class Notification extends AbstractModel */ public function user() { - return $this->belongsTo('Flarum\User\User', 'user_id'); + return $this->belongsTo(User::class, 'user_id'); } /** @@ -123,7 +124,7 @@ class Notification extends AbstractModel */ public function sender() { - return $this->belongsTo('Flarum\User\User', 'sender_id'); + return $this->belongsTo(User::class, 'sender_id'); } /** diff --git a/src/Notification/NotificationServiceProvider.php b/src/Notification/NotificationServiceProvider.php index 3edbffcaa..8771198a0 100644 --- a/src/Notification/NotificationServiceProvider.php +++ b/src/Notification/NotificationServiceProvider.php @@ -13,6 +13,7 @@ namespace Flarum\Notification; use Flarum\Event\ConfigureNotificationTypes; use Flarum\Foundation\AbstractServiceProvider; +use Flarum\Notification\Blueprint\DiscussionRenamedBlueprint; use Flarum\User\User; use ReflectionClass; @@ -32,7 +33,7 @@ class NotificationServiceProvider extends AbstractServiceProvider public function registerNotificationTypes() { $blueprints = [ - 'Flarum\Notification\Blueprint\DiscussionRenamedBlueprint' => ['alert'] + DiscussionRenamedBlueprint::class => ['alert'] ]; $this->app->make('events')->fire( @@ -51,7 +52,7 @@ class NotificationServiceProvider extends AbstractServiceProvider in_array('alert', $enabled) ); - if ((new ReflectionClass($blueprint))->implementsInterface('Flarum\Notification\MailableInterface')) { + if ((new ReflectionClass($blueprint))->implementsInterface(MailableInterface::class)) { User::addPreference( User::getNotificationPreferenceKey($type, 'email'), 'boolval', From 1215a1ef9b109bd3d9630c988b724fb8c32ee1db Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Mon, 3 Jul 2017 10:10:03 +0200 Subject: [PATCH 45/86] Use ::class constant instead of hardcoded strings --- src/Extension/ExtensionServiceProvider.php | 4 ++-- src/Settings/SettingsServiceProvider.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Extension/ExtensionServiceProvider.php b/src/Extension/ExtensionServiceProvider.php index a421b1865..77b88d3e5 100644 --- a/src/Extension/ExtensionServiceProvider.php +++ b/src/Extension/ExtensionServiceProvider.php @@ -20,7 +20,7 @@ class ExtensionServiceProvider extends AbstractServiceProvider */ public function register() { - $this->app->bind('flarum.extensions', 'Flarum\Extension\ExtensionManager'); + $this->app->bind('flarum.extensions', ExtensionManager::class); $bootstrappers = $this->app->make('flarum.extensions')->getEnabledBootstrappers(); @@ -38,6 +38,6 @@ class ExtensionServiceProvider extends AbstractServiceProvider { $events = $this->app->make('events'); - $events->subscribe('Flarum\Extension\DefaultLanguagePackGuard'); + $events->subscribe(DefaultLanguagePackGuard::class); } } diff --git a/src/Settings/SettingsServiceProvider.php b/src/Settings/SettingsServiceProvider.php index 1050e80ae..6955083ba 100644 --- a/src/Settings/SettingsServiceProvider.php +++ b/src/Settings/SettingsServiceProvider.php @@ -20,7 +20,7 @@ class SettingsServiceProvider extends AbstractServiceProvider */ public function register() { - $this->app->singleton('Flarum\Settings\SettingsRepositoryInterface', function () { + $this->app->singleton(SettingsRepositoryInterface::class, function () { return new MemoryCacheSettingsRepository( new DatabaseSettingsRepository( $this->app->make('Illuminate\Database\ConnectionInterface') @@ -28,6 +28,6 @@ class SettingsServiceProvider extends AbstractServiceProvider ); }); - $this->app->alias('Flarum\Settings\SettingsRepositoryInterface', 'flarum.settings'); + $this->app->alias(SettingsRepositoryInterface::class, 'flarum.settings'); } } From fddd134fa03e7f47d159acc1ac55940d8c582cc1 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Mon, 3 Jul 2017 10:15:09 +0200 Subject: [PATCH 46/86] Inject settings repository in event listener `$this->app` was not defined here anyway. Refs #1032. --- src/Extension/DefaultLanguagePackGuard.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Extension/DefaultLanguagePackGuard.php b/src/Extension/DefaultLanguagePackGuard.php index 3ec124edc..d8fd3dc8a 100644 --- a/src/Extension/DefaultLanguagePackGuard.php +++ b/src/Extension/DefaultLanguagePackGuard.php @@ -13,10 +13,21 @@ namespace Flarum\Extension; use Flarum\Extension\Event\Disabling; use Flarum\Http\Exception\ForbiddenException; +use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Events\Dispatcher; class DefaultLanguagePackGuard { + /** + * @var SettingsRepositoryInterface + */ + protected $settings; + + public function __construct(SettingsRepositoryInterface $settings) + { + $this->settings = $settings; + } + /** * @param Dispatcher $events */ @@ -32,9 +43,9 @@ class DefaultLanguagePackGuard public function whenExtensionWillBeDisabled(Disabling $event) { if (in_array('flarum-locale', $event->extension->extra)) { - $default_locale = $this->app->make('flarum.settings')->get('default_locale'); + $defaultLocale = $this->settings->get('default_locale'); $locale = array_get($event->extension->extra, 'flarum-locale.code'); - if ($locale === $default_locale) { + if ($locale === $defaultLocale) { throw new ForbiddenException('You cannot disable the default language pack!'); } } From 4f688fc9a25da9bfefe86b6cb418e2ca2a754519 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Tue, 3 Oct 2017 16:53:18 +0200 Subject: [PATCH 47/86] Change order of service provider registration Here, the order is relevant, because at this point, the application has already been booted. Hence, all boot() methods are called immediately, which might depend on other service providers' register() methods having run. In this case, the DiscussionServiceProvider depends on the Gate class being registered in the container by the UserServiceProvider. --- src/Install/Console/InstallCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index 1255e6216..6c628fcbd 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -186,13 +186,13 @@ class InstallCommand extends AbstractCommand $this->writeSettings(); + $this->application->register(UserServiceProvider::class); $this->application->register(FormatterServiceProvider::class); $this->application->register(DiscussionServiceProvider::class); $this->application->register(GroupServiceProvider::class); $this->application->register(NotificationServiceProvider::class); $this->application->register(SearchServiceProvider::class); $this->application->register(PostServiceProvider::class); - $this->application->register(UserServiceProvider::class); $this->seedGroups(); $this->seedPermissions(); From 20373718861a2ef829e8b32eac5e6092440f7b11 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Thu, 5 Oct 2017 13:39:41 +0200 Subject: [PATCH 48/86] lists > pluck --- composer.json | 38 +++++++++---------- src/Api/Controller/CreatePostController.php | 2 +- src/Api/Controller/ListPostsController.php | 2 +- .../Controller/ShowDiscussionController.php | 2 +- .../Controller/UpdateDiscussionController.php | 2 +- src/Database/DatabaseMigrationRepository.php | 2 +- src/Discussion/DiscussionRepository.php | 2 +- .../Search/Fulltext/MySqlFulltextDriver.php | 2 +- src/Notification/NotificationSyncer.php | 2 +- src/Post/PostRepository.php | 4 +- src/Settings/DatabaseSettingsRepository.php | 2 +- src/User/User.php | 4 +- src/User/UserRepository.php | 2 +- 13 files changed, 33 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index efdb49182..ffe0a7205 100644 --- a/composer.json +++ b/composer.json @@ -20,24 +20,24 @@ "docs": "http://flarum.org/docs" }, "require": { - "php": ">=5.6.0", + "php": ">=7.0", "dflydev/fig-cookies": "^1.0.2", "doctrine/dbal": "^2.5", "components/font-awesome": "^4.6", "franzl/whoops-middleware": "^0.4.0", - "illuminate/bus": "5.1.*", - "illuminate/cache": "5.1.*", - "illuminate/config": "5.1.*", - "illuminate/container": "5.1.*", - "illuminate/contracts": "5.1.*", - "illuminate/database": "^5.1.31", - "illuminate/events": "5.1.*", - "illuminate/filesystem": "5.1.*", - "illuminate/hashing": "5.1.*", - "illuminate/mail": "5.1.*", - "illuminate/support": "5.1.*", - "illuminate/validation": "5.1.*", - "illuminate/view": "5.1.*", + "illuminate/bus": "5.5.*", + "illuminate/cache": "5.5.*", + "illuminate/config": "5.5.*", + "illuminate/container": "5.5.*", + "illuminate/contracts": "5.5.*", + "illuminate/database": "5.5.*", + "illuminate/events": "5.5.*", + "illuminate/filesystem": "5.5.*", + "illuminate/hashing": "5.5.*", + "illuminate/mail": "5.5.*", + "illuminate/support": "5.5.*", + "illuminate/validation": "5.5.*", + "illuminate/view": "5.5.*", "intervention/image": "^2.3.0", "league/flysystem": "^1.0.11", "league/oauth2-client": "~1.0", @@ -46,10 +46,10 @@ "nikic/fast-route": "^0.6", "oyejorge/less.php": "~1.5", "psr/http-message": "^1.0", - "symfony/console": "^2.7", - "symfony/http-foundation": "^2.7", - "symfony/translation": "^2.7", - "symfony/yaml": "^2.7", + "symfony/console": "^3.3", + "symfony/http-foundation": "^3.3", + "symfony/translation": "^3.3", + "symfony/yaml": "^3.3", "s9e/text-formatter": "^0.8.1", "tobscure/json-api": "^0.3.0", "zendframework/zend-diactoros": "^1.1", @@ -57,7 +57,7 @@ }, "require-dev": { "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.8" + "phpunit/phpunit": "^6.0" }, "autoload": { "psr-4": { diff --git a/src/Api/Controller/CreatePostController.php b/src/Api/Controller/CreatePostController.php index fc7432530..1d7e9f5c2 100644 --- a/src/Api/Controller/CreatePostController.php +++ b/src/Api/Controller/CreatePostController.php @@ -83,7 +83,7 @@ class CreatePostController extends AbstractCreateController } $discussion = $post->discussion; - $discussion->posts = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id'); + $discussion->posts = $discussion->postsVisibleTo($actor)->orderBy('time')->pluck('id'); return $post; } diff --git a/src/Api/Controller/ListPostsController.php b/src/Api/Controller/ListPostsController.php index b506f814a..5c732bc6f 100644 --- a/src/Api/Controller/ListPostsController.php +++ b/src/Api/Controller/ListPostsController.php @@ -122,7 +122,7 @@ class ListPostsController extends AbstractListController $query->orderBy($field, $order); } - return $query->lists('id')->all(); + return $query->pluck('id')->all(); } /** diff --git a/src/Api/Controller/ShowDiscussionController.php b/src/Api/Controller/ShowDiscussionController.php index 4ee73d225..8cd8a2a06 100644 --- a/src/Api/Controller/ShowDiscussionController.php +++ b/src/Api/Controller/ShowDiscussionController.php @@ -117,7 +117,7 @@ class ShowDiscussionController extends AbstractShowController */ private function loadPostIds(Discussion $discussion, User $actor) { - return $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id')->all(); + return $discussion->postsVisibleTo($actor)->orderBy('time')->pluck('id')->all(); } /** diff --git a/src/Api/Controller/UpdateDiscussionController.php b/src/Api/Controller/UpdateDiscussionController.php index 4cdd3a0a1..3fa1900f3 100644 --- a/src/Api/Controller/UpdateDiscussionController.php +++ b/src/Api/Controller/UpdateDiscussionController.php @@ -63,7 +63,7 @@ class UpdateDiscussionController extends AbstractShowController if ($posts = $discussion->getModifiedPosts()) { $posts = (new Collection($posts))->load('discussion', 'user'); - $discussionPosts = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id')->all(); + $discussionPosts = $discussion->postsVisibleTo($actor)->orderBy('time')->pluck('id')->all(); foreach ($discussionPosts as &$id) { foreach ($posts as $post) { diff --git a/src/Database/DatabaseMigrationRepository.php b/src/Database/DatabaseMigrationRepository.php index 49a1978e4..fdce0f00e 100755 --- a/src/Database/DatabaseMigrationRepository.php +++ b/src/Database/DatabaseMigrationRepository.php @@ -58,7 +58,7 @@ class DatabaseMigrationRepository implements MigrationRepositoryInterface return $this->table() ->where('extension', $extension) ->orderBy('migration', 'asc') - ->lists('migration'); + ->pluck('migration'); } /** diff --git a/src/Discussion/DiscussionRepository.php b/src/Discussion/DiscussionRepository.php index 11c64664a..b5dbcfcb4 100644 --- a/src/Discussion/DiscussionRepository.php +++ b/src/Discussion/DiscussionRepository.php @@ -53,7 +53,7 @@ class DiscussionRepository return Discussion::leftJoin('users_discussions', 'users_discussions.discussion_id', '=', 'discussions.id') ->where('user_id', $user->id) ->where('read_number', '>=', new Expression('last_post_number')) - ->lists('id') + ->pluck('id') ->all(); } diff --git a/src/Discussion/Search/Fulltext/MySqlFulltextDriver.php b/src/Discussion/Search/Fulltext/MySqlFulltextDriver.php index 0c1136297..f3e1a0be2 100644 --- a/src/Discussion/Search/Fulltext/MySqlFulltextDriver.php +++ b/src/Discussion/Search/Fulltext/MySqlFulltextDriver.php @@ -23,7 +23,7 @@ class MySqlFulltextDriver implements DriverInterface $discussionIds = Post::where('type', 'comment') ->whereRaw('MATCH (`content`) AGAINST (? IN BOOLEAN MODE)', [$string]) ->orderByRaw('MATCH (`content`) AGAINST (?) DESC', [$string]) - ->lists('discussion_id', 'id'); + ->pluck('discussion_id', 'id'); $relevantPostIds = []; diff --git a/src/Notification/NotificationSyncer.php b/src/Notification/NotificationSyncer.php index 7065c461d..5dc3a1843 100644 --- a/src/Notification/NotificationSyncer.php +++ b/src/Notification/NotificationSyncer.php @@ -106,7 +106,7 @@ class NotificationSyncer // removed from this collection by the above loop. Un-delete the // existing records that we want to keep. if (count($toDelete)) { - $this->setDeleted($toDelete->lists('id')->all(), true); + $this->setDeleted($toDelete->pluck('id')->all(), true); } if (count($toUndelete)) { diff --git a/src/Post/PostRepository.php b/src/Post/PostRepository.php index e6a38af03..06ba1db71 100644 --- a/src/Post/PostRepository.php +++ b/src/Post/PostRepository.php @@ -70,7 +70,7 @@ class PostRepository $query->orderBy($field, $order); } - $ids = $query->lists('id')->all(); + $ids = $query->pluck('id')->all(); return $this->findByIds($ids, $actor); } @@ -111,7 +111,7 @@ class PostRepository */ public function filterVisibleIds(array $ids, User $actor) { - return $this->queryIds($ids, $actor)->lists('id')->all(); + return $this->queryIds($ids, $actor)->pluck('id')->all(); } /** diff --git a/src/Settings/DatabaseSettingsRepository.php b/src/Settings/DatabaseSettingsRepository.php index 3179d23b9..943342d6b 100644 --- a/src/Settings/DatabaseSettingsRepository.php +++ b/src/Settings/DatabaseSettingsRepository.php @@ -24,7 +24,7 @@ class DatabaseSettingsRepository implements SettingsRepositoryInterface public function all() { - return $this->database->table('settings')->lists('value', 'key'); + return $this->database->table('settings')->pluck('value', 'key'); } public function get($key, $default = null) diff --git a/src/User/User.php b/src/User/User.php index 78858643e..e33c58493 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -650,7 +650,7 @@ class User extends AbstractModel // standard 'member' group, as well as any other groups they've been // assigned to. if ($this->is_activated) { - $groupIds = array_merge($groupIds, [Group::MEMBER_ID], $this->groups->lists('id')->all()); + $groupIds = array_merge($groupIds, [Group::MEMBER_ID], $this->groups->pluck('id')->all()); } event(new PrepareUserGroups($this, $groupIds)); @@ -665,7 +665,7 @@ class User extends AbstractModel */ public function getPermissions() { - return $this->permissions()->lists('permission')->all(); + return $this->permissions()->pluck('permission')->all(); } /** diff --git a/src/User/UserRepository.php b/src/User/UserRepository.php index bea76c55d..8619446b9 100644 --- a/src/User/UserRepository.php +++ b/src/User/UserRepository.php @@ -94,7 +94,7 @@ class UserRepository ->orderByRaw('username = ? desc', [$string]) ->orderByRaw('username like ? desc', [$string.'%']); - return $this->scopeVisibleTo($query, $actor)->lists('id'); + return $this->scopeVisibleTo($query, $actor)->pluck('id')->all(); } /** From 1c01145a14e48f1e68113b83f204ffbb55c9dd35 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Thu, 5 Oct 2017 13:57:31 +0200 Subject: [PATCH 49/86] fixed those exception handling tests --- .travis.yml | 5 ++++- .../IlluminateValidationExceptionHandler.php | 5 +++-- .../Handler/IlluminateValidationExceptionHandlerTest.php | 8 +++++--- tests/Test/TestCase.php | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2226ea1a2..4a684b9be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,14 @@ language: php php: - - 5.6 - 7.0 - 7.1 + - 7.2 - hhvm +services: + - mysql + matrix: allow_failures: - php: hhvm diff --git a/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php b/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php index ab5bfadcf..31bf030ca 100644 --- a/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php +++ b/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Api\ExceptionHandler; use Exception; -use Illuminate\Contracts\Validation\ValidationException; +use Illuminate\Validation\ValidationException; use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface; use Tobscure\JsonApi\Exception\Handler\ResponseBag; @@ -32,7 +32,8 @@ class IlluminateValidationExceptionHandler implements ExceptionHandlerInterface public function handle(Exception $e) { $status = 422; - $errors = $this->formatErrors($e->errors()->toArray()); + + $errors = $this->formatErrors($e->errors()); return new ResponseBag($status, $errors); } diff --git a/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php b/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php index 4960aba36..298cee7b2 100644 --- a/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php @@ -13,9 +13,11 @@ namespace Tests\Flarum\Api\Handler; use Exception; use Flarum\Api\ExceptionHandler\IlluminateValidationExceptionHandler; -use Illuminate\Contracts\Validation\ValidationException; +use Illuminate\Translation\{ + Translator, ArrayLoader +}; +use Illuminate\Validation\ValidationException; use Illuminate\Validation\Factory; -use Symfony\Component\Translation\Translator; use Tests\Test\TestCase; class IlluminateValidationExceptionHandlerTest extends TestCase @@ -54,7 +56,7 @@ class IlluminateValidationExceptionHandlerTest extends TestCase private function makeValidator($data = [], $rules = []) { - $translator = new Translator('en'); + $translator = new Translator(new ArrayLoader(), 'en'); $factory = new Factory($translator); return $factory->make($data, $rules); diff --git a/tests/Test/TestCase.php b/tests/Test/TestCase.php index 5a25ceb8b..864eb3b5d 100644 --- a/tests/Test/TestCase.php +++ b/tests/Test/TestCase.php @@ -12,9 +12,9 @@ namespace Tests\Test; use Mockery; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase as Test; -abstract class TestCase extends PHPUnit_Framework_TestCase +abstract class TestCase extends Test { public function setUp() { From 3f9dc818740ae4bd01fbab9b54461a336d17c1d6 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Thu, 5 Oct 2017 14:02:54 +0200 Subject: [PATCH 50/86] satisfying styleci, undo mysql in travis --- .travis.yml | 3 --- .../IlluminateValidationExceptionHandler.php | 2 +- .../Api/Handler/IlluminateValidationExceptionHandlerTest.php | 5 ++--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a684b9be..b217e0233 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,6 @@ php: - 7.2 - hhvm -services: - - mysql - matrix: allow_failures: - php: hhvm diff --git a/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php b/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php index 31bf030ca..afc496c1d 100644 --- a/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php +++ b/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php @@ -32,7 +32,7 @@ class IlluminateValidationExceptionHandler implements ExceptionHandlerInterface public function handle(Exception $e) { $status = 422; - + $errors = $this->formatErrors($e->errors()); return new ResponseBag($status, $errors); diff --git a/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php b/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php index 298cee7b2..fb2262624 100644 --- a/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php @@ -13,9 +13,8 @@ namespace Tests\Flarum\Api\Handler; use Exception; use Flarum\Api\ExceptionHandler\IlluminateValidationExceptionHandler; -use Illuminate\Translation\{ - Translator, ArrayLoader -}; +use Illuminate\Translation\ArrayLoader; +use Illuminate\Translation\Translator; use Illuminate\Validation\ValidationException; use Illuminate\Validation\Factory; use Tests\Test\TestCase; From a7f3ca4b22a8243160bee9a60935495a458a650e Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Thu, 5 Oct 2017 16:25:01 +0200 Subject: [PATCH 51/86] added new methods etc --- src/BusServiceProvider.php | 30 --------------- src/Database/DatabaseServiceProvider.php | 1 - src/Foundation/Application.php | 18 +++++++++ src/Foundation/Site.php | 2 - src/User/Gate.php | 47 ++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 33 deletions(-) delete mode 100644 src/BusServiceProvider.php diff --git a/src/BusServiceProvider.php b/src/BusServiceProvider.php deleted file mode 100644 index 4406460f6..000000000 --- a/src/BusServiceProvider.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -/* - * This file is part of Flarum. - * - * (c) Toby Zerner <toby.zerner@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum; - -use Flarum\Foundation\AbstractServiceProvider; - -/** - * @deprecated - */ -class BusServiceProvider extends AbstractServiceProvider -{ - /** - * {@inheritdoc} - */ - public function boot() - { - $this->app->make('Illuminate\Contracts\Bus\Dispatcher')->mapUsing(function ($command) { - return get_class($command).'Handler@handle'; - }); - } -} diff --git a/src/Database/DatabaseServiceProvider.php b/src/Database/DatabaseServiceProvider.php index c4b349074..e54fb3e8e 100644 --- a/src/Database/DatabaseServiceProvider.php +++ b/src/Database/DatabaseServiceProvider.php @@ -28,7 +28,6 @@ class DatabaseServiceProvider extends AbstractServiceProvider $connection = $factory->make($this->app->config('database')); $connection->setEventDispatcher($this->app->make('Illuminate\Contracts\Events\Dispatcher')); - $connection->setFetchMode(PDO::FETCH_CLASS); return $connection; }); diff --git a/src/Foundation/Application.php b/src/Foundation/Application.php index 85533ffd9..3e9a5c7df 100644 --- a/src/Foundation/Application.php +++ b/src/Foundation/Application.php @@ -737,4 +737,22 @@ class Application extends Container implements ApplicationContract $this->loadedProviders = []; } + + /** + * Get the path to the cached packages.php file. + * + * @return string + */ + public function getCachedPackagesPath() + { + return storage_path('app/cache/packages.php'); + } + + /** + * @return string + */ + public function resourcePath() + { + return storage_path('resources'); + } } diff --git a/src/Foundation/Site.php b/src/Foundation/Site.php index d59b6f056..cd1484dab 100644 --- a/src/Foundation/Site.php +++ b/src/Foundation/Site.php @@ -178,8 +178,6 @@ class Site $config->set('mail.username', $settings->get('mail_username')); $config->set('mail.password', $settings->get('mail_password')); - $app->register(\Flarum\BusServiceProvider::class); - $app->register(DiscussionServiceProvider::class); $app->register(FormatterServiceProvider::class); $app->register(GroupServiceProvider::class); diff --git a/src/User/Gate.php b/src/User/Gate.php index 9a9e91a27..7d9ac895c 100644 --- a/src/User/Gate.php +++ b/src/User/Gate.php @@ -353,4 +353,51 @@ class Gate implements GateContract { return call_user_func($this->userResolver); } + + /** + * Register a callback to run after all Gate checks. + * + * @param callable $callback + * @return GateContract + */ + public function after(callable $callback) + { + // TODO: Implement after() method. + } + + /** + * Determine if any one of the given abilities should be granted for the current user. + * + * @param iterable|string $abilities + * @param array|mixed $arguments + * @return bool + */ + public function any($abilities, $arguments = []) + { + // TODO: Implement any() method. + } + + /** + * Determine if the given ability should be granted for the current user. + * + * @param string $ability + * @param array|mixed $arguments + * @return \Illuminate\Auth\Access\Response + * + * @throws \Illuminate\Auth\Access\AuthorizationException + */ + public function authorize($ability, $arguments = []) + { + // TODO: Implement authorize() method. + } + + /** + * Get all of the defined abilities. + * + * @return array + */ + public function abilities() + { + // TODO: Implement abilities() method. + } } From 44e9007790bb354b86bf1a71a2f250e115da11b8 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Wed, 1 Nov 2017 13:22:16 +0100 Subject: [PATCH 52/86] using blade @json directive to parse raw json into frontend` --- views/app.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/app.blade.php b/views/app.blade.php index 2f98cb715..89e94ad36 100644 --- a/views/app.blade.php +++ b/views/app.blade.php @@ -49,7 +49,7 @@ if (module.default) module.default(app); } - app.boot({!! json_encode($payload) !!}); + app.boot(@json($payload)); @if (! $debug) } catch (e) { window.location += (window.location.search ? '&' : '?') + 'nojs=1'; From a8f8ca7f873fc29b5d6cb1bf9aed1f0bc9856b96 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Wed, 1 Nov 2017 17:01:50 +0100 Subject: [PATCH 53/86] fixed an issue where the mail provider would not be able to instantiate --- src/Settings/DatabaseSettingsRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Settings/DatabaseSettingsRepository.php b/src/Settings/DatabaseSettingsRepository.php index 943342d6b..d0700a8e5 100644 --- a/src/Settings/DatabaseSettingsRepository.php +++ b/src/Settings/DatabaseSettingsRepository.php @@ -24,7 +24,7 @@ class DatabaseSettingsRepository implements SettingsRepositoryInterface public function all() { - return $this->database->table('settings')->pluck('value', 'key'); + return $this->database->table('settings')->pluck('value', 'key')->all(); } public function get($key, $default = null) From 3eede757bbb448745a3621f890e8138d81a1b031 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Wed, 1 Nov 2017 17:07:22 +0100 Subject: [PATCH 54/86] fixed symfony translator now using catalogues --- src/Frontend/AbstractFrontend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Frontend/AbstractFrontend.php b/src/Frontend/AbstractFrontend.php index af4fc954e..8b112a0e7 100644 --- a/src/Frontend/AbstractFrontend.php +++ b/src/Frontend/AbstractFrontend.php @@ -158,7 +158,7 @@ abstract class AbstractFrontend */ private function addTranslations(FrontendView $view) { - $translations = array_get($this->locales->getTranslator()->getMessages(), 'messages', []); + $translations = array_get($this->locales->getTranslator()->getCatalogue()->all(), 'messages', []); $translations = $this->filterTranslations($translations); From d7306dedb74208a7544aa9eb4baa73312cb77b43 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Wed, 1 Nov 2017 17:20:12 +0100 Subject: [PATCH 55/86] array_build => array_map --- src/User/User.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/User/User.php b/src/User/User.php index e33c58493..cde9e256f 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -484,9 +484,9 @@ class User extends AbstractModel */ public function getPreferencesAttribute($value) { - $defaults = array_build(static::$preferences, function ($key, $value) { - return [$key, $value['default']]; - }); + $defaults = array_map(function ($value) { + return $value['default']; + }, static::$preferences); $user = array_only((array) json_decode($value, true), array_keys(static::$preferences)); From 55b763a5709e95544dc63fab5aafb009230ad85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= <daniel@klabbers.email> Date: Wed, 1 Nov 2017 22:12:56 +0100 Subject: [PATCH 56/86] fixed renamed interface for Scope --- src/Post/RegisteredTypesScope.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Post/RegisteredTypesScope.php b/src/Post/RegisteredTypesScope.php index e18945259..51c04018a 100644 --- a/src/Post/RegisteredTypesScope.php +++ b/src/Post/RegisteredTypesScope.php @@ -13,9 +13,9 @@ namespace Flarum\Post; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\ScopeInterface; +use Illuminate\Database\Eloquent\Scope; -class RegisteredTypesScope implements ScopeInterface +class RegisteredTypesScope implements Scope { /** * The index at which we added a where clause. From 72c232d5a388479eaf712939ffeeb19bec848a19 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Thu, 2 Nov 2017 10:48:33 +0100 Subject: [PATCH 57/86] fixed the Bus command Handling forwarding the call to a matching Handler class --- src/Bus/BusServiceProvider.php | 28 ++++++++++++++++++++++++++++ src/Bus/Dispatcher.php | 19 +++++++++++++++++++ src/Foundation/Site.php | 3 +++ src/Locale/LocaleServiceProvider.php | 8 +++++--- 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 src/Bus/BusServiceProvider.php create mode 100644 src/Bus/Dispatcher.php diff --git a/src/Bus/BusServiceProvider.php b/src/Bus/BusServiceProvider.php new file mode 100644 index 000000000..d6d152839 --- /dev/null +++ b/src/Bus/BusServiceProvider.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Bus; + +use Flarum\Foundation\AbstractServiceProvider; +use Illuminate\Contracts\Bus\Dispatcher as BusContract; +use Illuminate\Contracts\Queue\Factory as QueueFactoryContract; + +class BusServiceProvider extends AbstractServiceProvider +{ + public function boot() + { + $this->app->bind(BusContract::class, function ($app) { + return new Dispatcher($app, function ($connection = null) use ($app) { + return $app[QueueFactoryContract::class]->connection($connection); + }); + }); + } +} diff --git a/src/Bus/Dispatcher.php b/src/Bus/Dispatcher.php new file mode 100644 index 000000000..13a3839ed --- /dev/null +++ b/src/Bus/Dispatcher.php @@ -0,0 +1,19 @@ +<?php + +namespace Flarum\Bus; + +use Illuminate\Bus\Dispatcher as BaseDispatcher; + +class Dispatcher extends BaseDispatcher +{ + public function getCommandHandler($command) + { + $handler = get_class($command) . 'Handler'; + + if (class_exists($handler)) { + return $this->container->make($handler); + } + + return parent::getCommandHandler($command); + } +} diff --git a/src/Foundation/Site.php b/src/Foundation/Site.php index cd1484dab..904e403de 100644 --- a/src/Foundation/Site.php +++ b/src/Foundation/Site.php @@ -13,6 +13,7 @@ namespace Flarum\Foundation; use Flarum\Admin\AdminServiceProvider; use Flarum\Api\ApiServiceProvider; +use Flarum\Bus\BusServiceProvider as BusProvider; use Flarum\Database\DatabaseServiceProvider; use Flarum\Database\MigrationServiceProvider; use Flarum\Discussion\DiscussionServiceProvider; @@ -166,6 +167,8 @@ class Site $app->register(ViewServiceProvider::class); $app->register(ValidationServiceProvider::class); + $app->register(BusProvider::class); + if ($app->isInstalled() && $app->isUpToDate()) { $settings = $app->make(SettingsRepositoryInterface::class); diff --git a/src/Locale/LocaleServiceProvider.php b/src/Locale/LocaleServiceProvider.php index 4ddcc46f5..05484575b 100644 --- a/src/Locale/LocaleServiceProvider.php +++ b/src/Locale/LocaleServiceProvider.php @@ -14,9 +14,11 @@ namespace Flarum\Locale; use Flarum\Event\ConfigureLocales; use Flarum\Foundation\AbstractServiceProvider; use Illuminate\Contracts\Events\Dispatcher; -use Symfony\Component\Translation\MessageSelector; -use Symfony\Component\Translation\Translator; -use Symfony\Component\Translation\TranslatorInterface; +use Illuminate\Translation\Translator; +use Illuminate\Translation\FileLoader; +//use Symfony\Component\Translation\MessageSelector; +//use Symfony\Component\Translation\Translator; +//use Symfony\Component\Translation\TranslatorInterface; class LocaleServiceProvider extends AbstractServiceProvider { From 0b1043c9d2aeb76c27785ecf105a616be0f68374 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Thu, 2 Nov 2017 10:52:52 +0100 Subject: [PATCH 58/86] moved from boot to register --- src/Bus/BusServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bus/BusServiceProvider.php b/src/Bus/BusServiceProvider.php index d6d152839..c07b9b812 100644 --- a/src/Bus/BusServiceProvider.php +++ b/src/Bus/BusServiceProvider.php @@ -17,7 +17,7 @@ use Illuminate\Contracts\Queue\Factory as QueueFactoryContract; class BusServiceProvider extends AbstractServiceProvider { - public function boot() + public function register() { $this->app->bind(BusContract::class, function ($app) { return new Dispatcher($app, function ($connection = null) use ($app) { From e2d61d1aebdce38ddb1b882d0571445dd8a072fa Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Mon, 27 Nov 2017 09:49:19 +0100 Subject: [PATCH 59/86] applied laravel contract --- src/Locale/LocaleServiceProvider.php | 10 +++++----- src/Locale/Translator.php | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Locale/LocaleServiceProvider.php b/src/Locale/LocaleServiceProvider.php index 05484575b..76a7081ab 100644 --- a/src/Locale/LocaleServiceProvider.php +++ b/src/Locale/LocaleServiceProvider.php @@ -14,11 +14,10 @@ namespace Flarum\Locale; use Flarum\Event\ConfigureLocales; use Flarum\Foundation\AbstractServiceProvider; use Illuminate\Contracts\Events\Dispatcher; -use Illuminate\Translation\Translator; -use Illuminate\Translation\FileLoader; -//use Symfony\Component\Translation\MessageSelector; -//use Symfony\Component\Translation\Translator; -//use Symfony\Component\Translation\TranslatorInterface; +use Illuminate\Contracts\Translation\Translator as TranslatorContract; +use Symfony\Component\Translation\MessageSelector; +use Symfony\Component\Translation\Translator; +use Symfony\Component\Translation\TranslatorInterface; class LocaleServiceProvider extends AbstractServiceProvider { @@ -53,6 +52,7 @@ class LocaleServiceProvider extends AbstractServiceProvider }); $this->app->alias('translator', Translator::class); $this->app->alias('translator', TranslatorInterface::class); + $this->app->alias('translator', TranslatorContract::class); } private function getDefaultLocale() diff --git a/src/Locale/Translator.php b/src/Locale/Translator.php index 0e68b8280..b80ba7966 100644 --- a/src/Locale/Translator.php +++ b/src/Locale/Translator.php @@ -13,8 +13,9 @@ namespace Flarum\Locale; use Symfony\Component\Translation\MessageCatalogueInterface; use Symfony\Component\Translation\Translator as BaseTranslator; +use Illuminate\Contracts\Translation\Translator as TranslatorContract; -class Translator extends BaseTranslator +class Translator extends BaseTranslator implements TranslatorContract { const REFERENCE_REGEX = '/^=>\s*([a-z0-9_\-\.]+)$/i'; From 7b2663e0bc5b0b8f4db21be85a84224f69edea6f Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Mon, 27 Nov 2017 10:35:57 +0100 Subject: [PATCH 60/86] fixed alias/reference loading for translation strings --- src/Locale/LocaleManager.php | 9 +++++---- src/Locale/LocaleServiceProvider.php | 9 +++------ src/Locale/Translator.php | 1 - 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Locale/LocaleManager.php b/src/Locale/LocaleManager.php index 7be082085..837cd80ee 100644 --- a/src/Locale/LocaleManager.php +++ b/src/Locale/LocaleManager.php @@ -11,12 +11,13 @@ namespace Flarum\Locale; -use Symfony\Component\Translation\Translator as SymfonyTranslator; + +use Illuminate\Contracts\Translation\Translator; class LocaleManager { /** - * @var SymfonyTranslator + * @var Translator */ protected $translator; @@ -27,9 +28,9 @@ class LocaleManager protected $css = []; /** - * @param SymfonyTranslator $translator + * @param Translator $translator */ - public function __construct(SymfonyTranslator $translator) + public function __construct(Translator $translator) { $this->translator = $translator; } diff --git a/src/Locale/LocaleServiceProvider.php b/src/Locale/LocaleServiceProvider.php index 76a7081ab..ac179c52a 100644 --- a/src/Locale/LocaleServiceProvider.php +++ b/src/Locale/LocaleServiceProvider.php @@ -16,7 +16,6 @@ use Flarum\Foundation\AbstractServiceProvider; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Translation\Translator as TranslatorContract; use Symfony\Component\Translation\MessageSelector; -use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\TranslatorInterface; class LocaleServiceProvider extends AbstractServiceProvider @@ -42,10 +41,8 @@ class LocaleServiceProvider extends AbstractServiceProvider $this->app->alias(LocaleManager::class, 'flarum.localeManager'); $this->app->singleton('translator', function () { - $defaultLocale = $this->getDefaultLocale(); - - $translator = new Translator($defaultLocale, new MessageSelector()); - $translator->setFallbackLocales([$defaultLocale, 'en']); + $translator = new Translator($this->getDefaultLocale(), new MessageSelector()); + $translator->setFallbackLocales(['en']); $translator->addLoader('prefixed_yaml', new PrefixedYamlFileLoader()); return $translator; @@ -55,7 +52,7 @@ class LocaleServiceProvider extends AbstractServiceProvider $this->app->alias('translator', TranslatorContract::class); } - private function getDefaultLocale() + private function getDefaultLocale(): string { return $this->app->isInstalled() && $this->app->isUpToDate() ? $this->app->make('flarum.settings')->get('default_locale', 'en') diff --git a/src/Locale/Translator.php b/src/Locale/Translator.php index b80ba7966..4e3668a4b 100644 --- a/src/Locale/Translator.php +++ b/src/Locale/Translator.php @@ -29,7 +29,6 @@ class Translator extends BaseTranslator implements TranslatorContract } else { $this->assertValidLocale($locale); } - $parse = ! isset($this->catalogues[$locale]); $catalogue = parent::getCatalogue($locale); From 642332ffe2e184b8570ba989853b1e2bfa80b9ea Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Mon, 27 Nov 2017 10:42:16 +0100 Subject: [PATCH 61/86] replaced the Symfony\Component\Translation\TranslationInterface with the Illuminate\Contracts\Translation\Translator, deprecating the Symfony version --- src/Api/Controller/SendConfirmationEmailController.php | 8 ++++---- src/Api/Serializer/GroupSerializer.php | 8 ++++---- src/Forum/Controller/ResetPasswordController.php | 6 +++--- src/Foundation/AbstractValidator.php | 8 ++++---- src/Install/Console/InstallCommand.php | 4 ++-- src/Locale/LocaleServiceProvider.php | 2 -- src/User/Command/RequestPasswordResetHandler.php | 8 ++++---- src/User/EmailConfirmationMailer.php | 8 ++++---- 8 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/Api/Controller/SendConfirmationEmailController.php b/src/Api/Controller/SendConfirmationEmailController.php index 2935f0067..8140fa997 100644 --- a/src/Api/Controller/SendConfirmationEmailController.php +++ b/src/Api/Controller/SendConfirmationEmailController.php @@ -20,7 +20,7 @@ use Flarum\User\Exception\PermissionDeniedException; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Mail\Message; use Psr\Http\Message\ServerRequestInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Illuminate\Contracts\Translation\Translator; use Zend\Diactoros\Response\EmptyResponse; class SendConfirmationEmailController implements ControllerInterface @@ -43,7 +43,7 @@ class SendConfirmationEmailController implements ControllerInterface protected $url; /** - * @var TranslatorInterface + * @var Translator */ protected $translator; @@ -51,9 +51,9 @@ class SendConfirmationEmailController implements ControllerInterface * @param \Flarum\Settings\SettingsRepositoryInterface $settings * @param Mailer $mailer * @param UrlGenerator $url - * @param TranslatorInterface $translator + * @param Translator $translator */ - public function __construct(SettingsRepositoryInterface $settings, Mailer $mailer, UrlGenerator $url, TranslatorInterface $translator) + public function __construct(SettingsRepositoryInterface $settings, Mailer $mailer, UrlGenerator $url, Translator $translator) { $this->settings = $settings; $this->mailer = $mailer; diff --git a/src/Api/Serializer/GroupSerializer.php b/src/Api/Serializer/GroupSerializer.php index 7cd1eb989..820803223 100644 --- a/src/Api/Serializer/GroupSerializer.php +++ b/src/Api/Serializer/GroupSerializer.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Serializer; use Flarum\Group\Group; use InvalidArgumentException; -use Symfony\Component\Translation\TranslatorInterface; +use Illuminate\Contracts\Translation\Translator; class GroupSerializer extends AbstractSerializer { @@ -23,14 +23,14 @@ class GroupSerializer extends AbstractSerializer protected $type = 'groups'; /** - * @var TranslatorInterface + * @var Translator */ private $translator; /** - * @param TranslatorInterface $translator + * @param Translator $translator */ - public function __construct(TranslatorInterface $translator) + public function __construct(Translator $translator) { $this->translator = $translator; } diff --git a/src/Forum/Controller/ResetPasswordController.php b/src/Forum/Controller/ResetPasswordController.php index 641da9b42..4a737b497 100644 --- a/src/Forum/Controller/ResetPasswordController.php +++ b/src/Forum/Controller/ResetPasswordController.php @@ -17,7 +17,7 @@ use Flarum\User\Exception\InvalidConfirmationTokenException; use Flarum\User\PasswordToken; use Illuminate\Contracts\View\Factory; use Psr\Http\Message\ServerRequestInterface as Request; -use Symfony\Component\Translation\TranslatorInterface; +use Illuminate\Contracts\Translation\Translator; class ResetPasswordController extends AbstractHtmlController { @@ -27,14 +27,14 @@ class ResetPasswordController extends AbstractHtmlController protected $view; /** - * @var TranslatorInterface + * @var Translator */ protected $translator; /** * @param Factory $view */ - public function __construct(Factory $view, TranslatorInterface $translator) + public function __construct(Factory $view, Translator $translator) { $this->view = $view; $this->translator = $translator; diff --git a/src/Foundation/AbstractValidator.php b/src/Foundation/AbstractValidator.php index ee1062af5..4d1a1fd4e 100644 --- a/src/Foundation/AbstractValidator.php +++ b/src/Foundation/AbstractValidator.php @@ -15,7 +15,7 @@ use Flarum\Foundation\Event\Validating; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Validation\ValidationException; use Illuminate\Validation\Factory; -use Symfony\Component\Translation\TranslatorInterface; +use Illuminate\Contracts\Translation\Translator; abstract class AbstractValidator { @@ -35,16 +35,16 @@ abstract class AbstractValidator protected $events; /** - * @var TranslatorInterface + * @var Translator */ protected $translator; /** * @param Factory $validator * @param Dispatcher $events - * @param TranslatorInterface $translator + * @param Translator $translator */ - public function __construct(Factory $validator, Dispatcher $events, TranslatorInterface $translator) + public function __construct(Factory $validator, Dispatcher $events, Translator $translator) { $this->validator = $validator; $this->events = $events; diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index 6c628fcbd..de49c11f6 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -36,7 +36,7 @@ use Illuminate\Filesystem\Filesystem; use Illuminate\Validation\Factory; use PDO; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Translation\TranslatorInterface; +use Illuminate\Contracts\Translation\Translator; class InstallCommand extends AbstractCommand { @@ -409,7 +409,7 @@ class InstallCommand extends AbstractCommand */ protected function getValidator() { - return new Factory($this->application->make(TranslatorInterface::class)); + return new Factory($this->application->make(Translator::class)); } protected function showErrors($errors) diff --git a/src/Locale/LocaleServiceProvider.php b/src/Locale/LocaleServiceProvider.php index ac179c52a..35b52eef7 100644 --- a/src/Locale/LocaleServiceProvider.php +++ b/src/Locale/LocaleServiceProvider.php @@ -16,7 +16,6 @@ use Flarum\Foundation\AbstractServiceProvider; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Translation\Translator as TranslatorContract; use Symfony\Component\Translation\MessageSelector; -use Symfony\Component\Translation\TranslatorInterface; class LocaleServiceProvider extends AbstractServiceProvider { @@ -48,7 +47,6 @@ class LocaleServiceProvider extends AbstractServiceProvider return $translator; }); $this->app->alias('translator', Translator::class); - $this->app->alias('translator', TranslatorInterface::class); $this->app->alias('translator', TranslatorContract::class); } diff --git a/src/User/Command/RequestPasswordResetHandler.php b/src/User/Command/RequestPasswordResetHandler.php index c0ac0c7fd..fc03314d4 100644 --- a/src/User/Command/RequestPasswordResetHandler.php +++ b/src/User/Command/RequestPasswordResetHandler.php @@ -20,7 +20,7 @@ use Illuminate\Contracts\Validation\Factory; use Illuminate\Contracts\Validation\ValidationException; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Mail\Message; -use Symfony\Component\Translation\TranslatorInterface; +use Illuminate\Contracts\Translation\Translator; class RequestPasswordResetHandler { @@ -45,7 +45,7 @@ class RequestPasswordResetHandler protected $url; /** - * @var TranslatorInterface + * @var Translator */ protected $translator; @@ -59,7 +59,7 @@ class RequestPasswordResetHandler * @param SettingsRepositoryInterface $settings * @param Mailer $mailer * @param UrlGenerator $url - * @param TranslatorInterface $translator + * @param Translator $translator * @param Factory $validatorFactory */ public function __construct( @@ -67,7 +67,7 @@ class RequestPasswordResetHandler SettingsRepositoryInterface $settings, Mailer $mailer, UrlGenerator $url, - TranslatorInterface $translator, + Translator $translator, Factory $validatorFactory ) { $this->users = $users; diff --git a/src/User/EmailConfirmationMailer.php b/src/User/EmailConfirmationMailer.php index 3273690b1..59b892ad3 100755 --- a/src/User/EmailConfirmationMailer.php +++ b/src/User/EmailConfirmationMailer.php @@ -18,7 +18,7 @@ use Flarum\User\Event\Registered; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Mail\Message; -use Symfony\Component\Translation\TranslatorInterface; +use Illuminate\Contracts\Translation\Translator; class EmailConfirmationMailer { @@ -38,7 +38,7 @@ class EmailConfirmationMailer protected $url; /** - * @var TranslatorInterface + * @var Translator */ protected $translator; @@ -46,9 +46,9 @@ class EmailConfirmationMailer * @param \Flarum\Settings\SettingsRepositoryInterface $settings * @param Mailer $mailer * @param UrlGenerator $url - * @param TranslatorInterface $translator + * @param Translator $translator */ - public function __construct(SettingsRepositoryInterface $settings, Mailer $mailer, UrlGenerator $url, TranslatorInterface $translator) + public function __construct(SettingsRepositoryInterface $settings, Mailer $mailer, UrlGenerator $url, Translator $translator) { $this->settings = $settings; $this->mailer = $mailer; From 4d9e2335c712469809553f9972c4d4fb58744fa6 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Mon, 27 Nov 2017 11:05:15 +0100 Subject: [PATCH 62/86] pleasing the angry god Circle --- .../Controller/SendConfirmationEmailController.php | 2 +- src/Api/Serializer/GroupSerializer.php | 2 +- src/Bus/Dispatcher.php | 11 ++++++++++- src/Database/DatabaseServiceProvider.php | 1 - src/Forum/Controller/ResetPasswordController.php | 2 +- src/Foundation/AbstractValidator.php | 2 +- src/Install/Console/InstallCommand.php | 2 +- src/Locale/LocaleManager.php | 1 - src/Locale/Translator.php | 2 +- src/User/Command/RequestPasswordResetHandler.php | 2 +- src/User/EmailConfirmationMailer.php | 2 +- .../IlluminateValidationExceptionHandlerTest.php | 2 +- 12 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Api/Controller/SendConfirmationEmailController.php b/src/Api/Controller/SendConfirmationEmailController.php index 8140fa997..dd9e37afa 100644 --- a/src/Api/Controller/SendConfirmationEmailController.php +++ b/src/Api/Controller/SendConfirmationEmailController.php @@ -18,9 +18,9 @@ use Flarum\User\AssertPermissionTrait; use Flarum\User\EmailToken; use Flarum\User\Exception\PermissionDeniedException; use Illuminate\Contracts\Mail\Mailer; +use Illuminate\Contracts\Translation\Translator; use Illuminate\Mail\Message; use Psr\Http\Message\ServerRequestInterface; -use Illuminate\Contracts\Translation\Translator; use Zend\Diactoros\Response\EmptyResponse; class SendConfirmationEmailController implements ControllerInterface diff --git a/src/Api/Serializer/GroupSerializer.php b/src/Api/Serializer/GroupSerializer.php index 820803223..94bf6b80f 100644 --- a/src/Api/Serializer/GroupSerializer.php +++ b/src/Api/Serializer/GroupSerializer.php @@ -12,8 +12,8 @@ namespace Flarum\Api\Serializer; use Flarum\Group\Group; -use InvalidArgumentException; use Illuminate\Contracts\Translation\Translator; +use InvalidArgumentException; class GroupSerializer extends AbstractSerializer { diff --git a/src/Bus/Dispatcher.php b/src/Bus/Dispatcher.php index 13a3839ed..c0836d129 100644 --- a/src/Bus/Dispatcher.php +++ b/src/Bus/Dispatcher.php @@ -1,5 +1,14 @@ <?php +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Flarum\Bus; use Illuminate\Bus\Dispatcher as BaseDispatcher; @@ -8,7 +17,7 @@ class Dispatcher extends BaseDispatcher { public function getCommandHandler($command) { - $handler = get_class($command) . 'Handler'; + $handler = get_class($command).'Handler'; if (class_exists($handler)) { return $this->container->make($handler); diff --git a/src/Database/DatabaseServiceProvider.php b/src/Database/DatabaseServiceProvider.php index e54fb3e8e..8d3c08262 100644 --- a/src/Database/DatabaseServiceProvider.php +++ b/src/Database/DatabaseServiceProvider.php @@ -14,7 +14,6 @@ namespace Flarum\Database; use Flarum\Foundation\AbstractServiceProvider; use Illuminate\Database\ConnectionResolver; use Illuminate\Database\Connectors\ConnectionFactory; -use PDO; class DatabaseServiceProvider extends AbstractServiceProvider { diff --git a/src/Forum/Controller/ResetPasswordController.php b/src/Forum/Controller/ResetPasswordController.php index 4a737b497..0be98834d 100644 --- a/src/Forum/Controller/ResetPasswordController.php +++ b/src/Forum/Controller/ResetPasswordController.php @@ -15,9 +15,9 @@ use DateTime; use Flarum\Http\Controller\AbstractHtmlController; use Flarum\User\Exception\InvalidConfirmationTokenException; use Flarum\User\PasswordToken; +use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\View\Factory; use Psr\Http\Message\ServerRequestInterface as Request; -use Illuminate\Contracts\Translation\Translator; class ResetPasswordController extends AbstractHtmlController { diff --git a/src/Foundation/AbstractValidator.php b/src/Foundation/AbstractValidator.php index 4d1a1fd4e..90b3af47c 100644 --- a/src/Foundation/AbstractValidator.php +++ b/src/Foundation/AbstractValidator.php @@ -13,9 +13,9 @@ namespace Flarum\Foundation; use Flarum\Foundation\Event\Validating; use Illuminate\Contracts\Events\Dispatcher; +use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\Validation\ValidationException; use Illuminate\Validation\Factory; -use Illuminate\Contracts\Translation\Translator; abstract class AbstractValidator { diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index de49c11f6..61c473f72 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -29,6 +29,7 @@ use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\User; use Flarum\User\UserServiceProvider; use Illuminate\Contracts\Foundation\Application; +use Illuminate\Contracts\Translation\Translator; use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionResolverInterface; use Illuminate\Database\Schema\Builder; @@ -36,7 +37,6 @@ use Illuminate\Filesystem\Filesystem; use Illuminate\Validation\Factory; use PDO; use Symfony\Component\Console\Input\InputOption; -use Illuminate\Contracts\Translation\Translator; class InstallCommand extends AbstractCommand { diff --git a/src/Locale/LocaleManager.php b/src/Locale/LocaleManager.php index 837cd80ee..7bfa4b1eb 100644 --- a/src/Locale/LocaleManager.php +++ b/src/Locale/LocaleManager.php @@ -11,7 +11,6 @@ namespace Flarum\Locale; - use Illuminate\Contracts\Translation\Translator; class LocaleManager diff --git a/src/Locale/Translator.php b/src/Locale/Translator.php index 4e3668a4b..718a59e27 100644 --- a/src/Locale/Translator.php +++ b/src/Locale/Translator.php @@ -11,9 +11,9 @@ namespace Flarum\Locale; +use Illuminate\Contracts\Translation\Translator as TranslatorContract; use Symfony\Component\Translation\MessageCatalogueInterface; use Symfony\Component\Translation\Translator as BaseTranslator; -use Illuminate\Contracts\Translation\Translator as TranslatorContract; class Translator extends BaseTranslator implements TranslatorContract { diff --git a/src/User/Command/RequestPasswordResetHandler.php b/src/User/Command/RequestPasswordResetHandler.php index fc03314d4..e1bb365bc 100644 --- a/src/User/Command/RequestPasswordResetHandler.php +++ b/src/User/Command/RequestPasswordResetHandler.php @@ -16,11 +16,11 @@ use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\PasswordToken; use Flarum\User\UserRepository; use Illuminate\Contracts\Mail\Mailer; +use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\Validation\Factory; use Illuminate\Contracts\Validation\ValidationException; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Mail\Message; -use Illuminate\Contracts\Translation\Translator; class RequestPasswordResetHandler { diff --git a/src/User/EmailConfirmationMailer.php b/src/User/EmailConfirmationMailer.php index 59b892ad3..fdafc8718 100755 --- a/src/User/EmailConfirmationMailer.php +++ b/src/User/EmailConfirmationMailer.php @@ -17,8 +17,8 @@ use Flarum\User\Event\EmailChangeRequested; use Flarum\User\Event\Registered; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Mail\Mailer; -use Illuminate\Mail\Message; use Illuminate\Contracts\Translation\Translator; +use Illuminate\Mail\Message; class EmailConfirmationMailer { diff --git a/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php b/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php index fb2262624..fbdf16559 100644 --- a/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php @@ -15,8 +15,8 @@ use Exception; use Flarum\Api\ExceptionHandler\IlluminateValidationExceptionHandler; use Illuminate\Translation\ArrayLoader; use Illuminate\Translation\Translator; -use Illuminate\Validation\ValidationException; use Illuminate\Validation\Factory; +use Illuminate\Validation\ValidationException; use Tests\Test\TestCase; class IlluminateValidationExceptionHandlerTest extends TestCase From 55b945f129dc286b26846b6ac257d3dbccf2af2a Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Mon, 27 Nov 2017 14:03:45 +0100 Subject: [PATCH 63/86] Using Core Translator in Locale Manager, type hinted its methods and removed unnecessary phpdoc --- src/Locale/LocaleManager.php | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/Locale/LocaleManager.php b/src/Locale/LocaleManager.php index 7bfa4b1eb..5fdd4d492 100644 --- a/src/Locale/LocaleManager.php +++ b/src/Locale/LocaleManager.php @@ -11,8 +11,6 @@ namespace Flarum\Locale; -use Illuminate\Contracts\Translation\Translator; - class LocaleManager { /** @@ -26,52 +24,49 @@ class LocaleManager protected $css = []; - /** - * @param Translator $translator - */ public function __construct(Translator $translator) { $this->translator = $translator; } - public function getLocale() + public function getLocale(): string { return $this->translator->getLocale(); } - public function setLocale($locale) + public function setLocale(string $locale) { $this->translator->setLocale($locale); } - public function addLocale($locale, $name) + public function addLocale(string $locale, string $name) { $this->locales[$locale] = $name; } - public function getLocales() + public function getLocales(): array { return $this->locales; } - public function hasLocale($locale) + public function hasLocale(string $locale): bool { return isset($this->locales[$locale]); } - public function addTranslations($locale, $file, $module = null) + public function addTranslations(string $locale, $file, string $module = null) { $prefix = $module ? $module.'::' : ''; $this->translator->addResource('prefixed_yaml', compact('file', 'prefix'), $locale); } - public function addJsFile($locale, $js) + public function addJsFile(string $locale, string $js) { $this->js[$locale][] = $js; } - public function getJsFiles($locale) + public function getJsFiles(string $locale): array { $files = array_get($this->js, $locale, []); @@ -84,12 +79,12 @@ class LocaleManager return $files; } - public function addCssFile($locale, $css) + public function addCssFile(string $locale, string $css) { $this->css[$locale][] = $css; } - public function getCssFiles($locale) + public function getCssFiles(string $locale): array { $files = array_get($this->css, $locale, []); @@ -102,18 +97,12 @@ class LocaleManager return $files; } - /** - * @return SymfonyTranslator - */ - public function getTranslator() + public function getTranslator(): Translator { return $this->translator; } - /** - * @param SymfonyTranslator $translator - */ - public function setTranslator(SymfonyTranslator $translator) + public function setTranslator(Translator $translator) { $this->translator = $translator; } From ac0b4cb2d23c1164bfcfd3b96d20dfbd95a10c9f Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Mon, 27 Nov 2017 14:17:17 +0100 Subject: [PATCH 64/86] patched up the Scope implementation as requested --- src/Post/RegisteredTypesScope.php | 46 ------------------------------- 1 file changed, 46 deletions(-) diff --git a/src/Post/RegisteredTypesScope.php b/src/Post/RegisteredTypesScope.php index 51c04018a..8d27eb4f1 100644 --- a/src/Post/RegisteredTypesScope.php +++ b/src/Post/RegisteredTypesScope.php @@ -17,62 +17,16 @@ use Illuminate\Database\Eloquent\Scope; class RegisteredTypesScope implements Scope { - /** - * The index at which we added a where clause. - * - * @var int - */ - protected $whereIndex; - - /** - * The index at which we added where bindings. - * - * @var int - */ - protected $bindingIndex; - - /** - * The number of where bindings we added. - * - * @var int - */ - protected $bindingCount; - /** * Apply the scope to a given Eloquent query builder. * * @param Builder $builder * @param Model $post - * @return void */ public function apply(Builder $builder, Model $post) { $query = $builder->getQuery(); - - $this->whereIndex = count($query->wheres); - $this->bindingIndex = count($query->getRawBindings()['where']); - $types = array_keys($post::getModels()); - $this->bindingCount = count($types); $query->whereIn('type', $types); } - - /** - * Remove the scope from the given Eloquent query builder. - * - * @param Builder $builder - * @param Model $post - * @return void - */ - public function remove(Builder $builder, Model $post) - { - $query = $builder->getQuery(); - - unset($query->wheres[$this->whereIndex]); - $query->wheres = array_values($query->wheres); - - $whereBindings = $query->getRawBindings()['where']; - array_splice($whereBindings, $this->bindingIndex, $this->bindingCount); - $query->setBindings(array_values($whereBindings)); - } } From f4fc245df425f80eda60a9d573929d47e87452ad Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Mon, 27 Nov 2017 14:18:28 +0100 Subject: [PATCH 65/86] re-added a precious line --- src/Locale/Translator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Locale/Translator.php b/src/Locale/Translator.php index 718a59e27..d37f8c8c3 100644 --- a/src/Locale/Translator.php +++ b/src/Locale/Translator.php @@ -29,6 +29,7 @@ class Translator extends BaseTranslator implements TranslatorContract } else { $this->assertValidLocale($locale); } + $parse = ! isset($this->catalogues[$locale]); $catalogue = parent::getCatalogue($locale); From c01268d9ae0cdf0078565d110fe7587cbbc48e6f Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Mon, 27 Nov 2017 14:19:18 +0100 Subject: [PATCH 66/86] must be an empty line --- src/Locale/Translator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Locale/Translator.php b/src/Locale/Translator.php index d37f8c8c3..70acf299d 100644 --- a/src/Locale/Translator.php +++ b/src/Locale/Translator.php @@ -29,7 +29,7 @@ class Translator extends BaseTranslator implements TranslatorContract } else { $this->assertValidLocale($locale); } - + $parse = ! isset($this->catalogues[$locale]); $catalogue = parent::getCatalogue($locale); From 6280fb2498ca0708492338c281ea24e991299da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= <daniel@klabbers.email> Date: Wed, 29 Nov 2017 06:26:48 +0100 Subject: [PATCH 67/86] reverting translator contract --- src/Api/Controller/SendConfirmationEmailController.php | 8 ++++---- src/Api/Serializer/GroupSerializer.php | 8 ++++---- src/Forum/Controller/ResetPasswordController.php | 7 ++++--- src/Foundation/AbstractValidator.php | 8 ++++---- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Api/Controller/SendConfirmationEmailController.php b/src/Api/Controller/SendConfirmationEmailController.php index dd9e37afa..2935f0067 100644 --- a/src/Api/Controller/SendConfirmationEmailController.php +++ b/src/Api/Controller/SendConfirmationEmailController.php @@ -18,9 +18,9 @@ use Flarum\User\AssertPermissionTrait; use Flarum\User\EmailToken; use Flarum\User\Exception\PermissionDeniedException; use Illuminate\Contracts\Mail\Mailer; -use Illuminate\Contracts\Translation\Translator; use Illuminate\Mail\Message; use Psr\Http\Message\ServerRequestInterface; +use Symfony\Component\Translation\TranslatorInterface; use Zend\Diactoros\Response\EmptyResponse; class SendConfirmationEmailController implements ControllerInterface @@ -43,7 +43,7 @@ class SendConfirmationEmailController implements ControllerInterface protected $url; /** - * @var Translator + * @var TranslatorInterface */ protected $translator; @@ -51,9 +51,9 @@ class SendConfirmationEmailController implements ControllerInterface * @param \Flarum\Settings\SettingsRepositoryInterface $settings * @param Mailer $mailer * @param UrlGenerator $url - * @param Translator $translator + * @param TranslatorInterface $translator */ - public function __construct(SettingsRepositoryInterface $settings, Mailer $mailer, UrlGenerator $url, Translator $translator) + public function __construct(SettingsRepositoryInterface $settings, Mailer $mailer, UrlGenerator $url, TranslatorInterface $translator) { $this->settings = $settings; $this->mailer = $mailer; diff --git a/src/Api/Serializer/GroupSerializer.php b/src/Api/Serializer/GroupSerializer.php index 94bf6b80f..7cd1eb989 100644 --- a/src/Api/Serializer/GroupSerializer.php +++ b/src/Api/Serializer/GroupSerializer.php @@ -12,8 +12,8 @@ namespace Flarum\Api\Serializer; use Flarum\Group\Group; -use Illuminate\Contracts\Translation\Translator; use InvalidArgumentException; +use Symfony\Component\Translation\TranslatorInterface; class GroupSerializer extends AbstractSerializer { @@ -23,14 +23,14 @@ class GroupSerializer extends AbstractSerializer protected $type = 'groups'; /** - * @var Translator + * @var TranslatorInterface */ private $translator; /** - * @param Translator $translator + * @param TranslatorInterface $translator */ - public function __construct(Translator $translator) + public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } diff --git a/src/Forum/Controller/ResetPasswordController.php b/src/Forum/Controller/ResetPasswordController.php index 0be98834d..f5f7e9300 100644 --- a/src/Forum/Controller/ResetPasswordController.php +++ b/src/Forum/Controller/ResetPasswordController.php @@ -15,9 +15,9 @@ use DateTime; use Flarum\Http\Controller\AbstractHtmlController; use Flarum\User\Exception\InvalidConfirmationTokenException; use Flarum\User\PasswordToken; -use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\View\Factory; use Psr\Http\Message\ServerRequestInterface as Request; +use Symfony\Component\Translation\TranslatorInterface; class ResetPasswordController extends AbstractHtmlController { @@ -27,14 +27,15 @@ class ResetPasswordController extends AbstractHtmlController protected $view; /** - * @var Translator + * @var TranslatorInterface */ protected $translator; /** * @param Factory $view + * @param TranslatorInterface $translator */ - public function __construct(Factory $view, Translator $translator) + public function __construct(Factory $view, TranslatorInterface $translator) { $this->view = $view; $this->translator = $translator; diff --git a/src/Foundation/AbstractValidator.php b/src/Foundation/AbstractValidator.php index 90b3af47c..ee1062af5 100644 --- a/src/Foundation/AbstractValidator.php +++ b/src/Foundation/AbstractValidator.php @@ -13,9 +13,9 @@ namespace Flarum\Foundation; use Flarum\Foundation\Event\Validating; use Illuminate\Contracts\Events\Dispatcher; -use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\Validation\ValidationException; use Illuminate\Validation\Factory; +use Symfony\Component\Translation\TranslatorInterface; abstract class AbstractValidator { @@ -35,16 +35,16 @@ abstract class AbstractValidator protected $events; /** - * @var Translator + * @var TranslatorInterface */ protected $translator; /** * @param Factory $validator * @param Dispatcher $events - * @param Translator $translator + * @param TranslatorInterface $translator */ - public function __construct(Factory $validator, Dispatcher $events, Translator $translator) + public function __construct(Factory $validator, Dispatcher $events, TranslatorInterface $translator) { $this->validator = $validator; $this->events = $events; From 93aa3d77b53ebbd96258f6009e41bd967114a906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= <daniel@klabbers.email> Date: Wed, 13 Dec 2017 21:45:55 +0100 Subject: [PATCH 68/86] re-using symfony translator --- src/Locale/LocaleServiceProvider.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Locale/LocaleServiceProvider.php b/src/Locale/LocaleServiceProvider.php index 35b52eef7..73eb156f5 100644 --- a/src/Locale/LocaleServiceProvider.php +++ b/src/Locale/LocaleServiceProvider.php @@ -16,6 +16,7 @@ use Flarum\Foundation\AbstractServiceProvider; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Translation\Translator as TranslatorContract; use Symfony\Component\Translation\MessageSelector; +use Symfony\Component\Translation\TranslatorInterface; class LocaleServiceProvider extends AbstractServiceProvider { @@ -48,6 +49,7 @@ class LocaleServiceProvider extends AbstractServiceProvider }); $this->app->alias('translator', Translator::class); $this->app->alias('translator', TranslatorContract::class); + $this->app->alias('translator', TranslatorInterface::class); } private function getDefaultLocale(): string From 2aba61668cc84f914d3a79a98542f95ed74b7072 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Fri, 15 Dec 2017 08:10:32 +0100 Subject: [PATCH 69/86] - satisfying styleci - cleared the merge conflict in the phpdoc - changed some string class names to use ::class --- src/Admin/AdminServiceProvider.php | 5 +---- .../Listener/CheckCustomLessFormat.php | 10 +++++----- src/Api/Controller/ListNotificationsController.php | 2 +- src/Forum/ForumServiceProvider.php | 2 +- src/Foundation/Console/CacheClearCommand.php | 8 -------- src/Http/Middleware/ShareErrorsFromSession.php | 1 - src/{Core => User}/AvatarUploader.php | 3 +-- src/User/Command/DeleteAvatarHandler.php | 2 +- src/User/Command/EditUserHandler.php | 2 +- src/User/Command/RegisterUserHandler.php | 2 +- src/User/Command/UploadAvatarHandler.php | 3 +-- src/{Core => User}/Listener/SelfDemotionGuard.php | 14 +++++++------- src/User/User.php | 8 -------- src/User/UserServiceProvider.php | 14 +++++++------- 14 files changed, 27 insertions(+), 49 deletions(-) rename src/{Core => Admin}/Listener/CheckCustomLessFormat.php (78%) rename src/{Core => User}/AvatarUploader.php (96%) rename src/{Core => User}/Listener/SelfDemotionGuard.php (82%) diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index 9104bef74..d517f1fe6 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -11,14 +11,11 @@ namespace Flarum\Admin; +use Flarum\Admin\Listener\CheckCustomLessFormat; use Flarum\Admin\Middleware\RequireAdministrateAbility; use Flarum\Event\ConfigureMiddleware; use Flarum\Extension\Event\Disabled; use Flarum\Extension\Event\Enabled; -use Flarum\Core\Listener\CheckCustomLessFormat; -use Flarum\Event\ExtensionWasDisabled; -use Flarum\Event\ExtensionWasEnabled; -use Flarum\Event\SettingWasSet; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Http\Middleware\AuthenticateWithSession; use Flarum\Http\Middleware\DispatchRoute; diff --git a/src/Core/Listener/CheckCustomLessFormat.php b/src/Admin/Listener/CheckCustomLessFormat.php similarity index 78% rename from src/Core/Listener/CheckCustomLessFormat.php rename to src/Admin/Listener/CheckCustomLessFormat.php index 324b62bae..c8d80d2b0 100644 --- a/src/Core/Listener/CheckCustomLessFormat.php +++ b/src/Admin/Listener/CheckCustomLessFormat.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Listener; +namespace Flarum\Admin\Listener; -use Flarum\Core\Exception\ValidationException; -use Flarum\Event\PrepareSerializedSetting; +use Flarum\Foundation\ValidationException; +use Flarum\Settings\Event\Serializing; use Illuminate\Contracts\Events\Dispatcher; use Less_Exception_Parser; use Less_Parser; @@ -21,10 +21,10 @@ class CheckCustomLessFormat { public function subscribe(Dispatcher $events) { - $events->listen(PrepareSerializedSetting::class, [$this, 'check']); + $events->listen(Serializing::class, [$this, 'check']); } - public function check(PrepareSerializedSetting $event) + public function check(Serializing $event) { if ($event->key === 'custom_less') { $parser = new Less_Parser(); diff --git a/src/Api/Controller/ListNotificationsController.php b/src/Api/Controller/ListNotificationsController.php index 434078944..ceb9a2a6f 100644 --- a/src/Api/Controller/ListNotificationsController.php +++ b/src/Api/Controller/ListNotificationsController.php @@ -11,10 +11,10 @@ namespace Flarum\Api\Controller; +use Flarum\Api\UrlGenerator; use Flarum\Discussion\Discussion; use Flarum\Notification\NotificationRepository; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Api\UrlGenerator; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 530d0e589..175346ad3 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -26,9 +26,9 @@ use Flarum\Http\Middleware\StartSession; use Flarum\Http\RouteCollection; use Flarum\Http\RouteHandlerFactory; use Flarum\Http\UrlGenerator; -use Zend\Stratigility\MiddlewarePipe; use Flarum\Settings\SettingsRepositoryInterface; use Symfony\Component\Translation\TranslatorInterface; +use Zend\Stratigility\MiddlewarePipe; class ForumServiceProvider extends AbstractServiceProvider { diff --git a/src/Foundation/Console/CacheClearCommand.php b/src/Foundation/Console/CacheClearCommand.php index 4b2a8ee99..6bd6650da 100644 --- a/src/Foundation/Console/CacheClearCommand.php +++ b/src/Foundation/Console/CacheClearCommand.php @@ -25,20 +25,12 @@ class CacheClearCommand extends AbstractCommand protected $cache; /** -<<<<<<< HEAD:src/Foundation/Console/CacheClearCommand.php - * @var \Flarum\Forum\Frontend -======= * @var ForumWebApp ->>>>>>> master:src/Debug/Console/CacheClearCommand.php */ protected $forum; /** -<<<<<<< HEAD:src/Foundation/Console/CacheClearCommand.php - * @var \Flarum\Admin\Frontend -======= * @var AdminWebApp ->>>>>>> master:src/Debug/Console/CacheClearCommand.php */ protected $admin; diff --git a/src/Http/Middleware/ShareErrorsFromSession.php b/src/Http/Middleware/ShareErrorsFromSession.php index 5d0a5ed9b..87c2b845a 100644 --- a/src/Http/Middleware/ShareErrorsFromSession.php +++ b/src/Http/Middleware/ShareErrorsFromSession.php @@ -59,4 +59,3 @@ class ShareErrorsFromSession implements MiddlewareInterface return $out ? $out($request, $response) : $response; } } - diff --git a/src/Core/AvatarUploader.php b/src/User/AvatarUploader.php similarity index 96% rename from src/Core/AvatarUploader.php rename to src/User/AvatarUploader.php index 180bae93c..29f1e9e2e 100755 --- a/src/Core/AvatarUploader.php +++ b/src/User/AvatarUploader.php @@ -9,9 +9,8 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\User; -use Flarum\User\User; use Illuminate\Support\Str; use Intervention\Image\Image; use League\Flysystem\FilesystemInterface; diff --git a/src/User/Command/DeleteAvatarHandler.php b/src/User/Command/DeleteAvatarHandler.php index a5ee526a1..91b0dd50d 100644 --- a/src/User/Command/DeleteAvatarHandler.php +++ b/src/User/Command/DeleteAvatarHandler.php @@ -13,9 +13,9 @@ namespace Flarum\User\Command; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; +use Flarum\User\AvatarUploader; use Flarum\User\Event\AvatarDeleting; use Flarum\User\UserRepository; -use Flarum\Core\AvatarUploader; use Flarum\Event\AvatarWillBeDeleted; use Illuminate\Contracts\Events\Dispatcher; diff --git a/src/User/Command/EditUserHandler.php b/src/User/Command/EditUserHandler.php index 4c2d887f6..7dd0cd3dc 100644 --- a/src/User/Command/EditUserHandler.php +++ b/src/User/Command/EditUserHandler.php @@ -12,7 +12,7 @@ namespace Flarum\User\Command; use Exception; -use Flarum\Core\AvatarUploader; +use Flarum\User\AvatarUploader; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; use Flarum\User\Event\GroupsChanged; diff --git a/src/User/Command/RegisterUserHandler.php b/src/User/Command/RegisterUserHandler.php index 91d628810..977766fce 100644 --- a/src/User/Command/RegisterUserHandler.php +++ b/src/User/Command/RegisterUserHandler.php @@ -12,7 +12,7 @@ namespace Flarum\User\Command; use Exception; -use Flarum\Core\AvatarUploader; +use Flarum\User\AvatarUploader; use Flarum\Foundation\DispatchEventsTrait; use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\AssertPermissionTrait; diff --git a/src/User/Command/UploadAvatarHandler.php b/src/User/Command/UploadAvatarHandler.php index 9e50a192c..b0dc60b6d 100644 --- a/src/User/Command/UploadAvatarHandler.php +++ b/src/User/Command/UploadAvatarHandler.php @@ -11,11 +11,10 @@ namespace Flarum\User\Command; -use Exception; -use Flarum\Core\AvatarUploader; use Flarum\Foundation\Application; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; +use Flarum\User\AvatarUploader; use Flarum\User\AvatarValidator; use Flarum\User\Event\AvatarSaving; use Flarum\User\UserRepository; diff --git a/src/Core/Listener/SelfDemotionGuard.php b/src/User/Listener/SelfDemotionGuard.php similarity index 82% rename from src/Core/Listener/SelfDemotionGuard.php rename to src/User/Listener/SelfDemotionGuard.php index 1fbfe3e89..d45d8ccb8 100644 --- a/src/Core/Listener/SelfDemotionGuard.php +++ b/src/User/Listener/SelfDemotionGuard.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Listener; +namespace Flarum\User\Listener; -use Flarum\Core\Exception\PermissionDeniedException; -use Flarum\Core\Group; -use Flarum\Event\UserWillBeSaved; +use Flarum\User\Exception\PermissionDeniedException; +use Flarum\Group\Group; +use Flarum\User\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class SelfDemotionGuard @@ -23,15 +23,15 @@ class SelfDemotionGuard */ public function subscribe(Dispatcher $events) { - $events->listen(UserWillBeSaved::class, [$this, 'whenUserWillBeSaved']); + $events->listen(Saving::class, [$this, 'whenUserWillBeSaved']); } /** * Prevent an admin from removing their admin permission via the API. - * @param UserWillBeSaved $event + * @param Saving $event * @throws PermissionDeniedException */ - public function whenUserWillBeSaved(UserWillBeSaved $event) + public function whenUserWillBeSaved(Saving $event) { // Non-admin users pose no problem if (! $event->actor->isAdmin()) { diff --git a/src/User/User.php b/src/User/User.php index b5f6824c7..38a9f6900 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -18,14 +18,6 @@ use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\GetDisplayName; use Flarum\Event\PostWasDeleted; use Flarum\Event\PrepareUserGroups; -use Flarum\Event\UserAvatarWasChanged; -use Flarum\Event\UserEmailChangeWasRequested; -use Flarum\Event\UserEmailWasChanged; -use Flarum\Event\UserPasswordWasChanged; -use Flarum\Event\UserWasActivated; -use Flarum\Event\UserWasDeleted; -use Flarum\Event\UserWasRegistered; -use Flarum\Event\UserWasRenamed; use Flarum\Foundation\Application; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Group\Group; diff --git a/src/User/UserServiceProvider.php b/src/User/UserServiceProvider.php index 7c17943c6..be6da2d8a 100644 --- a/src/User/UserServiceProvider.php +++ b/src/User/UserServiceProvider.php @@ -30,7 +30,7 @@ class UserServiceProvider extends AbstractServiceProvider }); $this->app->alias('flarum.gate', 'Illuminate\Contracts\Auth\Access\Gate'); - $this->app->alias('flarum.gate', 'Flarum\User\Gate'); + $this->app->alias('flarum.gate', Gate::class); $this->registerAvatarsFilesystem(); } @@ -45,11 +45,11 @@ class UserServiceProvider extends AbstractServiceProvider ->needs('League\Flysystem\FilesystemInterface') ->give($avatarsFilesystem); - $this->app->when('Flarum\User\Command\DeleteAvatarHandler') + $this->app->when(Command\DeleteAvatarHandler::class) ->needs('League\Flysystem\FilesystemInterface') ->give($avatarsFilesystem); - $this->app->when('Flarum\User\Command\RegisterUserHandler') + $this->app->when(Command\RegisterUserHandler::class) ->needs('League\Flysystem\FilesystemInterface') ->give($avatarsFilesystem); } @@ -86,10 +86,10 @@ class UserServiceProvider extends AbstractServiceProvider $events = $this->app->make('events'); - $events->subscribe('Flarum\Core\Listener\SelfDemotionGuard'); - $events->subscribe('Flarum\User\EmailConfirmationMailer'); - $events->subscribe('Flarum\User\UserMetadataUpdater'); - $events->subscribe('Flarum\User\UserPolicy'); + $events->subscribe(Listener\SelfDemotionGuard::class); + $events->subscribe(EmailConfirmationMailer::class); + $events->subscribe(UserMetadataUpdater::class); + $events->subscribe(UserPolicy::class); $events->listen(ConfigureUserPreferences::class, [$this, 'configureUserPreferences']); } From 28d4cff156be0781e61239316dd2575f394f2c8c Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Fri, 15 Dec 2017 08:14:15 +0100 Subject: [PATCH 70/86] satisfying sci isnt enough for it, lets please it further --- src/Http/Middleware/ShareErrorsFromSession.php | 1 + src/User/Command/DeleteAvatarHandler.php | 1 - src/User/Command/EditUserHandler.php | 2 +- src/User/Command/RegisterUserHandler.php | 2 +- src/User/Listener/SelfDemotionGuard.php | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Http/Middleware/ShareErrorsFromSession.php b/src/Http/Middleware/ShareErrorsFromSession.php index 87c2b845a..6f03c6215 100644 --- a/src/Http/Middleware/ShareErrorsFromSession.php +++ b/src/Http/Middleware/ShareErrorsFromSession.php @@ -1,4 +1,5 @@ <?php + /* * This file is part of Flarum. * diff --git a/src/User/Command/DeleteAvatarHandler.php b/src/User/Command/DeleteAvatarHandler.php index 91b0dd50d..25eb3b39f 100644 --- a/src/User/Command/DeleteAvatarHandler.php +++ b/src/User/Command/DeleteAvatarHandler.php @@ -16,7 +16,6 @@ use Flarum\User\AssertPermissionTrait; use Flarum\User\AvatarUploader; use Flarum\User\Event\AvatarDeleting; use Flarum\User\UserRepository; -use Flarum\Event\AvatarWillBeDeleted; use Illuminate\Contracts\Events\Dispatcher; class DeleteAvatarHandler diff --git a/src/User/Command/EditUserHandler.php b/src/User/Command/EditUserHandler.php index 7dd0cd3dc..3554038b5 100644 --- a/src/User/Command/EditUserHandler.php +++ b/src/User/Command/EditUserHandler.php @@ -12,9 +12,9 @@ namespace Flarum\User\Command; use Exception; -use Flarum\User\AvatarUploader; use Flarum\Foundation\DispatchEventsTrait; use Flarum\User\AssertPermissionTrait; +use Flarum\User\AvatarUploader; use Flarum\User\Event\GroupsChanged; use Flarum\User\Event\Saving; use Flarum\User\User; diff --git a/src/User/Command/RegisterUserHandler.php b/src/User/Command/RegisterUserHandler.php index 977766fce..fdd95b434 100644 --- a/src/User/Command/RegisterUserHandler.php +++ b/src/User/Command/RegisterUserHandler.php @@ -12,11 +12,11 @@ namespace Flarum\User\Command; use Exception; -use Flarum\User\AvatarUploader; use Flarum\Foundation\DispatchEventsTrait; use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\AssertPermissionTrait; use Flarum\User\AuthToken; +use Flarum\User\AvatarUploader; use Flarum\User\Event\Saving; use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\User; diff --git a/src/User/Listener/SelfDemotionGuard.php b/src/User/Listener/SelfDemotionGuard.php index d45d8ccb8..f4aaf4276 100644 --- a/src/User/Listener/SelfDemotionGuard.php +++ b/src/User/Listener/SelfDemotionGuard.php @@ -11,9 +11,9 @@ namespace Flarum\User\Listener; +use Flarum\User\Event\Saving; use Flarum\User\Exception\PermissionDeniedException; use Flarum\Group\Group; -use Flarum\User\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class SelfDemotionGuard From 7be01119f53ff74ba06d179030daa0627901acf1 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Fri, 15 Dec 2017 08:15:08 +0100 Subject: [PATCH 71/86] and another.. --- src/User/Listener/SelfDemotionGuard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/User/Listener/SelfDemotionGuard.php b/src/User/Listener/SelfDemotionGuard.php index f4aaf4276..9c015ed83 100644 --- a/src/User/Listener/SelfDemotionGuard.php +++ b/src/User/Listener/SelfDemotionGuard.php @@ -11,9 +11,9 @@ namespace Flarum\User\Listener; +use Flarum\Group\Group; use Flarum\User\Event\Saving; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Group\Group; use Illuminate\Contracts\Events\Dispatcher; class SelfDemotionGuard From 654fca9c2c54bcdd1e2f4535a35e31654f05e44f Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Fri, 15 Dec 2017 08:29:07 +0100 Subject: [PATCH 72/86] fixed the BasicFoo vs FooBasic serializer definition issue, prevented for future using ::class --- src/Api/ApiServiceProvider.php | 3 ++- src/Api/Serializer/BasicDiscussionSerializer.php | 14 +++++++------- src/Api/Serializer/BasicPostSerializer.php | 4 ++-- src/Api/Serializer/BasicUserSerializer.php | 2 +- src/Api/Serializer/ForumSerializer.php | 2 +- src/Api/Serializer/GroupSerializer.php | 2 +- src/Api/Serializer/NotificationSerializer.php | 4 ++-- src/Api/Serializer/PostSerializer.php | 8 ++++---- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Api/ApiServiceProvider.php b/src/Api/ApiServiceProvider.php index 7360358a3..f0bdf6659 100644 --- a/src/Api/ApiServiceProvider.php +++ b/src/Api/ApiServiceProvider.php @@ -15,6 +15,7 @@ use Flarum\Api\Controller\AbstractSerializeController; use Flarum\Api\Middleware\FakeHttpMethods; use Flarum\Api\Middleware\HandleErrors; use Flarum\Api\Serializer\AbstractSerializer; +use Flarum\Api\Serializer\BasicDiscussionSerializer; use Flarum\Api\Serializer\NotificationSerializer; use Flarum\Event\ConfigureApiRoutes; use Flarum\Event\ConfigureMiddleware; @@ -114,7 +115,7 @@ class ApiServiceProvider extends AbstractServiceProvider { $blueprints = []; $serializers = [ - 'discussionRenamed' => 'Flarum\Api\Serializer\DiscussionBasicSerializer' + 'discussionRenamed' => BasicDiscussionSerializer::class ]; $this->app->make('events')->fire( diff --git a/src/Api/Serializer/BasicDiscussionSerializer.php b/src/Api/Serializer/BasicDiscussionSerializer.php index b0f39b2fe..b03d6d002 100644 --- a/src/Api/Serializer/BasicDiscussionSerializer.php +++ b/src/Api/Serializer/BasicDiscussionSerializer.php @@ -46,7 +46,7 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function startUser($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\BasicUserSerializer'); + return $this->hasOne($discussion, BasicUserSerializer::class); } /** @@ -54,7 +54,7 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function startPost($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\BasicPostSerializer'); + return $this->hasOne($discussion, BasicPostSerializer::class); } /** @@ -62,7 +62,7 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function lastUser($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\BasicUserSerializer'); + return $this->hasOne($discussion, BasicUserSerializer::class); } /** @@ -70,7 +70,7 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function lastPost($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\BasicPostSerializer'); + return $this->hasOne($discussion, BasicPostSerializer::class); } /** @@ -78,7 +78,7 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function posts($discussion) { - return $this->hasMany($discussion, 'Flarum\Api\Serializer\PostSerializer'); + return $this->hasMany($discussion, PostSerializer::class); } /** @@ -86,7 +86,7 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function relevantPosts($discussion) { - return $this->hasMany($discussion, 'Flarum\Api\Serializer\BasicPostSerializer'); + return $this->hasMany($discussion, BasicPostSerializer::class); } /** @@ -94,6 +94,6 @@ class BasicDiscussionSerializer extends AbstractSerializer */ protected function hideUser($discussion) { - return $this->hasOne($discussion, 'Flarum\Api\Serializer\UserBasicSerializer'); + return $this->hasOne($discussion, BasicUserSerializer::class); } } diff --git a/src/Api/Serializer/BasicPostSerializer.php b/src/Api/Serializer/BasicPostSerializer.php index a2a10feeb..103bd8a06 100644 --- a/src/Api/Serializer/BasicPostSerializer.php +++ b/src/Api/Serializer/BasicPostSerializer.php @@ -57,7 +57,7 @@ class BasicPostSerializer extends AbstractSerializer */ protected function user($post) { - return $this->hasOne($post, 'Flarum\Api\Serializer\BasicUserSerializer'); + return $this->hasOne($post, BasicUserSerializer::class); } /** @@ -65,6 +65,6 @@ class BasicPostSerializer extends AbstractSerializer */ protected function discussion($post) { - return $this->hasOne($post, 'Flarum\Api\Serializer\BasicDiscussionSerializer'); + return $this->hasOne($post, BasicDiscussionSerializer::class); } } diff --git a/src/Api/Serializer/BasicUserSerializer.php b/src/Api/Serializer/BasicUserSerializer.php index 5e84273d5..3a6b3d46d 100644 --- a/src/Api/Serializer/BasicUserSerializer.php +++ b/src/Api/Serializer/BasicUserSerializer.php @@ -47,6 +47,6 @@ class BasicUserSerializer extends AbstractSerializer */ protected function groups($user) { - return $this->hasMany($user, 'Flarum\Api\Serializer\GroupSerializer'); + return $this->hasMany($user, GroupSerializer::class); } } diff --git a/src/Api/Serializer/ForumSerializer.php b/src/Api/Serializer/ForumSerializer.php index 399fcfd83..02dcdd6d6 100644 --- a/src/Api/Serializer/ForumSerializer.php +++ b/src/Api/Serializer/ForumSerializer.php @@ -97,7 +97,7 @@ class ForumSerializer extends AbstractSerializer */ protected function groups($model) { - return $this->hasMany($model, 'Flarum\Api\Serializer\GroupSerializer'); + return $this->hasMany($model, GroupSerializer::class); } /** diff --git a/src/Api/Serializer/GroupSerializer.php b/src/Api/Serializer/GroupSerializer.php index 7cd1eb989..7511329cc 100644 --- a/src/Api/Serializer/GroupSerializer.php +++ b/src/Api/Serializer/GroupSerializer.php @@ -62,7 +62,7 @@ class GroupSerializer extends AbstractSerializer */ protected function permissions($group) { - return $this->hasMany($group, 'Flarum\Api\Serializers\PermissionSerializer'); + return $this->hasMany($group, PermissionSerializer::class); } /** diff --git a/src/Api/Serializer/NotificationSerializer.php b/src/Api/Serializer/NotificationSerializer.php index 9159445a3..55b809079 100644 --- a/src/Api/Serializer/NotificationSerializer.php +++ b/src/Api/Serializer/NotificationSerializer.php @@ -57,7 +57,7 @@ class NotificationSerializer extends AbstractSerializer */ protected function user($notification) { - return $this->hasOne($notification, 'Flarum\Api\Serializer\BasicUserSerializer'); + return $this->hasOne($notification, BasicUserSerializer::class); } /** @@ -65,7 +65,7 @@ class NotificationSerializer extends AbstractSerializer */ protected function sender($notification) { - return $this->hasOne($notification, 'Flarum\Api\Serializer\BasicUserSerializer'); + return $this->hasOne($notification, BasicUserSerializer::class); } /** diff --git a/src/Api/Serializer/PostSerializer.php b/src/Api/Serializer/PostSerializer.php index 7843e43ce..ee807374b 100644 --- a/src/Api/Serializer/PostSerializer.php +++ b/src/Api/Serializer/PostSerializer.php @@ -77,7 +77,7 @@ class PostSerializer extends BasicPostSerializer */ protected function user($post) { - return $this->hasOne($post, 'Flarum\Api\Serializer\UserSerializer'); + return $this->hasOne($post, UserSerializer::class); } /** @@ -85,7 +85,7 @@ class PostSerializer extends BasicPostSerializer */ protected function discussion($post) { - return $this->hasOne($post, 'Flarum\Api\Serializer\DiscussionBasicSerializer'); + return $this->hasOne($post, BasicDiscussionSerializer::class); } /** @@ -93,7 +93,7 @@ class PostSerializer extends BasicPostSerializer */ protected function editUser($post) { - return $this->hasOne($post, 'Flarum\Api\Serializer\UserBasicSerializer'); + return $this->hasOne($post, BasicUserSerializer::class); } /** @@ -101,6 +101,6 @@ class PostSerializer extends BasicPostSerializer */ protected function hideUser($post) { - return $this->hasOne($post, 'Flarum\Api\Serializer\UserBasicSerializer'); + return $this->hasOne($post, BasicUserSerializer::class); } } From 183a22b5c513aa53b4ae1a628d8349ff0672d100 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Fri, 15 Dec 2017 09:29:20 +0100 Subject: [PATCH 73/86] - FilesystemInterface no longer needed in User related handlers - FilesystemInterface conditional ioc binding moved to AvatarUploader - User::getAvatarAtribute failed to use the UrlGenerator properly --- src/User/Command/UploadAvatarHandler.php | 2 +- src/User/User.php | 2 +- src/User/UserServiceProvider.php | 10 +--------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/User/Command/UploadAvatarHandler.php b/src/User/Command/UploadAvatarHandler.php index b0dc60b6d..18fa84c00 100644 --- a/src/User/Command/UploadAvatarHandler.php +++ b/src/User/Command/UploadAvatarHandler.php @@ -98,7 +98,7 @@ class UploadAvatarHandler $image = (new ImageManager)->make($tmpFile); $this->events->fire( - new AvatarSaving($user, $actor, $tmpFile) + new AvatarSaving($user, $actor, $image) ); $this->uploader->upload($user, $image); diff --git a/src/User/User.php b/src/User/User.php index 38a9f6900..577ab1dcb 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -316,7 +316,7 @@ class User extends AbstractModel return $this->avatar_path; } - return app(UrlGenerator::class)->toPath('assets/avatars/'.$this->avatar_path); + return app(UrlGenerator::class)->to('forum')->path('assets/avatars/'.$this->avatar_path); } } diff --git a/src/User/UserServiceProvider.php b/src/User/UserServiceProvider.php index be6da2d8a..1b1a52954 100644 --- a/src/User/UserServiceProvider.php +++ b/src/User/UserServiceProvider.php @@ -41,15 +41,7 @@ class UserServiceProvider extends AbstractServiceProvider return $app->make('Illuminate\Contracts\Filesystem\Factory')->disk('flarum-avatars')->getDriver(); }; - $this->app->when('Flarum\User\Command\UploadAvatarHandler') - ->needs('League\Flysystem\FilesystemInterface') - ->give($avatarsFilesystem); - - $this->app->when(Command\DeleteAvatarHandler::class) - ->needs('League\Flysystem\FilesystemInterface') - ->give($avatarsFilesystem); - - $this->app->when(Command\RegisterUserHandler::class) + $this->app->when(AvatarUploader::class) ->needs('League\Flysystem\FilesystemInterface') ->give($avatarsFilesystem); } From 1b94ef90eacd89a770d3a86955f945f593514182 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers <daniel@productip.com> Date: Fri, 15 Dec 2017 09:35:02 +0100 Subject: [PATCH 74/86] the admin service provider also has to use the new HandleError logic --- src/Admin/AdminServiceProvider.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index d517f1fe6..ccdf4fc62 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -51,8 +51,7 @@ class AdminServiceProvider extends AbstractServiceProvider // All requests should first be piped through our global error handler $debugMode = ! $app->isUpToDate() || $app->inDebugMode(); - $errorDir = __DIR__.'/../../error'; - $pipe->pipe(new HandleErrors($errorDir, $app->make('log'), $debugMode)); + $pipe->pipe($app->make(HandleErrors::class, ['debug' => $debugMode])); $pipe->pipe($app->make(ParseJsonBody::class)); $pipe->pipe($app->make(StartSession::class)); From 2ec183778c8509df31a28d4d4ac3c5802b4ffb5c Mon Sep 17 00:00:00 2001 From: Toby Zerner <toby.zerner@gmail.com> Date: Tue, 19 Dec 2017 18:38:00 +1030 Subject: [PATCH 75/86] Pick up config when setting a new base path --- src/Foundation/Site.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Foundation/Site.php b/src/Foundation/Site.php index 904e403de..e069366e8 100644 --- a/src/Foundation/Site.php +++ b/src/Foundation/Site.php @@ -95,6 +95,10 @@ class Site { $this->basePath = $basePath; + if (file_exists($file = $this->basePath.'/config.php')) { + $this->config = include $file; + } + return $this; } From 4cf481355fb44025984fef18bd29bb38c37a6ff7 Mon Sep 17 00:00:00 2001 From: Toby Zerner <toby.zerner@gmail.com> Date: Tue, 19 Dec 2017 18:52:27 +1030 Subject: [PATCH 76/86] Fix usage of UrlGenerator in notifications --- src/Api/Controller/ListNotificationsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Api/Controller/ListNotificationsController.php b/src/Api/Controller/ListNotificationsController.php index ceb9a2a6f..f5f360309 100644 --- a/src/Api/Controller/ListNotificationsController.php +++ b/src/Api/Controller/ListNotificationsController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Api\UrlGenerator; +use Flarum\Http\UrlGenerator; use Flarum\Discussion\Discussion; use Flarum\Notification\NotificationRepository; use Flarum\User\Exception\PermissionDeniedException; @@ -92,7 +92,7 @@ class ListNotificationsController extends AbstractListController } $document->addPaginationLinks( - $this->url->toRoute('notifications.index'), + $this->url->to('api')->route('notifications.index'), $request->getQueryParams(), $offset, $limit, From 2b8c66354d864cf43eafff99b0236800edb4a7f9 Mon Sep 17 00:00:00 2001 From: Toby Zerner <toby.zerner@gmail.com> Date: Tue, 19 Dec 2017 08:24:06 +0000 Subject: [PATCH 77/86] Apply fixes from StyleCI [ci skip] [skip ci] --- src/Api/Controller/ListNotificationsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/Controller/ListNotificationsController.php b/src/Api/Controller/ListNotificationsController.php index f5f360309..f09dd7ca9 100644 --- a/src/Api/Controller/ListNotificationsController.php +++ b/src/Api/Controller/ListNotificationsController.php @@ -11,8 +11,8 @@ namespace Flarum\Api\Controller; -use Flarum\Http\UrlGenerator; use Flarum\Discussion\Discussion; +use Flarum\Http\UrlGenerator; use Flarum\Notification\NotificationRepository; use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface; From e9da1ba2f55058f5180db57e57f44e4d7d9fe030 Mon Sep 17 00:00:00 2001 From: Toby Zerner <toby.zerner@gmail.com> Date: Tue, 19 Dec 2017 18:58:45 +1030 Subject: [PATCH 78/86] Remove Listener namespace We may reverse this in the future, but for now just going for consistency between domains (the majority do not use a Listener namespace) --- src/Admin/AdminServiceProvider.php | 1 - src/Admin/{Listener => }/CheckCustomLessFormat.php | 2 +- src/User/{Listener => }/SelfDemotionGuard.php | 2 +- src/User/UserServiceProvider.php | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) rename src/Admin/{Listener => }/CheckCustomLessFormat.php (97%) rename src/User/{Listener => }/SelfDemotionGuard.php (98%) diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index ccdf4fc62..d0ca1975f 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -11,7 +11,6 @@ namespace Flarum\Admin; -use Flarum\Admin\Listener\CheckCustomLessFormat; use Flarum\Admin\Middleware\RequireAdministrateAbility; use Flarum\Event\ConfigureMiddleware; use Flarum\Extension\Event\Disabled; diff --git a/src/Admin/Listener/CheckCustomLessFormat.php b/src/Admin/CheckCustomLessFormat.php similarity index 97% rename from src/Admin/Listener/CheckCustomLessFormat.php rename to src/Admin/CheckCustomLessFormat.php index c8d80d2b0..a2644945f 100644 --- a/src/Admin/Listener/CheckCustomLessFormat.php +++ b/src/Admin/CheckCustomLessFormat.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Admin\Listener; +namespace Flarum\Admin; use Flarum\Foundation\ValidationException; use Flarum\Settings\Event\Serializing; diff --git a/src/User/Listener/SelfDemotionGuard.php b/src/User/SelfDemotionGuard.php similarity index 98% rename from src/User/Listener/SelfDemotionGuard.php rename to src/User/SelfDemotionGuard.php index 9c015ed83..1aec59e6c 100644 --- a/src/User/Listener/SelfDemotionGuard.php +++ b/src/User/SelfDemotionGuard.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\User\Listener; +namespace Flarum\User; use Flarum\Group\Group; use Flarum\User\Event\Saving; diff --git a/src/User/UserServiceProvider.php b/src/User/UserServiceProvider.php index 1b1a52954..dc7774e2e 100644 --- a/src/User/UserServiceProvider.php +++ b/src/User/UserServiceProvider.php @@ -78,7 +78,7 @@ class UserServiceProvider extends AbstractServiceProvider $events = $this->app->make('events'); - $events->subscribe(Listener\SelfDemotionGuard::class); + $events->subscribe(SelfDemotionGuard::class); $events->subscribe(EmailConfirmationMailer::class); $events->subscribe(UserMetadataUpdater::class); $events->subscribe(UserPolicy::class); From bfd98e33717aee986750dafcfb4c17608871ec7a Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Tue, 19 Dec 2017 23:16:06 +0100 Subject: [PATCH 79/86] DRY up loading of config --- src/Foundation/Site.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Foundation/Site.php b/src/Foundation/Site.php index e069366e8..3c73b643a 100644 --- a/src/Foundation/Site.php +++ b/src/Foundation/Site.php @@ -65,7 +65,7 @@ class Site /** * @var array */ - protected $config; + protected $config = []; protected $extenders = []; @@ -73,10 +73,6 @@ class Site { $this->basePath = getcwd(); $this->publicPath = $this->basePath; - - if (file_exists($file = $this->basePath.'/config.php')) { - $this->config = include $file; - } } /** @@ -95,10 +91,6 @@ class Site { $this->basePath = $basePath; - if (file_exists($file = $this->basePath.'/config.php')) { - $this->config = include $file; - } - return $this; } @@ -135,6 +127,15 @@ class Site return $this; } + protected function getConfig() + { + if (empty($this->config) && file_exists($file = $this->basePath.'/config.php')) { + $this->config = include $file; + } + + return $this->config; + } + /** * @return Application */ @@ -153,7 +154,7 @@ class Site } $app->instance('env', 'production'); - $app->instance('flarum.config', $this->config); + $app->instance('flarum.config', $this->getConfig()); $app->instance('config', $config = $this->getIlluminateConfig($app)); $this->registerLogger($app); From 6efe2ee91a6db4af8a4356135f36e27b4abff8e2 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Tue, 19 Dec 2017 23:48:38 +0100 Subject: [PATCH 80/86] Fix previous commit Prevent `flarum.config` from being bound in the container when the software has not been installed yet. --- src/Foundation/Site.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Foundation/Site.php b/src/Foundation/Site.php index 3c73b643a..a86f7d6e1 100644 --- a/src/Foundation/Site.php +++ b/src/Foundation/Site.php @@ -65,7 +65,7 @@ class Site /** * @var array */ - protected $config = []; + protected $config; protected $extenders = []; From 8d5132fd5a234e9bf5adcdc70bf003a24e0ba089 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Wed, 20 Dec 2017 00:00:23 +0100 Subject: [PATCH 81/86] Disable HandleErrors middleware during installation Temporary measure until we have a real fix in place. --- src/Http/Server.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Http/Server.php b/src/Http/Server.php index 590a73a24..8c50cb3e2 100644 --- a/src/Http/Server.php +++ b/src/Http/Server.php @@ -67,6 +67,7 @@ class Server */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out) { + // FIXME: Only call this when app is installed. Do this via middleware? $this->collectGarbage(); $middleware = $this->getMiddleware($request->getUri()->getPath()); @@ -119,8 +120,10 @@ class Server { $this->app->register(InstallServiceProvider::class); - $pipe->pipe(new HandleErrors($this->getErrorDir(), $this->app->make('log'), true)); - + // FIXME: Re-enable HandleErrors middleware, if possible + // (Right now it tries to resolve a database connection because of the injected settings repo instance) + // We could register a different settings repo when Flarum is not installed + //$pipe->pipe($this->app->make(HandleErrors::class, ['debug' => true])); $pipe->pipe($this->app->make(StartSession::class)); $pipe->pipe($this->app->make(DispatchRoute::class, ['routes' => $this->app->make('flarum.install.routes')])); From c8a1a5fcfa64cd63836cffc5779f55f1965c79d2 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Wed, 20 Dec 2017 00:20:23 +0100 Subject: [PATCH 82/86] Fix more incompatibilities with Laravel 5.5 --- migrations/2016_02_04_095452_add_slug_to_discussions.php | 2 +- src/Database/DatabaseMigrationRepository.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/migrations/2016_02_04_095452_add_slug_to_discussions.php b/migrations/2016_02_04_095452_add_slug_to_discussions.php index 0a87cc059..54ec4e31c 100644 --- a/migrations/2016_02_04_095452_add_slug_to_discussions.php +++ b/migrations/2016_02_04_095452_add_slug_to_discussions.php @@ -20,7 +20,7 @@ return [ }); // Store slugs for existing discussions - $schema->getConnection()->table('discussions')->chunk(100, function ($discussions) use ($schema) { + $schema->getConnection()->table('discussions')->chunkById(100, function ($discussions) use ($schema) { foreach ($discussions as $discussion) { $schema->getConnection()->table('discussions')->where('id', $discussion->id)->update([ 'slug' => Str::slug($discussion->title) diff --git a/src/Database/DatabaseMigrationRepository.php b/src/Database/DatabaseMigrationRepository.php index fdce0f00e..3e02ae84a 100755 --- a/src/Database/DatabaseMigrationRepository.php +++ b/src/Database/DatabaseMigrationRepository.php @@ -58,7 +58,8 @@ class DatabaseMigrationRepository implements MigrationRepositoryInterface return $this->table() ->where('extension', $extension) ->orderBy('migration', 'asc') - ->pluck('migration'); + ->pluck('migration') + ->toArray(); } /** From 56231d61be8e2090891cb0e93542460c41052af1 Mon Sep 17 00:00:00 2001 From: Franz Liedke <franz@develophp.org> Date: Thu, 21 Dec 2017 12:23:34 +0100 Subject: [PATCH 83/86] Move garbage collection into middleware This prevents garbage collection to randomly break the installer: before installation, the models that are being accessed have no database connection. Now, the middleware is only mounted into the forum's middleware stack. I want API requests to have stable performance, and the forum middleware stack is only mounted when Flarum is installed. --- src/Forum/ForumServiceProvider.php | 2 + src/Http/Middleware/CollectGarbage.php | 55 ++++++++++++++++++++++++++ src/Http/Server.php | 24 ----------- 3 files changed, 57 insertions(+), 24 deletions(-) create mode 100644 src/Http/Middleware/CollectGarbage.php diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 175346ad3..8e95b0072 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -17,6 +17,7 @@ use Flarum\Extension\Event\Disabled; use Flarum\Extension\Event\Enabled; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Http\Middleware\AuthenticateWithSession; +use Flarum\Http\Middleware\CollectGarbage; use Flarum\Http\Middleware\DispatchRoute; use Flarum\Http\Middleware\HandleErrors; use Flarum\Http\Middleware\ParseJsonBody; @@ -54,6 +55,7 @@ class ForumServiceProvider extends AbstractServiceProvider $pipe->pipe($app->make(HandleErrors::class, ['debug' => $debugMode])); $pipe->pipe($app->make(ParseJsonBody::class)); + $pipe->pipe($app->make(CollectGarbage::class)); $pipe->pipe($app->make(StartSession::class)); $pipe->pipe($app->make(RememberFromCookie::class)); $pipe->pipe($app->make(AuthenticateWithSession::class)); diff --git a/src/Http/Middleware/CollectGarbage.php b/src/Http/Middleware/CollectGarbage.php new file mode 100644 index 000000000..0a04da16e --- /dev/null +++ b/src/Http/Middleware/CollectGarbage.php @@ -0,0 +1,55 @@ +<?php + +/* + * This file is part of Flarum. + * + * (c) Toby Zerner <toby.zerner@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Http\Middleware; + +use Flarum\Http\AccessToken; +use Flarum\User\AuthToken; +use Flarum\User\EmailToken; +use Flarum\User\PasswordToken; +use Psr\Http\Message\ResponseInterface as Response; +use Psr\Http\Message\ServerRequestInterface as Request; +use Zend\Stratigility\MiddlewareInterface; + +class CollectGarbage implements MiddlewareInterface +{ + /** + * {@inheritdoc} + */ + public function __invoke(Request $request, Response $response, callable $out = null) + { + $this->collectGarbageSometimes(); + + return $out ? $out($request, $response) : $response; + } + + private function collectGarbageSometimes() + { + // In order to save performance, we only execute this query + // from time to time (with 50% chance). + if (! $this->hit()) { + return; + } + + AccessToken::whereRaw('last_activity <= ? - lifetime', [time()])->delete(); + + $earliestToKeep = date('Y-m-d H:i:s', time() - 24 * 60 * 60); + + EmailToken::where('created_at', '<=', $earliestToKeep)->delete(); + PasswordToken::where('created_at', '<=', $earliestToKeep)->delete(); + AuthToken::where('created_at', '<=', $earliestToKeep)->delete(); + } + + private function hit() + { + return mt_rand(1, 100) <= 2; + } +} diff --git a/src/Http/Server.php b/src/Http/Server.php index 8c50cb3e2..80e507d43 100644 --- a/src/Http/Server.php +++ b/src/Http/Server.php @@ -18,9 +18,6 @@ use Flarum\Http\Middleware\HandleErrors; use Flarum\Http\Middleware\StartSession; use Flarum\Install\InstallServiceProvider; use Flarum\Update\UpdateServiceProvider; -use Flarum\User\AuthToken; -use Flarum\User\EmailToken; -use Flarum\User\PasswordToken; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Zend\Diactoros\Response\HtmlResponse; @@ -67,9 +64,6 @@ class Server */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out) { - // FIXME: Only call this when app is installed. Do this via middleware? - $this->collectGarbage(); - $middleware = $this->getMiddleware($request->getUri()->getPath()); return $middleware($request, $response, $out); @@ -152,24 +146,6 @@ class Server return $pipe; } - private function collectGarbage() - { - if ($this->hitsLottery()) { - AccessToken::whereRaw('last_activity <= ? - lifetime', [time()])->delete(); - - $earliestToKeep = date('Y-m-d H:i:s', time() - 24 * 60 * 60); - - EmailToken::where('created_at', '<=', $earliestToKeep)->delete(); - PasswordToken::where('created_at', '<=', $earliestToKeep)->delete(); - AuthToken::where('created_at', '<=', $earliestToKeep)->delete(); - } - } - - private function hitsLottery() - { - return mt_rand(1, 100) <= 2; - } - private function getErrorDir() { return __DIR__.'/../../error'; From a0621e85bf196dd36d7626be0606f0240b70f644 Mon Sep 17 00:00:00 2001 From: Toby Zerner <toby.zerner@gmail.com> Date: Tue, 26 Dec 2017 20:38:15 +1030 Subject: [PATCH 84/86] Fix order of array_first arguments As per https://laravel.com/docs/5.3/upgrade (under "Arrays") --- src/Forum/Controller/DiscussionController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Forum/Controller/DiscussionController.php b/src/Forum/Controller/DiscussionController.php index 931141561..1c16d4669 100644 --- a/src/Forum/Controller/DiscussionController.php +++ b/src/Forum/Controller/DiscussionController.php @@ -64,7 +64,7 @@ class DiscussionController extends FrontendController $document = $this->getDocument($request->getAttribute('actor'), $params); $getResource = function ($link) use ($document) { - return array_first($document->included, function ($key, $value) use ($link) { + return array_first($document->included, function ($value, $key) use ($link) { return $value->type === $link->type && $value->id === $link->id; }); }; From 8a6344cfcfcf25be5c59f15d0b50f141f6df4b94 Mon Sep 17 00:00:00 2001 From: Toby Zerner <toby.zerner@gmail.com> Date: Wed, 27 Dec 2017 16:17:25 +1030 Subject: [PATCH 85/86] Fix some class names, clean up imports --- src/Forum/Controller/ResetPasswordController.php | 1 - src/Forum/Controller/SavePasswordController.php | 2 +- src/Forum/ForumServiceProvider.php | 1 + src/Foundation/AbstractValidator.php | 2 +- src/User/User.php | 1 - src/User/UserServiceProvider.php | 1 + 6 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Forum/Controller/ResetPasswordController.php b/src/Forum/Controller/ResetPasswordController.php index 2f3b025e2..3752ead21 100644 --- a/src/Forum/Controller/ResetPasswordController.php +++ b/src/Forum/Controller/ResetPasswordController.php @@ -27,7 +27,6 @@ class ResetPasswordController extends AbstractHtmlController /** * @param Factory $view - * @param TranslatorInterface $translator */ public function __construct(Factory $view) { diff --git a/src/Forum/Controller/SavePasswordController.php b/src/Forum/Controller/SavePasswordController.php index 0a1a25400..ea3257062 100644 --- a/src/Forum/Controller/SavePasswordController.php +++ b/src/Forum/Controller/SavePasswordController.php @@ -17,7 +17,7 @@ use Flarum\Http\UrlGenerator; use Flarum\User\PasswordToken; use Flarum\User\UserValidator; use Illuminate\Contracts\Validation\Factory; -use Illuminate\Contracts\Validation\ValidationException; +use Illuminate\Validation\ValidationException; use Psr\Http\Message\ServerRequestInterface as Request; use Zend\Diactoros\Response\RedirectResponse; diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index 8e95b0072..f0a68d342 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -27,6 +27,7 @@ use Flarum\Http\Middleware\StartSession; use Flarum\Http\RouteCollection; use Flarum\Http\RouteHandlerFactory; use Flarum\Http\UrlGenerator; +use Flarum\Settings\Event\Saved; use Flarum\Settings\SettingsRepositoryInterface; use Symfony\Component\Translation\TranslatorInterface; use Zend\Stratigility\MiddlewarePipe; diff --git a/src/Foundation/AbstractValidator.php b/src/Foundation/AbstractValidator.php index ee1062af5..25108526f 100644 --- a/src/Foundation/AbstractValidator.php +++ b/src/Foundation/AbstractValidator.php @@ -13,8 +13,8 @@ namespace Flarum\Foundation; use Flarum\Foundation\Event\Validating; use Illuminate\Contracts\Events\Dispatcher; -use Illuminate\Contracts\Validation\ValidationException; use Illuminate\Validation\Factory; +use Illuminate\Validation\ValidationException; use Symfony\Component\Translation\TranslatorInterface; abstract class AbstractValidator diff --git a/src/User/User.php b/src/User/User.php index 577ab1dcb..7c02c882d 100755 --- a/src/User/User.php +++ b/src/User/User.php @@ -16,7 +16,6 @@ use Flarum\Database\AbstractModel; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\GetDisplayName; -use Flarum\Event\PostWasDeleted; use Flarum\Event\PrepareUserGroups; use Flarum\Foundation\Application; use Flarum\Foundation\EventGeneratorTrait; diff --git a/src/User/UserServiceProvider.php b/src/User/UserServiceProvider.php index dc7774e2e..03f3cbf55 100644 --- a/src/User/UserServiceProvider.php +++ b/src/User/UserServiceProvider.php @@ -15,6 +15,7 @@ use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\GetPermission; use Flarum\Foundation\AbstractServiceProvider; use Illuminate\Contracts\Container\Container; +use RuntimeException; class UserServiceProvider extends AbstractServiceProvider { From ac7d28ca5899e7de6a0e9581367d8582f1c9dfb6 Mon Sep 17 00:00:00 2001 From: Toby Zerner <toby.zerner@gmail.com> Date: Wed, 27 Dec 2017 16:17:35 +1030 Subject: [PATCH 86/86] Remove unused method --- src/Api/Serializer/GroupSerializer.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Api/Serializer/GroupSerializer.php b/src/Api/Serializer/GroupSerializer.php index 7511329cc..7207c0153 100644 --- a/src/Api/Serializer/GroupSerializer.php +++ b/src/Api/Serializer/GroupSerializer.php @@ -57,14 +57,6 @@ class GroupSerializer extends AbstractSerializer ]; } - /** - * @return \Tobscure\JsonApi\Relationship - */ - protected function permissions($group) - { - return $this->hasMany($group, PermissionSerializer::class); - } - /** * @param string $name * @return string