NestedAccessor: add getService and hasService #480

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants
Contributor

Vrtak-CZ commented Jan 20, 2012

No description provided.

@@ -64,7 +86,7 @@ public function __call($name, $args)
*/
public function &__get($name)
{
- $service = $this->container->getService($this->namespace . $name);
+ $service = $this->getService($name);
return $service;
@mCzolko

mCzolko Mar 26, 2012

return $this->getService($name); není tam ta proměnná $service zbytečná?

@Majkl578

Majkl578 Mar 26, 2012

Contributor

Je.

@kravco

kravco Mar 26, 2012

Contributor

Nie, nie je.

Keďže Nette\Object deklaruje, že __get() vracia referenciu, musia takto fungovať i podedené triedy (aj Nette\DI\NestedAccessor). Takáto konštrukcia zabezpečí, že __get() nevráti referenciu na službu, ale len referenciu na kópiu v premennej $service.

@Majkl578

Majkl578 Mar 26, 2012

Contributor

Pravda, to jsem si neuvědomil. Bez toho by to řvalo E_NOTICE.

@mCzolko

mCzolko Mar 28, 2012

sorry, nevšiml jsem si ukazatele. a i tak díky za vysvětlení :)

@hrach hrach closed this Nov 22, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment