PHP Класс Graby\SiteConfig\ConfigBuilder

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( array $config = [], Psr\Log\LoggerInterface $logger = null )
addToCache ( string $key, SiteConfig $config ) Add the given SiteConfig to the cache.
build ( string $host, boolean $exactHostMatch = false ) : false | SiteConfig Returns SiteConfig instance (joined in order: exact match, wildcard, fingerprint, global, default).
buildForHost ( string $host, boolean $addToCache = true ) : SiteConfig Build a config file from a host.
buildFromUrl ( string $url, boolean $addToCache = true ) : SiteConfig Build a config file from an url.
create ( ) : SiteConfig Create a new config.
getCachedVersion ( string $key ) : boolean | SiteConfig Determine if a Config is already cached.
loadSiteConfig ( string $host, boolean $exactHostMatch = false ) : false | SiteConfig Returns SiteConfig instance if an appropriate one is found, false otherwise.
mergeConfig ( SiteConfig $currentConfig, SiteConfig $newConfig ) : SiteConfig Append a configuration from to an existing one.
parseLines ( array $lines ) : SiteConfig Parse line from the config file to build the config.
setLogger ( Psr\Log\LoggerInterface $logger )

Описание методов

__construct() публичный Метод

public __construct ( array $config = [], Psr\Log\LoggerInterface $logger = null )
$config array
$logger Psr\Log\LoggerInterface

addToCache() публичный Метод

Add the given SiteConfig to the cache.
public addToCache ( string $key, SiteConfig $config )
$key string Key for the cache
$config SiteConfig Config to be cached

build() публичный Метод

Will add the merged result to cache if $addToCache is set to true
Устаревший: Use either buildForHost() / buildFromUrl() for the merged config or loadSiteConfig() to get the config for a site
public build ( string $host, boolean $exactHostMatch = false ) : false | SiteConfig
$host string Host, like en.wikipedia.org
$exactHostMatch boolean if true, we will not look for wildcard config matches
Результат false | SiteConfig

buildForHost() публичный Метод

Use buildFromUrl if you have an url.
public buildForHost ( string $host, boolean $addToCache = true ) : SiteConfig
$host string Host, like en.wikipedia.org
$addToCache boolean
Результат SiteConfig

buildFromUrl() публичный Метод

Use buildForHost if you already have the host.
public buildFromUrl ( string $url, boolean $addToCache = true ) : SiteConfig
$url string
$addToCache boolean
Результат SiteConfig

create() публичный Метод

Create a new config.
public create ( ) : SiteConfig
Результат SiteConfig

getCachedVersion() публичный Метод

If so, return it otherwise return false.
public getCachedVersion ( string $key ) : boolean | SiteConfig
$key string Key for the cache
Результат boolean | SiteConfig

loadSiteConfig() публичный Метод

by default if host is 'test.example.org' we will look for and load '.example.org.txt' if it exists.
public loadSiteConfig ( string $host, boolean $exactHostMatch = false ) : false | SiteConfig
$host string Host, like en.wikipedia.org
$exactHostMatch boolean if true, we will not look for wildcard config matches
Результат false | SiteConfig

mergeConfig() публичный Метод

Append a configuration from to an existing one.
public mergeConfig ( SiteConfig $currentConfig, SiteConfig $newConfig ) : SiteConfig
$currentConfig SiteConfig Current configuration
$newConfig SiteConfig New configuration to be merged
Результат SiteConfig Merged config

parseLines() публичный Метод

Parse line from the config file to build the config.
public parseLines ( array $lines ) : SiteConfig
$lines array
Результат SiteConfig

setLogger() публичный Метод

public setLogger ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface