- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
<?php
// Zend\Di\Locator
namespace Zend\Di;
interface Locator
{
public function get($name, array $params = array());
}
<?php
//Zend\Di\ServiceLocation
namespace Zend\Di;
interface ServiceLocation extends Locator
{
public function set($name, $service);
}
<?php
//Zend\Di\ServiceLocator
namespace Zend\Di;
class ServiceLocator implements ServiceLocation
{
protected $map = array();
protected $services = array();
public function set($name, $service)
{
$this->services[$name] = $service;
return $this;
}
public function get($name, array $params = array())
{
if (!isset($this->services[$name])) {
if (!isset($this->map[$name])) {
return null;
}
$method = $this->map[$name];
return $this->$method($params);
}
$service = $this->services[$name];
if ($service instanceof \Closure
|| (!is_object($service) && is_callable($service))
) {
$this->services[$name] = $service = call_user_func_array($service, $params);
}
return $service;
}
}
по какой логике "радар" становится "местоположением", а затем "местоположение" снова становится "радарчиком"?!!! пыщь