Skip to content

Conversation

@janpecha
Copy link
Member

@janpecha janpecha commented Jan 4, 2017

@castamir castamir self-assigned this Jan 6, 2017
@castamir castamir self-requested a review January 6, 2017 08:32
Copy link
Contributor

@castamir castamir left a comment

Choose a reason for hiding this comment

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

prosim o vyjadreni pripadne o upravy

# registrace Lean Mapperu
- LeanMapper\Connection(%leanmapper%)
- LeanMapper\DefaultMapper
- LeanMapper\DefaultEntityFactory
Copy link
Contributor

Choose a reason for hiding this comment

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

pokud si dobre vzpominam, tak tohle neni potreba definovat, existuje DI\Extension pro nette a dokonce regne i repozitare viz https://github.com/Tharos/LeanMapper/blob/develop/src/LeanMapper/Bridges/Nette/DI/LeanMapperExtension.php

Copy link
Member Author

Choose a reason for hiding this comment

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

Rozšíření pro Nette nepoužívám, ale ano, i to je jedna z cest. Ideální by asi bylo zmínit oboje - DI rozšíření jako doporučenou cestu a tohle nastavení jako alternativu pro ty, kteří nechtějí nemůžou DI rozšíření použít.

Copy link
Member Author

Choose a reason for hiding this comment

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

Přidal jsem část o použití DI rozšíření (snad je použito správně).


V rámci presenteru pak máme repositář přístupný přes `$this->bookRepository`.

**Tip:** pokud nechcete, nebo nemůžete použít anotaci `@inject`, lze pro předání repositáře použít constructor nebo [`inject*()` metodu](http://pla.nette.org/cs/inject-autowire).
Copy link
Contributor

Choose a reason for hiding this comment

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

Tohle bych napsal naopak. Konstruktor je jedine spravne reseni predani zavislosti. Injectovani, at uz pres anotace nebo pres metodu, je jen vseobecne pouzivana berlicka specialne pro presentery, aby se vyvojari vyhnuli problemu "contructor hell" pri velke dedicnosti, ktera je u presenteru bezna. V modelu aplikace (ve smyslu MVC) je nutne predat zavislosti vyhradne pres konstruktor.

Copy link
Member Author

Choose a reason for hiding this comment

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

Jasně, že ano. Psal jsem to hlavně s ohledem na začátečníky, kteří se snadno do contructor hellu v presenteru zapletou a jeho vyřešení je pro ně obtížné, pokročilejší uživatelé tohle nepotřebují, ti si to rovnou předají přes kontruktor.

Copy link
Member Author

Choose a reason for hiding this comment

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

Přidal jsem předání přes konstruktor.


Existuje mnoho důvodů proč v databázi pojmenovávat *sloupce/tabulky* pouze malými písmeny a jednotlivá slova oddělovat podtržítkem `_` *(tzv. under score konvence)*. Pokud bychom ale na straně PHP chtěli k těmto datům přistupovat pomocí *camel case konvence*, tedy vizuálně oddělovat velkým písmenem na začátku jednotlivých slov, **LeanMapper** k tomu nabízí všechny potřebné prostředky.

K zprovoznění této funkcionality postačí upravit [**mapper**](/cs/docs/mapper/), tedy třídu, která dědí po `LeanMapper\DefaultMapper` nebo jen implementuje rozhraní `LeanMapper\IMapper`. Nejprve si připravíme funkce, které nám budou převádět `fooBar` na `foo_bar` a obráceně. Můžeme je klidně implementovat jako statické veřejné metody vlastního mapperu.
Copy link
Contributor

Choose a reason for hiding this comment

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

Striktne vzato, metody pro prevod nazvu z jedne konvence do jine nepatri do Mapperu, ale jinam, kvuli pouzitelnosti mimo LeanMapper. Jejich implementace muze zustat staticka (stejne jako trida Strings z Nette) a v Mapperu to jen pouzit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Striktně vzato asi ano, ale pokud nikde jinde ty metody nepotřebujeme, nedává jejich vyčlenění do další třídy smysl. Navíc tohle je jen příklad, je asi zbytečné to komplikovat dalšími třídami.

@castamir
Copy link
Contributor

castamir commented Jan 8, 2017

Jinak vyborna prace! ;-)


leanmapper:
db:
host: localhost
Copy link
Contributor

Choose a reason for hiding this comment

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

přidej sem ještě driver, ať je to stejné jako dole

Copy link
Member Author

Choose a reason for hiding this comment

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

hotovo.

PS. přidal jsem ještě commit, který aktualizuje rok v patičce (z 2013-2016 na 2013-2017).

@castamir castamir merged commit 290a6b5 into LeanMapper:master Jan 12, 2017
@castamir
Copy link
Contributor

great job ;)

@janpecha janpecha deleted the pr/changes-3 branch April 15, 2018 15:09
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