本文整理汇总了PHP中FileBackend::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP FileBackend::__construct方法的具体用法?PHP FileBackend::__construct怎么用?PHP FileBackend::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileBackend
的用法示例。
在下文中一共展示了FileBackend::__construct方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construct a proxy backend that consists of several internal backends.
* Additional $config params include:
* 'backends' : Array of backend config and multi-backend settings.
* Each value is the config used in the constructor of a
* FileBackendStore class, but with these additional settings:
* 'class' : The name of the backend class
* 'isMultiMaster' : This must be set for one backend.
* 'syncChecks' : Integer bitfield of internal backend sync checks to perform.
* Possible bits include self::CHECK_SIZE and self::CHECK_TIME.
* The checks are done before allowing any file operations.
* @param $config Array
*/
public function __construct(array $config)
{
parent::__construct($config);
$namesUsed = array();
// Construct backends here rather than via registration
// to keep these backends hidden from outside the proxy.
foreach ($config['backends'] as $index => $config) {
$name = $config['name'];
if (isset($namesUsed[$name])) {
// don't break FileOp predicates
throw new MWException("Two or more backends defined with the name {$name}.");
}
$namesUsed[$name] = 1;
if (!isset($config['class'])) {
throw new MWException('No class given for a backend config.');
}
$class = $config['class'];
$this->backends[$index] = new $class($config);
if (!empty($config['isMultiMaster'])) {
if ($this->masterIndex >= 0) {
throw new MWException('More than one master backend defined.');
}
$this->masterIndex = $index;
}
}
if ($this->masterIndex < 0) {
// need backends and must have a master
throw new MWException('No master backend defined.');
}
$this->syncChecks = isset($config['syncChecks']) ? $config['syncChecks'] : self::CHECK_SIZE;
}
示例2: __construct
/**
* @see FileBackend::__construct()
*
* @param $config Array
*/
public function __construct(array $config)
{
parent::__construct($config);
$this->memCache = new EmptyBagOStuff();
// disabled by default
$this->cheapCache = new ProcessCacheLRU(300);
$this->expensiveCache = new ProcessCacheLRU(5);
}
示例3: __construct
/**
* @see FileBackend::__construct()
*
* @param $config Array
*/
public function __construct(array $config)
{
parent::__construct($config);
$this->memCache = new EmptyBagOStuff();
// disabled by default
$this->cheapCache = new ProcessCacheLRU(self::CACHE_CHEAP_SIZE);
$this->expensiveCache = new ProcessCacheLRU(self::CACHE_EXPENSIVE_SIZE);
}
示例4: __construct
/**
* @see FileBackend::__construct()
* Additional $config params include:
* - wanCache : WANObjectCache object to use for persistent caching.
* - mimeCallback : Callback that takes (storage path, content, file system path) and
* returns the MIME type of the file or 'unknown/unknown'. The file
* system path parameter should be used if the content one is null.
*
* @param array $config
*/
public function __construct(array $config)
{
parent::__construct($config);
$this->mimeCallback = isset($config['mimeCallback']) ? $config['mimeCallback'] : null;
$this->memCache = WANObjectCache::newEmpty();
// disabled by default
$this->cheapCache = new ProcessCacheLRU(self::CACHE_CHEAP_SIZE);
$this->expensiveCache = new ProcessCacheLRU(self::CACHE_EXPENSIVE_SIZE);
}
示例5: __construct
public function __construct(array $config)
{
$config['name'] = $config['backend']->getName();
$config['wikiId'] = $config['backend']->getWikiId();
parent::__construct($config);
$this->backend = $config['backend'];
$this->repoName = $config['repoName'];
$this->dbHandleFunc = $config['dbHandleFactory'];
$this->resolvedPathCache = new ProcessCacheLRU(100);
}
示例6: __construct
/**
* @see FileBackend::__construct()
* Additional $config params include:
* azureHost : Windows Azure server URL
* azureAccount : Windows Azure user used by MediaWiki
* azureKey : Authentication key for the above user (used to get sessions)
* //azureContainer : Identifier of the container. (Optional. If not provided wikiId will be used as container name)
* containerPaths : Map of container names to Azure container names
*/
public function __construct( array $config ) {
parent::__construct( $config );
$this->storageClient = new Microsoft_WindowsAzure_Storage_Blob(
$config['azureHost'],
$config['azureAccount'],
$config['azureKey']
);
$this->containerPaths = (array)$config['containerPaths'];
}
示例7: __construct
/**
* @see FileBackend::__construct()
* Additional $config params include:
* - wanCache : WANOBjectCache object to use for persistent caching.
* - mimeCallback : Callback that takes (storage path, content, file system path) and
* returns the MIME type of the file or 'unknown/unknown'. The file
* system path parameter should be used if the content one is null.
*
* @param array $config
*/
public function __construct(array $config)
{
parent::__construct($config);
$this->mimeCallback = isset($config['mimeCallback']) ? $config['mimeCallback'] : function ($storagePath, $content, $fsPath) {
// @todo handle the case of extension-less files using the contents
return StreamFile::contentTypeFromPath($storagePath) ?: 'unknown/unknown';
};
$this->memCache = WANObjectCache::newEmpty();
// disabled by default
$this->cheapCache = new ProcessCacheLRU(self::CACHE_CHEAP_SIZE);
$this->expensiveCache = new ProcessCacheLRU(self::CACHE_EXPENSIVE_SIZE);
}
示例8: __construct
/**
* Construct a proxy backend that consists of several internal backends.
* Locking, journaling, and read-only checks are handled by the proxy backend.
*
* Additional $config params include:
* - backends : Array of backend config and multi-backend settings.
* Each value is the config used in the constructor of a
* FileBackendStore class, but with these additional settings:
* - class : The name of the backend class
* - isMultiMaster : This must be set for one backend.
* - template: : If given a backend name, this will use
* the config of that backend as a template.
* Values specified here take precedence.
* - syncChecks : Integer bitfield of internal backend sync checks to perform.
* Possible bits include the FileBackendMultiWrite::CHECK_* constants.
* There are constants for SIZE, TIME, and SHA1.
* The checks are done before allowing any file operations.
* - autoResync : Automatically resync the clone backends to the master backend
* when pre-operation sync checks fail. This should only be used
* if the master backend is stable and not missing any files.
* Use "conservative" to limit resyncing to copying newer master
* backend files over older (or non-existing) clone backend files.
* Cases that cannot be handled will result in operation abortion.
* - noPushQuickOps : (hack) Only apply doQuickOperations() to the master backend.
* - noPushDirConts : (hack) Only apply directory functions to the master backend.
*
* @param Array $config
* @throws MWException
*/
public function __construct( array $config ) {
parent::__construct( $config );
$this->syncChecks = isset( $config['syncChecks'] )
? $config['syncChecks']
: self::CHECK_SIZE;
$this->autoResync = isset( $config['autoResync'] )
? $config['autoResync']
: false;
$this->noPushQuickOps = isset( $config['noPushQuickOps'] )
? $config['noPushQuickOps']
: false;
$this->noPushDirConts = isset( $config['noPushDirConts'] )
? $config['noPushDirConts']
: array();
// Construct backends here rather than via registration
// to keep these backends hidden from outside the proxy.
$namesUsed = array();
foreach ( $config['backends'] as $index => $config ) {
if ( isset( $config['template'] ) ) {
// Config is just a modified version of a registered backend's.
// This should only be used when that config is used only by this backend.
$config = $config + FileBackendGroup::singleton()->config( $config['template'] );
}
$name = $config['name'];
if ( isset( $namesUsed[$name] ) ) { // don't break FileOp predicates
throw new MWException( "Two or more backends defined with the name $name." );
}
$namesUsed[$name] = 1;
// Alter certain sub-backend settings for sanity
unset( $config['readOnly'] ); // use proxy backend setting
unset( $config['fileJournal'] ); // use proxy backend journal
$config['wikiId'] = $this->wikiId; // use the proxy backend wiki ID
$config['lockManager'] = 'nullLockManager'; // lock under proxy backend
if ( !empty( $config['isMultiMaster'] ) ) {
if ( $this->masterIndex >= 0 ) {
throw new MWException( 'More than one master backend defined.' );
}
$this->masterIndex = $index; // this is the "master"
$config['fileJournal'] = $this->fileJournal; // log under proxy backend
}
// Create sub-backend object
if ( !isset( $config['class'] ) ) {
throw new MWException( 'No class given for a backend config.' );
}
$class = $config['class'];
$this->backends[$index] = new $class( $config );
}
if ( $this->masterIndex < 0 ) { // need backends and must have a master
throw new MWException( 'No master backend defined.' );
}
}
示例9: __construct
/**
* Construct a proxy backend that consists of several internal backends.
* Locking, journaling, and read-only checks are handled by the proxy backend.
*
* Additional $config params include:
* - backends : Array of backend config and multi-backend settings.
* Each value is the config used in the constructor of a
* FileBackendStore class, but with these additional settings:
* - class : The name of the backend class
* - isMultiMaster : This must be set for one backend.
* - readAffinity : Use this for reads without 'latest' set.
* - syncChecks : Integer bitfield of internal backend sync checks to perform.
* Possible bits include the FileBackendMultiWrite::CHECK_* constants.
* There are constants for SIZE, TIME, and SHA1.
* The checks are done before allowing any file operations.
* - autoResync : Automatically resync the clone backends to the master backend
* when pre-operation sync checks fail. This should only be used
* if the master backend is stable and not missing any files.
* Use "conservative" to limit resyncing to copying newer master
* backend files over older (or non-existing) clone backend files.
* Cases that cannot be handled will result in operation abortion.
* - replication : Set to 'async' to defer file operations on the non-master backends.
* This will apply such updates post-send for web requests. Note that
* any checks from "syncChecks" are still synchronous.
*
* @param array $config
* @throws FileBackendError
*/
public function __construct(array $config)
{
parent::__construct($config);
$this->syncChecks = isset($config['syncChecks']) ? $config['syncChecks'] : self::CHECK_SIZE;
$this->autoResync = isset($config['autoResync']) ? $config['autoResync'] : false;
$this->asyncWrites = isset($config['replication']) && $config['replication'] === 'async';
// Construct backends here rather than via registration
// to keep these backends hidden from outside the proxy.
$namesUsed = [];
foreach ($config['backends'] as $index => $config) {
$name = $config['name'];
if (isset($namesUsed[$name])) {
// don't break FileOp predicates
throw new LogicException("Two or more backends defined with the name {$name}.");
}
$namesUsed[$name] = 1;
// Alter certain sub-backend settings for sanity
unset($config['readOnly']);
// use proxy backend setting
unset($config['fileJournal']);
// use proxy backend journal
unset($config['lockManager']);
// lock under proxy backend
$config['domainId'] = $this->domainId;
// use the proxy backend wiki ID
if (!empty($config['isMultiMaster'])) {
if ($this->masterIndex >= 0) {
throw new LogicException('More than one master backend defined.');
}
$this->masterIndex = $index;
// this is the "master"
$config['fileJournal'] = $this->fileJournal;
// log under proxy backend
}
if (!empty($config['readAffinity'])) {
$this->readIndex = $index;
// prefer this for reads
}
// Create sub-backend object
if (!isset($config['class'])) {
throw new InvalidArgumentException('No class given for a backend config.');
}
$class = $config['class'];
$this->backends[$index] = new $class($config);
}
if ($this->masterIndex < 0) {
// need backends and must have a master
throw new LogicException('No master backend defined.');
}
if ($this->readIndex < 0) {
$this->readIndex = $this->masterIndex;
// default
}
}