Re-structured the app code to be feature based rather than code type based

This commit is contained in:
Dan Brown
2018-09-25 12:30:50 +01:00
parent 19751ed1cb
commit 919660678b
109 changed files with 684 additions and 531 deletions

View File

@ -1,10 +1,10 @@
<?php namespace BookStack\Http\Controllers;
use BookStack\Exceptions\FileUploadException;
use BookStack\Attachment;
use BookStack\Uploads\Attachment;
use BookStack\Exceptions\NotFoundException;
use BookStack\Repos\EntityRepo;
use BookStack\Services\AttachmentService;
use BookStack\Entities\EntityRepo;
use BookStack\Uploads\AttachmentService;
use Illuminate\Http\Request;
class AttachmentController extends Controller
@ -15,7 +15,7 @@ class AttachmentController extends Controller
/**
* AttachmentController constructor.
* @param AttachmentService $attachmentService
* @param \BookStack\Uploads\AttachmentService $attachmentService
* @param Attachment $attachment
* @param EntityRepo $entityRepo
*/

View File

@ -4,9 +4,9 @@ namespace BookStack\Http\Controllers\Auth;
use BookStack\Exceptions\AuthException;
use BookStack\Http\Controllers\Controller;
use BookStack\Repos\UserRepo;
use BookStack\Services\LdapService;
use BookStack\Services\SocialAuthService;
use BookStack\Auth\UserRepo;
use BookStack\Auth\Access\LdapService;
use BookStack\Auth\Access\SocialAuthService;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
@ -43,9 +43,9 @@ class LoginController extends Controller
/**
* Create a new controller instance.
*
* @param SocialAuthService $socialAuthService
* @param \BookStack\Auth\\BookStack\Auth\Access\SocialAuthService $socialAuthService
* @param LdapService $ldapService
* @param UserRepo $userRepo
* @param \BookStack\Auth\UserRepo $userRepo
*/
public function __construct(SocialAuthService $socialAuthService, LdapService $ldapService, UserRepo $userRepo)
{

View File

@ -5,11 +5,11 @@ namespace BookStack\Http\Controllers\Auth;
use BookStack\Exceptions\SocialSignInAccountNotUsed;
use BookStack\Exceptions\SocialSignInException;
use BookStack\Exceptions\UserRegistrationException;
use BookStack\Repos\UserRepo;
use BookStack\Services\EmailConfirmationService;
use BookStack\Services\SocialAuthService;
use BookStack\SocialAccount;
use BookStack\User;
use BookStack\Auth\UserRepo;
use BookStack\Auth\Access\EmailConfirmationService;
use BookStack\Auth\Access\SocialAuthService;
use BookStack\Auth\SocialAccount;
use BookStack\Auth\User;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@ -48,11 +48,11 @@ class RegisterController extends Controller
/**
* Create a new controller instance.
*
* @param SocialAuthService $socialAuthService
* @param EmailConfirmationService $emailConfirmationService
* @param UserRepo $userRepo
* @param \BookStack\Auth\Access\SocialAuthService $socialAuthService
* @param \BookStack\Auth\EmailConfirmationService $emailConfirmationService
* @param \BookStack\Auth\UserRepo $userRepo
*/
public function __construct(SocialAuthService $socialAuthService, EmailConfirmationService $emailConfirmationService, UserRepo $userRepo)
public function __construct(\BookStack\Auth\Access\SocialAuthService $socialAuthService, \BookStack\Auth\Access\EmailConfirmationService $emailConfirmationService, UserRepo $userRepo)
{
$this->middleware('guest')->only(['getRegister', 'postRegister', 'socialRegister']);
$this->socialAuthService = $socialAuthService;
@ -119,7 +119,7 @@ class RegisterController extends Controller
/**
* Create a new user instance after a valid registration.
* @param array $data
* @return User
* @return \BookStack\Auth\User
*/
protected function create(array $data)
{

View File

@ -1,10 +1,10 @@
<?php namespace BookStack\Http\Controllers;
use Activity;
use BookStack\Book;
use BookStack\Repos\EntityRepo;
use BookStack\Repos\UserRepo;
use BookStack\Services\ExportService;
use BookStack\Entities\Book;
use BookStack\Entities\EntityRepo;
use BookStack\Auth\UserRepo;
use BookStack\Entities\ExportService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Views;
@ -19,8 +19,8 @@ class BookController extends Controller
/**
* BookController constructor.
* @param EntityRepo $entityRepo
* @param UserRepo $userRepo
* @param ExportService $exportService
* @param \BookStack\Auth\UserRepo $userRepo
* @param \BookStack\Entities\ExportService $exportService
*/
public function __construct(EntityRepo $entityRepo, UserRepo $userRepo, ExportService $exportService)
{

View File

@ -1,11 +1,11 @@
<?php namespace BookStack\Http\Controllers;
use Activity;
use BookStack\Book;
use BookStack\Bookshelf;
use BookStack\Repos\EntityRepo;
use BookStack\Repos\UserRepo;
use BookStack\Services\ExportService;
use BookStack\Entities\Book;
use BookStack\Entities\Bookshelf;
use BookStack\Entities\EntityRepo;
use BookStack\Auth\UserRepo;
use BookStack\Entities\ExportService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Views;
@ -19,9 +19,9 @@ class BookshelfController extends Controller
/**
* BookController constructor.
* @param EntityRepo $entityRepo
* @param \BookStack\Entities\EntityRepo $entityRepo
* @param UserRepo $userRepo
* @param ExportService $exportService
* @param \BookStack\Entities\ExportService $exportService
*/
public function __construct(EntityRepo $entityRepo, UserRepo $userRepo, ExportService $exportService)
{

View File

@ -1,9 +1,9 @@
<?php namespace BookStack\Http\Controllers;
use Activity;
use BookStack\Repos\EntityRepo;
use BookStack\Repos\UserRepo;
use BookStack\Services\ExportService;
use BookStack\Entities\EntityRepo;
use BookStack\Auth\UserRepo;
use BookStack\Entities\ExportService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Views;
@ -19,7 +19,7 @@ class ChapterController extends Controller
* ChapterController constructor.
* @param EntityRepo $entityRepo
* @param UserRepo $userRepo
* @param ExportService $exportService
* @param \BookStack\Entities\ExportService $exportService
*/
public function __construct(EntityRepo $entityRepo, UserRepo $userRepo, ExportService $exportService)
{

View File

@ -1,8 +1,8 @@
<?php namespace BookStack\Http\Controllers;
use Activity;
use BookStack\Repos\CommentRepo;
use BookStack\Repos\EntityRepo;
use BookStack\Actions\CommentRepo;
use BookStack\Entities\EntityRepo;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
@ -13,8 +13,8 @@ class CommentController extends Controller
/**
* CommentController constructor.
* @param EntityRepo $entityRepo
* @param CommentRepo $commentRepo
* @param \BookStack\Entities\EntityRepo $entityRepo
* @param \BookStack\Actions\CommentRepo $commentRepo
*/
public function __construct(EntityRepo $entityRepo, CommentRepo $commentRepo)
{

View File

@ -8,7 +8,7 @@ use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use BookStack\User;
use BookStack\Auth\User;
abstract class Controller extends BaseController
{

View File

@ -1,7 +1,7 @@
<?php namespace BookStack\Http\Controllers;
use Activity;
use BookStack\Repos\EntityRepo;
use BookStack\Entities\EntityRepo;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Views;

View File

@ -2,11 +2,11 @@
use BookStack\Exceptions\ImageUploadException;
use BookStack\Exceptions\NotFoundException;
use BookStack\Repos\EntityRepo;
use BookStack\Repos\ImageRepo;
use BookStack\Entities\EntityRepo;
use BookStack\Uploads\ImageRepo;
use Illuminate\Filesystem\Filesystem as File;
use Illuminate\Http\Request;
use BookStack\Image;
use BookStack\Uploads\Image;
use BookStack\Repos\PageRepo;
class ImageController extends Controller

View File

@ -2,9 +2,9 @@
use Activity;
use BookStack\Exceptions\NotFoundException;
use BookStack\Repos\EntityRepo;
use BookStack\Repos\UserRepo;
use BookStack\Services\ExportService;
use BookStack\Entities\EntityRepo;
use BookStack\Auth\UserRepo;
use BookStack\Entities\ExportService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Views;
@ -19,8 +19,8 @@ class PageController extends Controller
/**
* PageController constructor.
* @param EntityRepo $entityRepo
* @param ExportService $exportService
* @param \BookStack\Entities\EntityRepo $entityRepo
* @param \BookStack\Entities\ExportService $exportService
* @param UserRepo $userRepo
*/
public function __construct(EntityRepo $entityRepo, ExportService $exportService, UserRepo $userRepo)

View File

@ -1,7 +1,7 @@
<?php namespace BookStack\Http\Controllers;
use BookStack\Exceptions\PermissionsException;
use BookStack\Repos\PermissionsRepo;
use BookStack\Auth\Permissions\PermissionsRepo;
use Illuminate\Http\Request;
class PermissionController extends Controller
@ -11,7 +11,7 @@ class PermissionController extends Controller
/**
* PermissionController constructor.
* @param PermissionsRepo $permissionsRepo
* @param \BookStack\Auth\Permissions\PermissionsRepo $permissionsRepo
*/
public function __construct(PermissionsRepo $permissionsRepo)
{

View File

@ -1,8 +1,8 @@
<?php namespace BookStack\Http\Controllers;
use BookStack\Repos\EntityRepo;
use BookStack\Services\SearchService;
use BookStack\Services\ViewService;
use BookStack\Entities\EntityRepo;
use BookStack\Entities\SearchService;
use BookStack\Actions\ViewService;
use Illuminate\Http\Request;
class SearchController extends Controller
@ -97,7 +97,7 @@ class SearchController extends Controller
$entities = $this->searchService->searchEntities($searchTerm, 'all', 1, 20, $permission)['results'];
} else {
$entityNames = $entityTypes->map(function ($type) {
return 'BookStack\\' . ucfirst($type);
return 'BookStack\\' . ucfirst($type); // TODO - Extract this elsewhere, too specific and stringy
})->toArray();
$entities = $this->viewService->getPopular(20, 0, $entityNames, $permission);
}

View File

@ -1,6 +1,6 @@
<?php namespace BookStack\Http\Controllers;
use BookStack\Services\ImageService;
use BookStack\Uploads\ImageService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Setting;

View File

@ -1,6 +1,6 @@
<?php namespace BookStack\Http\Controllers;
use BookStack\Repos\TagRepo;
use BookStack\Actions\TagRepo;
use Illuminate\Http\Request;
class TagController extends Controller

View File

@ -3,9 +3,9 @@
use Exception;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use BookStack\Repos\UserRepo;
use BookStack\Services\SocialAuthService;
use BookStack\User;
use BookStack\Auth\UserRepo;
use BookStack\Auth\Access\SocialAuthService;
use BookStack\Auth\User;
class UserController extends Controller
{
@ -16,7 +16,7 @@ class UserController extends Controller
/**
* UserController constructor.
* @param User $user
* @param UserRepo $userRepo
* @param \BookStack\Auth\UserRepo $userRepo
*/
public function __construct(User $user, UserRepo $userRepo)
{
@ -101,7 +101,7 @@ class UserController extends Controller
/**
* Show the form for editing the specified user.
* @param int $id
* @param SocialAuthService $socialAuthService
* @param \BookStack\Auth\Access\SocialAuthService $socialAuthService
* @return Response
*/
public function edit($id, SocialAuthService $socialAuthService)