We extend the container because it allows us to document properties in the PhpDoc, which assists IDEs to auto-complete properties and understand the types returned. Extension allows us to keep the container generic.
Inheritance: extends Elgg\Di\DiContainer
Ejemplo n.º 1
0
 /**
  * Bootstraps test suite
  *
  * @global stdClass $CONFIG Global config
  * @global stdClass $_ELGG  Global vars
  * @return void
  */
 public static function bootstrap()
 {
     date_default_timezone_set('America/Los_Angeles');
     error_reporting(E_ALL | E_STRICT);
     $config = new Config((object) self::getTestingConfigArray());
     $sp = new ServiceProvider($config);
     $sp->setFactory('plugins', function (ServiceProvider $c) {
         $pool = new InMemory();
         return new TestingPlugins($pool, $c->pluginSettingsCache);
     });
     $sp->setValue('mailer', new InMemoryTransport());
     $sp->siteSecret->setTestingSecret('z1234567890123456789012345678901');
     // persistentLogin service needs this set to instantiate without calling DB
     $sp->config->getCookieConfig();
     $app = new Application($sp);
     Application::setTestingApplication(true);
     Application::$_instance = $app;
     // loadCore bails on repeated calls, so we need to manually inject this to make
     // sure it happens before each test.
     $app->loadCore();
     _elgg_services($sp);
     // Invalidate memcache
     _elgg_get_memcache('new_entity_cache')->clear();
     self::$_mocks = null;
     // reset mocking service
 }
Ejemplo n.º 2
0
 /**
  * Allow plugins to rewrite the path.
  *
  * @return void
  */
 private function allowPathRewrite()
 {
     $request = $this->services->request;
     $new = $this->services->router->allowRewrite($request);
     if ($new === $request) {
         return;
     }
     $this->services->setValue('request', $new);
     _elgg_set_initial_context($new);
 }