PHP 클래스 Graby\SiteConfig\ConfigBuilder

파일 보기 프로젝트 열기: j0k3r/graby 1 사용 예제들

공개 메소드들

메소드 설명
__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