Created
March 4, 2014 09:17
-
-
Save ronan-gloo/9342993 to your computer and use it in GitHub Desktop.
Cuisine et dépendances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// constructor | |
class Void | |
{ | |
protected $mapper; | |
public function __construct(Mapper $mapper) | |
{ | |
$this->mapper = $mapper; | |
} | |
} | |
// Getter | Setter | |
class Void { | |
protected $mapper; | |
public function getMapper() | |
{ | |
return $this->mapper; | |
} | |
public function setMapper(Foreign $object) | |
{ | |
$this->mapper = $object; | |
return $this; | |
} | |
} | |
// Lazy loading | |
class Void implements ServiceLocatorAwareInterface | |
{ | |
use ServiceLocatorAwareTrait; | |
public function getMapper() | |
{ | |
return $this->getServiceLocator()->get('service.mapper'); | |
} | |
} | |
// Getter | Setter + Lazy loading | |
class Void implements ServiceLocatorAwareInterface | |
{ | |
use ServiceLocatorAwareTrait; | |
protected $mapper; | |
public function getMapper() | |
{ | |
if (! isset($this->mapper)) { | |
$this->setMapper($this->getServiceLocator()->get('service.mapper')); | |
} | |
return $this->mapper; | |
} | |
public function setMapper(Mapper $object) | |
{ | |
$this->mapper = $object; | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment