MediaWiki  master
BlobStoreFactory.php
Go to the documentation of this file.
1 <?php
21 namespace MediaWiki\Storage;
22 
28 
37 
41  private $lbFactory;
42 
46  private $extStoreAccess;
47 
51  private $cache;
52 
56  private $options;
57 
61  private $contLang;
62 
69  public static $constructorOptions = [
70  'CompressRevisions',
71  'DefaultExternalStore',
72  'LegacyEncoding',
73  'RevisionCacheExpiry',
74  ];
75 
76  public function __construct(
82  ) {
83  $options->assertRequiredOptions( self::$constructorOptions );
84 
85  $this->lbFactory = $lbFactory;
86  $this->extStoreAccess = $extStoreAccess;
87  $this->cache = $cache;
88  $this->options = $options;
89  $this->contLang = $contLang;
90  }
91 
99  public function newBlobStore( $dbDomain = false ) {
100  return $this->newSqlBlobStore( $dbDomain );
101  }
102 
110  public function newSqlBlobStore( $dbDomain = false ) {
111  $lb = $this->lbFactory->getMainLB( $dbDomain );
112  $store = new SqlBlobStore(
113  $lb,
114  $this->extStoreAccess,
115  $this->cache,
116  $dbDomain
117  );
118 
119  $store->setCompressBlobs( $this->options->get( 'CompressRevisions' ) );
120  $store->setCacheExpiry( $this->options->get( 'RevisionCacheExpiry' ) );
121  $store->setUseExternalStore( $this->options->get( 'DefaultExternalStore' ) !== false );
122 
123  if ( $this->options->get( 'LegacyEncoding' ) ) {
124  $store->setLegacyEncoding( $this->options->get( 'LegacyEncoding' ), $this->contLang );
125  }
126 
127  return $store;
128  }
129 
130 }
Service for storing and loading Content objects.
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
__construct(ILBFactory $lbFactory, ExternalStoreAccess $extStoreAccess, WANObjectCache $cache, ServiceOptions $options, Language $contLang)
Service for instantiating BlobStores.
A class for passing options to services.
you have access to all of the normal MediaWiki so you can get a DB use the cache
Definition: maintenance.txt:52
static array $constructorOptions
TODO Make this a const when HHVM support is dropped (T192166)
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys, without regard for order.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
An interface for generating database load balancers.
Definition: ILBFactory.php:33