Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Pagination example with knplabs/knp-pagination-bundle #22

Closed

Conversation

DaniCristante
Copy link
Contributor

No description provided.

@@ -34,7 +35,7 @@ protected function setUp(): void
{
$this->repository = $this->prophesize(BookRepository::class);

$this->service = new BookService($this->repository->reveal());
$this->service = new BookService($this->repository->reveal(), new Paginator());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tengo dudas sobre modificar los tests, entiendo que debería modificarlos para que se adapten al nuevo código ¿verdad?, pero ahora el BookService espera un nuevo param, un PaginatorInterface. Al no poder instanciar una interfaz, ¿Entiendo que le debería pasar un new Paginator que es el que implementa la interfaz?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si es posible pasarle una clase real, mejor, sino tmb puedes mockerla. En el caso de dependencias externas (como es tu caso) mejor como lo estás haciendo

@codecov
Copy link

codecov bot commented Aug 6, 2020

Codecov Report

Merging #22 into master will decrease coverage by 2.78%.
The diff coverage is 6.45%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #22      +/-   ##
============================================
- Coverage     51.43%   48.64%   -2.79%     
- Complexity      127      135       +8     
============================================
  Files            23       24       +1     
  Lines           488      518      +30     
============================================
+ Hits            251      252       +1     
- Misses          237      266      +29     
Impacted Files Coverage Δ Complexity Δ
src/BasicEntities/Admin/BookAdmin.php 100.00% <ø> (ø) 3.00 <0.00> (ø)
src/BasicEntities/Controller/BookController.php 68.75% <0.00%> (-31.25%) 4.00 <1.00> (+1.00) ⬇️
src/BasicEntities/Repository/BookRepository.php 15.78% <0.00%> (-7.29%) 3.00 <1.00> (+1.00) ⬇️
src/BasicEntities/ViewModel/BooksListViewModel.php 0.00% <0.00%> (ø) 5.00 <5.00> (?)
src/BasicEntities/Service/BookService.php 68.42% <25.00%> (-31.58%) 4.00 <2.00> (+1.00) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86aab42...c07b911. Read the comment docs.

@@ -52,6 +52,7 @@ protected function configureListFields(ListMapper $listMapper): void
->add('_action', 'actions', [
'actions' => [
'delete' => [],
'edit' => [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yo este cambio lo desharía, no es consistente con el resto de admins.


public function list(Request $request): Response
{
$page = (int) $request->get('page', 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creo que si haces: $request->query->getInt('page', 1); te da directamente un int, puede ser?

@@ -52,4 +53,15 @@ public function book(string $slug): Response
$model
);
}

public function list(Request $request): Response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

porqué no usas el mismo método que ya teniamos de books() y amplias su funcionalidad para incluir esto?, así evitamos tener 2 listados.

@@ -46,4 +58,16 @@ public function getBookViewModel(string $slug): BookViewModel

return $model;
}

public function getBooksListViewModel(int $page): BooksListViewModel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aquí lo mismo, podríamos reusar el método ya existente: getBooksViewModel()

use Knp\Bundle\PaginatorBundle\Pagination\SlidingPaginationInterface;
use Runroom\SamplesBundle\BasicEntities\Entity\Book;

class BooksListViewModel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Podríamos reusar el viewModel ya existente.

@@ -13,6 +13,10 @@ runroom_samples.basic_entities.book:
path: /book/{slug}
controller: Runroom\SamplesBundle\BasicEntities\Controller\BookController::book

runroom_samples.basic_entities.books_list:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Podríamos reusar la url ya existente.

@DaniCristante
Copy link
Contributor Author

Cierro este PR, he abierto uno nuevo: #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants