PHP Class Graby\SiteConfig\ConfigBuilder

ファイルを表示 Open project: j0k3r/graby Class Usage Examples

Public Methods

Method Description
__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 )

Method Details

__construct() public method

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

addToCache() public method

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() public method

Will add the merged result to cache if $addToCache is set to true
Deprecation: 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
return false | SiteConfig

buildForHost() public method

Use buildFromUrl if you have an url.
public buildForHost ( string $host, boolean $addToCache = true ) : SiteConfig
$host string Host, like en.wikipedia.org
$addToCache boolean
return SiteConfig

buildFromUrl() public method

Use buildForHost if you already have the host.
public buildFromUrl ( string $url, boolean $addToCache = true ) : SiteConfig
$url string
$addToCache boolean
return SiteConfig

create() public method

Create a new config.
public create ( ) : SiteConfig
return SiteConfig

getCachedVersion() public method

If so, return it otherwise return false.
public getCachedVersion ( string $key ) : boolean | SiteConfig
$key string Key for the cache
return boolean | SiteConfig

loadSiteConfig() public method

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
return false | SiteConfig

mergeConfig() public method

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
return SiteConfig Merged config

parseLines() public method

Parse line from the config file to build the config.
public parseLines ( array $lines ) : SiteConfig
$lines array
return SiteConfig

setLogger() public method

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