Applied styleci changes for conversion work

This commit is contained in:
Dan Brown 2022-06-19 18:14:53 +01:00
parent 85f59b5275
commit ba25dda031
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
12 changed files with 12 additions and 14 deletions

View File

@ -6,12 +6,10 @@ use BookStack\Actions\ActivityType;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Tools\TrashCan;
use BookStack\Exceptions\ImageUploadException;
use BookStack\Exceptions\NotFoundException;
use BookStack\Facades\Activity;
use Exception;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Collection;
class BookshelfRepo

View File

@ -89,6 +89,7 @@ class Cloner
/**
* Convert an entity to a raw data array of input data.
*
* @return array<string, mixed>
*/
public function entityToInputData(Entity $entity): array

View File

@ -45,6 +45,7 @@ class HierarchyTransformer
$this->trashCan->destroyEntity($chapter);
Activity::add(ActivityType::BOOK_CREATE_FROM_CHAPTER, $book);
return $book;
}
@ -80,6 +81,7 @@ class HierarchyTransformer
$shelf->books()->sync($shelfBookSyncData);
Activity::add(ActivityType::BOOKSHELF_CREATE_FROM_BOOK, $shelf);
return $shelf;
}
}
}

View File

@ -89,7 +89,8 @@ class BookApiController extends ApiController
return response('', 204);
}
protected function rules(): array {
protected function rules(): array
{
return [
'create' => [
'name' => ['required', 'string', 'max:255'],

View File

@ -167,7 +167,7 @@ class BookController extends Controller
if ($request->has('image_reset')) {
$validated['image'] = null;
} else if (array_key_exists('image', $validated) && is_null($validated['image'])) {
} elseif (array_key_exists('image', $validated) && is_null($validated['image'])) {
unset($validated['image']);
}

View File

@ -167,7 +167,7 @@ class BookshelfController extends Controller
if ($request->has('image_reset')) {
$validated['image'] = null;
} else if (array_key_exists('image', $validated) && is_null($validated['image'])) {
} elseif (array_key_exists('image', $validated) && is_null($validated['image'])) {
unset($validated['image']);
}

View File

@ -274,7 +274,6 @@ class ChapterController extends Controller
return redirect($chapter->getUrl());
}
/**
* Convert the chapter to a book.
*/

View File

@ -139,7 +139,7 @@ class BooksApiTest extends TestCase
// Ensure further updates without image do not clear cover image
$resp = $this->put($this->baseEndpoint . "/{$book->id}", [
'name' => 'My updated book again'
'name' => 'My updated book again',
]);
$book->refresh();

View File

@ -167,7 +167,7 @@ class ShelvesApiTest extends TestCase
// Ensure further updates without image do not clear cover image
$resp = $this->put($this->baseEndpoint . "/{$shelf->id}", [
'name' => 'My updated shelf again'
'name' => 'My updated shelf again',
]);
$shelf->refresh();

View File

@ -12,7 +12,6 @@ use Tests\TestCase;
class ConvertTest extends TestCase
{
public function test_chapter_edit_view_shows_convert_option()
{
/** @var Chapter $chapter */
@ -143,5 +142,4 @@ class ConvertTest extends TestCase
$this->assertNotPermissionError($resp);
$resp->assertRedirect();
}
}
}

View File

@ -8,7 +8,6 @@ use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
use BookStack\Entities\Repos\BaseRepo;
use BookStack\Entities\Repos\BookRepo;
use BookStack\Entities\Repos\BookshelfRepo;
use Illuminate\Support\Str;
use Tests\Uploads\UsesImages;

View File

@ -201,7 +201,7 @@ trait SharedTestHelpers
/** @var RolePermission $permission */
$permission = RolePermission::query()->where('name', '=', $permissionName)->firstOrFail();
$roles = $user->roles()->whereHas('permissions', function($query) use ($permission) {
$roles = $user->roles()->whereHas('permissions', function ($query) use ($permission) {
$query->where('id', '=', $permission->id);
})->get();