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

Úkol 2 - Jozef Liška #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

JFox-sk
Copy link

@JFox-sk JFox-sk commented Oct 15, 2016

Jozef Liška

@@ -31,8 +31,26 @@ public function categoryDetail(Request $request)
throw new NotFoundHttpException("Kategorie neexistuje");
}

// paginator
$em = $this->get('doctrine.orm.entity_manager');
$dql = 'SELECT p
Copy link
Author

Choose a reason for hiding this comment

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

Tento blok DQL kódu je takmer totožný s ProductRepository->findByCategory() s tým rozdielom, že KnpPaginatorBundle to vyžaduje bez getResult() /takže som tu nemohol priamo použiť túto metódu/.
Vznikla mi tu však duplicita, tak by ma zaujímalo, či je nejaký best practice ako to presunúť do ProductRepository s tým aby som mal k dispozícií metódu bez a zároveň s getResult(). Samozrejme, napadajú ma možnosti ako to je možné spraviť, ale skôr ma zaujíma to, čo je osvedčené z praxe.
Vďaka.

Copy link
Member

Choose a reason for hiding this comment

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

Uvažuješ správně, určitě pokud je jeden kód duplikovaný, tak má cenu ho dát dohromady. Můžeš si tedy vytvořit metodu, která ten dotaz staví a ve findByCategory vrátit getResult nad jejím výsledkem

Copy link
Collaborator

Choose a reason for hiding this comment

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

Jo souhlas. Když je podíváš na ukázkové řešní v masteru, tak podobný problém jsem tam řešil já. Může to být ukázkové řešení. Nicméně nelíbí se mi, protože je tam porušený jeden z pricipů SOLID. Ale to vysvětlím.

@@ -31,8 +31,26 @@ public function categoryDetail(Request $request)
throw new NotFoundHttpException("Kategorie neexistuje");
}

// paginator
$em = $this->get('doctrine.orm.entity_manager');
$dql = 'SELECT p
Copy link
Member

Choose a reason for hiding this comment

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

Uvažuješ správně, určitě pokud je jeden kód duplikovaný, tak má cenu ho dát dohromady. Můžeš si tedy vytvořit metodu, která ten dotaz staví a ve findByCategory vrátit getResult nad jejím výsledkem

@vasekboch vasekboch changed the title Strankovanie Úkol 2 - Jozef Liška Oct 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants