Beispiel #1
0
 function registry($key, $object = null)
 {
     if ($object !== null) {
         return Registry::set($object, $key);
     }
     return Registry::get($key);
 }
Beispiel #2
0
 /**
  * Test that removing a registered object returns a correct boolean.
  */
 public function testRemove()
 {
     for ($i = 1; $i <= 10; $i++) {
         Registry::set(new Base(), 'key' . $i);
     }
     $this->assertTrue(Registry::has('key1'));
     $this->assertTrue(Registry::has('key4'));
     $this->assertTrue(Registry::has('key8'));
     Registry::remove('key1');
     Registry::remove('key4');
     Registry::remove('key8');
     $this->assertFalse(Registry::has('key1'));
     $this->assertFalse(Registry::has('key4'));
     $this->assertFalse(Registry::has('key8'));
 }
Beispiel #3
0
define('MODULES_DIR', APP_DIR . 'modules' . DS);
define('RESOURCES_DIR', APP_DIR . 'resources' . DS);
define('TEMP_DIR', APP_DIR . 'temp' . DS);
define('VIEWS_DIR', APP_DIR . 'views' . DS);
define('WEB_DIR', APP_DIR . 'web' . DS);
/**
 * --------------------------------------------------------------
 *  Composer Autoloader
 * --------------------------------------------------------------
 *
 * Make use of Composers built-in autoloader for all classes and
 * vendor libraries used in the application. Store a reference
 * to composer in case we need to modify the loader.
 */
$composer = (require_once VENDOR_DIR . 'autoload.php');
Registry::set($composer, 'titon.composer');
/**
 * --------------------------------------------------------------
 *  Application Bootstrap
 * --------------------------------------------------------------
 *
 * Now it's time to start the application. We can do this by
 * instantiating a new Application object. We'll use a multiton
 * so that we can access the Application object statically.
 * Lastly, pass in a Request and Response object as constructor
 * parameters, which will be passed down to child classes.
 */
$app = Application::getInstance('default', [new Request(), new Response()]);
/**
 * Bootstrap the application with configuration.
 * Order here is extremely critical, do not change!
Beispiel #4
0
 /**
  * Set an object to use throughout the application.
  *
  * @param string $key
  * @param object $object
  * @return $this
  */
 public function set($key, $object)
 {
     $this->_components[$key] = Registry::set($object);
     return $this;
 }