Вход Регистрация
Файл: concrete5.7.5.6/concrete/src/Config/Repository/Repository.php
Строк: 124
<?php
namespace ConcreteCoreConfigRepository;

use 
ConcreteCoreConfigLoaderInterface;
use 
ConcreteCoreConfigSaverInterface;

class 
Repository extends IlluminateConfigRepository
{

    
/**
     * @var SaverInterface
     */
    
protected $saver;

    
/**
     * @var LoaderInterface
     */
    
protected $loader;

    
/**
     * Create a new configuration repository.
     *
     * @param LoaderInterface $loader
     * @param SaverInterface  $saver
     * @param                 $environment
     */
    
public function __construct(LoaderInterface $loaderSaverInterface $saver$environment)
    {
        
$this->saver $saver;
        
parent::__construct($loader$environment);
    }

    
/**
     * Clear specific key
     *
     * @param string $key
     */
    
public function clear($key)
    {
        
$this->set($keynull);
    }

    
/**
     * Save a key
     *
     * @param $key
     * @param $value
     * @return bool
     */
    
public function save($key$value)
    {
        list(
$namespace$group$item) = $this->parseKey($key);
        
$collection $this->getCollection($group$namespace);
        unset(
$this->items[$collection]);

        if (
$this->saver->save($item$value$this->environment$group$namespace)) {
            
$this->load($group$namespace$this->getCollection($group$namespace));

            return 
true;
        }
        return 
false;
    }

    
/**
     * Register a package for cascading configuration.
     *
     * @param  string $package
     * @param  string $hint
     * @param  string $namespace
     * @return void
     */
    
public function package($package$hint$namespace null)
    {
        
$namespace $this->getPackageNamespace($package$namespace);

        
$this->packages[] = $namespace;
        
$this->addNamespace($namespace$hint);
    }

    protected function 
getPackageNamespace($package$namespace)
    {
        return 
$namespace ?: $package;
    }

    public function 
clearCache()
    {
        
$this->items = array();
    }

    public function 
clearNamespace($namespace) {
        
$this->loader->clearNamespace($namespace);
    }

    
/**
     * @return SaverInterface
     */
    
public function getSaver()
    {
        return 
$this->saver;
    }

    
/**
     * Set the saver instance
     *
     * @param ConcreteCoreConfigSaverInterface $saver
     */
    
public function setSaver(SaverInterface $saver)
    {
        
$this->saver $saver;
    }

    protected function 
parsePackageSegments($key$namespace$item)
    {
        list(
$namespace$item) = explode('::'$key);

        
// First we'll just explode the first segment to get the namespace and group
        // since the item should be in the remaining segments. Once we have these
        // two pieces of data we can proceed with parsing out the item's value.
        
$itemSegments explode('.'$item);

        
$groupAndItem array_slice($this->parseBasicSegments($itemSegments), 1);

        return 
array_merge(array($namespace), $groupAndItem);
    }

}
Онлайн: 0
Реклама