Вход Регистрация
Файл: ServiceLocator-1.0.0/System/Kernel/ServiceContainer.php
Строк: 45
<?php
/**
 * PositiveCodeCMS
 *
 * Open source content management system for mobile sites
 *
 * @author KpuTuK <bykputuk@ya.ru>
 * @copyright Copyright (c) 2015, PositiveCodeCMS Team
 * @license MIT License
 */

namespace SystemKernelServiceLocator;

/**
 * Контейнер сервисов
 * @author KpuTuK <bykputuk@ya.ru>
 * @version 1.0.0
 * @package PositiveCodeCMS
 * @category Kernel
 */
class ServiceContainer extends ArrayObject implements ServiceContainerInterface
{
    
/**
     * Возвращает параметр контейнера или сервис 
     * @param string $index Ключ параметра/сервиса
     * @return mixed
     */
    
public function offsetGet($index)
    {
        if (
$this->offsetExists($index)) {
          return  
parent::offsetGet($index);
        } 
        
$this->loadToMap($index);
    }
    
/**
     * Регистрирует сервис в контейнере
     * @param SystemKernelServiceLocatorServiceProviderInterface $service Обьект сервиса
     * @param array $bindValues Массив параметров сервиса
     * @return SystemKernelServiceLocatorServiceContainer 
     */
    
public function withServiceProvider(
        
ServiceProviderInterface $service, array $bindValues = []
    ) {
        
$service->registerContainer($this);
        
$this->offsetSet($service->getServiceName(), $service);
        foreach (
$bindValues as $key => $value) {
            
$this->offsetSet($key$value);
        }
        return 
$this;
    }
}
Онлайн: 0
Реклама