add() публичный статический Метод

The add() method registers a named library configuration to your application, and is used to allow the framework to auto-load classes on an as-needed basis. ### Adding libraries to your application In Lithium, libraries represent the broadest unit of class organization in an application, and _everything_ is a library; this includes your application, and the Lithium framework itself. Libraries can also be other frameworks, like Solar, Zend Framework or PEAR, or Lithium plugins, which are simply libraries that follow the same organizational standards as Lithium applications. By convention, libraries are placed in the libraries directory inside your application, or the root libraries directory at the top level of the default distribution (i.e. the one that contains the lithium directory), however, you can change this on a case-by-case basis using the 'path' key to specify an absolute path to the library's directory.
public static add ( string $name, array $config = [] ) : array
$name string Library name, i.e. `'app'`, `'lithium'`, `'pear'` or `'aura'`.
$config array Specifies where the library is in the filesystem, and how classes should be loaded from it. Allowed keys are: - `'bootstrap'` _mixed_: A file path (relative to `'path'`) to a bootstrap script that should be run when the library is added, or `true` to use the default bootstrap path, i.e. `config/bootstrap.php`. - `'defer'` _boolean_: If `true`, indicates that, when locating classes, this library should defer to other libraries in order of preference. - `'includePath'` _mixed_: If `true`, appends the absolutely-resolved value of `'path'` to the PHP include path. If a string, the value is appended to PHP's. - `'loader'`: An auto-loader method associated with the library, if any. - `'path'`: The directory containing the library. - `'prefix'` _string_: The class prefix this library uses, i.e. `'lithium\'`, `'Zend_'` or `'Solar_'`. If the library has no global prefix, set to `false`. - `'suffix'` _string_: Gets appended to the end of the file name. For example, most libraries end classes in `'.php'`, but some use `'.class.php'`, or `'.inc.php'`. - `'transform'` _\Closure_: Defines a custom way to transform a class name into its corresponding file path. Accepts either an array of two strings which are interpreted as the pattern and replacement for a regex, or an anonymous function, which receives the class name and library configuration arrays as parameters, and returns the full physical file path as output. - `'resources'` _string_: If this is the default library, this maybe set to the absolute path to the write-enabled application resources directory, which is used for caching, log files, uploads, etc.
Результат array Returns the resulting set of options created for this library.
Пример #1
0
 public function tearDown()
 {
     $_SERVER = $this->_backup['_SERVER'];
     chdir($this->_backup['cwd']);
     Libraries::add('app', $this->_backup['app']);
     $this->_cleanUp();
 }
Пример #2
0
 public function testConfig()
 {
     $oldConfig = Libraries::get('li3_facebook');
     Libraries::remove('li3_facebook');
     Libraries::add('li3_facebook');
     FacebookProxy::$_autoConfigure = false;
     FacebookProxy::__init();
     $this->assertEqual(FacebookProxy::config(), array(), 'config should be empty.');
     $this->assertEqual(FacebookProxy::config(array()), array(), 'config should be empty.');
     //check ignoring
     FacebookProxy::reset();
     $result = FacebookProxy::config(array('foo'));
     $this->assertTrue($result, array(), 'config should return true');
     $this->assertIdentical(FacebookProxy::config(), array(), 'config should be empty');
     //check ingoring vs. existing but unset associations
     FacebookProxy::reset();
     $result = FacebookProxy::config(array('appId'));
     $this->assertTrue($result, array(), 'config should return true');
     $this->assertIdentical(FacebookProxy::config(), array(), 'config should be empty');
     //check valid Settings
     FacebookProxy::reset();
     $sampleConfig = array('appId' => 'hello');
     $result = FacebookProxy::config($sampleConfig);
     $this->assertTrue($result, 'config should return true');
     $this->assertIdentical(FacebookProxy::config(), $sampleConfig, 'config should not be empty');
     //check vs. complete Settings
     FacebookProxy::reset();
     $result = FacebookProxy::config($this->_mockDefaults);
     $this->assertTrue($result, 'config should return true');
     $this->assertIdentical(FacebookProxy::config(), $this->_mockDefaults, 'config should not be empty');
     Libraries::remove('li3_facebook');
     Libraries::add('li3_facebook', $oldConfig);
     //FaceBookProxy::foo();
     //die(print_r(array($result,FacebookProxy::config()),true));
 }
Пример #3
0
	public function setUp() {
		$this->_backup['cwd'] = getcwd();
		$this->_backup['_SERVER'] = $_SERVER;
		$_SERVER['argv'] = array();

		chdir($this->_testPath);

		Libraries::add('library_test', array(
			'path' => $this->_testPath . '/library_test', 'bootstrap' => false
		));

		Libraries::add('library_test_plugin', array(
			'path' => $this->_testPath . '/library_test_plugin'
		));

		$this->classes = array(
			'service' => 'lithium\tests\mocks\console\command\MockLibraryService',
			'response' => 'lithium\tests\mocks\console\MockResponse'
		);
		$this->request = new Request(array('input' => fopen('php://temp', 'w+')));
		$this->library = new Library(array(
			'request' => $this->request, 'classes' => $this->classes
		));
		$this->testConf = $this->library->conf = $this->_testPath . '/library.json';
	}
Пример #4
0
 /**
  * instantiates and returns instance of neon-renderer
  *
  * @return object instance of NeonRenderer
  */
 public static function renderer()
 {
     if (is_null(static::$_renderer)) {
         Libraries::add('Neon', array('path' => RADIUM_PATH . '/libraries/neon'));
         static::$_renderer = new NeonRenderer();
     }
     return static::$_renderer;
 }
Пример #5
0
 public function tearDown()
 {
     foreach ($this->_superglobals as $varname) {
         $GLOBALS[$varname] = $this->_env[$varname];
     }
     Libraries::remove('app');
     Libraries::add($this->_library['name'], $this->_library);
     $this->_cleanUp();
 }
Пример #6
0
 public function testShouldRunSetsLibraryConfig()
 {
     $config = $this->selfConfig;
     unset($config['shouldRun']);
     Libraries::add('li3_newrelic', $this->selfConfig);
     $result = NewrelicMock::shouldRun();
     $config = Libraries::get('li3_newrelic');
     $this->assertArrayHasKey('shouldRun', $config);
     $this->assertInternalType('bool', $result);
 }
 public function setUp()
 {
     $this->_backup['cwd'] = getcwd();
     $this->_backup['_SERVER'] = $_SERVER;
     $_SERVER['argv'] = array();
     Libraries::add('create_test', array('path' => $this->_testPath . '/create_test'));
     $this->request = new Request(array('input' => fopen('php://temp', 'w+')));
     $this->request->params = array('library' => 'create_test', 'action' => null);
     Connections::add('default', array('type' => null, 'adapter' => 'lithium\\tests\\mocks\\data\\model\\MockDatabase'));
 }
Пример #8
0
 public function setUp()
 {
     $this->classes = array('response' => 'lithium\\tests\\mocks\\console\\MockResponse');
     $this->_backup['cwd'] = getcwd();
     $this->_backup['_SERVER'] = $_SERVER;
     $_SERVER['argv'] = array();
     Libraries::add('create_test', array('path' => $this->_testPath . '/create_test'));
     $this->request = new Request(array('input' => fopen('php://temp', 'w+')));
     $this->request->params = array('library' => 'create_test');
 }
Пример #9
0
 /**
  *
  * Determines if we should run any `newrelic_` methods.
  *
  * If the configuration for the plugin `shouldRun` does not exist, set
  * a generic one.
  *
  * @return bool
  */
 public static function shouldRun()
 {
     if (!is_callable(Libraries::get('li3_newrelic', 'shouldRun'))) {
         $config = Libraries::get('li3_newrelic');
         $config['shouldRun'] = function () {
             return Environment::is('production') && extension_loaded('newrelic');
         };
         Libraries::add('li3_newrelic', $config);
     }
     return Libraries::get('li3_newrelic', 'shouldRun')->__invoke();
 }
Пример #10
0
 public function testEmptyConfig()
 {
     $oldConfig = Libraries::get('li3_facebook');
     $subject = new Facebook();
     //disable validation inside the proxy
     FacebookProxy::$_validateConfiguration = false;
     Libraries::remove('li3_facebook');
     Libraries::add('li3_facebook');
     $this->expectException('Configuration: `appId` should be set');
     $this->assertTrue($subject->check($this->request));
     Libraries::remove('li3_facebook');
     Libraries::add('li3_facebook', $oldConfig);
 }
Пример #11
0
 public function setUp()
 {
     $this->_backup['cwd'] = getcwd();
     $this->_backup['_SERVER'] = $_SERVER;
     $_SERVER['argv'] = array();
     $this->_testPath = LITHIUM_APP_PATH . '/resources/tmp/tests';
     chdir($this->_testPath);
     Libraries::add('library_test', array('path' => $this->_testPath . '/library_test'));
     Libraries::add('plugin', array('library_test_plugin' => array('path' => $this->_testPath . '/library_test_plugin')));
     $this->classes = array('service' => '\\lithium\\tests\\mocks\\console\\command\\MockLibraryService', 'response' => '\\lithium\\tests\\mocks\\console\\MockResponse');
     $this->request = new Request(array('input' => fopen('php://temp', 'w+')));
     $this->library = new Library(array('request' => $this->request, 'classes' => $this->classes));
     $this->library->conf = $this->_conf = $this->_testPath . '/library.json';
 }
Пример #12
0
<?php

/**
 * Lithium: the most rad php framework
 *
 * @copyright     Copyright 2009, Union of RAD (http://union-of-rad.org)
 * @license       http://opensource.org/licenses/bsd-license.php The BSD License
 */
use lithium\core\Libraries;
/**
 * Add the `phpca` library.
 */
Libraries::add('phpca', array('prefix' => 'spriebsch\\PHPca\\', 'path' => dirname(__DIR__) . '/libraries/phpca/src', 'bootstrap' => 'Autoload.php'));
Пример #13
0
<?php

define('LITHIUM_LIBRARY_PATH', 'phar://lithium.phar');
if (!(include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php')) {
    $message = "Lithium core could not be found.  Check the value of LITHIUM_LIBRARY_PATH.";
    throw new ErrorException($message);
}
use lithium\core\Libraries;
Libraries::add('lithium');
Пример #14
0
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Message.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Media.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Request.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Response.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Route.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Router.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Controller.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Dispatcher.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Request.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Response.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/View.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Renderer.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Compiler.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/adapter/File.php';
require LITHIUM_LIBRARY_PATH . '/lithium/storage/Cache.php';
require LITHIUM_LIBRARY_PATH . '/lithium/storage/cache/adapter/Apc.php';
/**
 * Add the Lithium core library.  This sets default paths and initializes the autoloader.  You
 * generally should not need to override any settings.
 */
Libraries::add('lithium');
/**
 * Add the application.  You can pass a `'path'` key here if this bootstrap file is outside of
 * your main application, but generally you should not need to change any settings.
 */
Libraries::add('app', array('default' => true));
/**
 * Add some plugins
 */
Libraries::add('li3_twig', array('bootstrap' => true));
Пример #15
0
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Route.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Router.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Controller.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Dispatcher.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Request.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Response.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/View.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Renderer.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Compiler.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/adapter/File.php';
require LITHIUM_LIBRARY_PATH . '/lithium/storage/Cache.php';
require LITHIUM_LIBRARY_PATH . '/lithium/storage/cache/adapter/Apc.php';
/**
 * Add the Lithium core library.  This sets default paths and initializes the autoloader.  You
 * generally should not need to override any settings.
 */
Libraries::add('lithium');
/**
 * Add the application.  You can pass a `'path'` key here if this bootstrap file is outside of
 * your main application, but generally you should not need to change any settings.
 */
Libraries::add('app', array('default' => true));
/**
 * Add some plugins:
 */
//Libraries::add('li3_show');
Libraries::add('li3_qrcode');
Libraries::add('li3_pdf');
Libraries::add('jpgraph', array('bootstrap' => 'jpgraph_required.php'));
Libraries::add('swiftmailer', array('bootstrap' => 'swift_required.php'));
Пример #16
0
 public function testPathWithCustomDirectoryName()
 {
     $testApp = Libraries::get(true, 'resources') . '/tmp/tests/custom_dir';
     $testDir = $testApp . '/tests/cases/models';
     mkdir($testDir, 0777, true);
     Libraries::add('test_app', array('path' => $testApp));
     $request = new Request(array('env' => array('working' => $testApp)));
     $command = new Test(array('request' => $request, 'classes' => $this->classes));
     $expected = 'test_app\\tests\\cases\\models';
     $result = $command->invokeMethod('_path', array('tests\\cases\\models'));
     $this->assertIdentical($expected, $result);
     Libraries::remove('test_app');
     $this->_cleanUp();
 }
Пример #17
0
 public function testGetLibraryWebroot()
 {
     $this->assertNull(Media::webroot('foobar'));
     Libraries::add('foobar', array('path' => __DIR__, 'webroot' => __DIR__));
     $this->assertEqual(__DIR__, Media::webroot('foobar'));
     Libraries::remove('foobar');
     $resources = Libraries::get(true, 'resources');
     $webroot = "{$resources}/media_test/webroot";
     $this->skipIf(!is_writable($resources), "Cannot write test app to resources directory.");
     if (!is_dir($webroot)) {
         mkdir($webroot, 0777, true);
     }
     Libraries::add('media_test', array('path' => "{$resources}/media_test"));
     $this->assertFileExists(Media::webroot('media_test'));
     Libraries::remove('media_test');
     rmdir($webroot);
 }
Пример #18
0
 public function testContextWithElementRenderingOptions()
 {
     $tmpDir = realpath(Libraries::get(true, 'resources') . '/tmp');
     $this->skipIf(!is_writable($tmpDir), "Can't write to resources directory.");
     $testApp = $tmpDir . '/tests/test_app';
     $viewDir = $testApp . '/views';
     mkdir($viewDir . '/elements', 0777, true);
     Libraries::add('test_app', array('path' => $testApp));
     $testApp2 = $tmpDir . '/tests/test_app2';
     $viewDir2 = $testApp2 . '/views';
     mkdir($viewDir2 . '/elements', 0777, true);
     Libraries::add('test_app2', array('path' => $testApp2));
     $body = "<?php ";
     $body .= "echo \$this->_render('element', 'element2', array(), ";
     $body .= "array('library' => 'test_app2'));";
     $body .= "echo \$this->_render('element', 'element1');";
     $body .= "?>";
     file_put_contents($viewDir . '/template.html.php', $body);
     file_put_contents($viewDir . '/elements/element1.html.php', 'element1');
     file_put_contents($viewDir2 . '/elements/element2.html.php', 'element2');
     $view = new View(array('compile' => false, 'paths' => array('template' => '{:library}/views/{:template}.html.php', 'element' => '{:library}/views/elements/{:template}.html.php', 'layout' => false)));
     $options = array('template' => 'template', 'library' => 'test_app');
     $result = $view->render('all', array(), $options);
     $this->assertIdentical('element2element1', $result);
     $body = "<?php ";
     $body .= "echo \$this->_render('element', 'element1');";
     $body .= "echo \$this->_render('element', 'element2', array(), ";
     $body .= "array('library' => 'test_app2'));";
     $body .= "?>";
     file_put_contents($viewDir . '/template.html.php', $body);
     $result = $view->render('all', array(), $options);
     $this->assertIdentical('element1element2', $result);
     Libraries::remove('test_app');
     Libraries::remove('test_app2');
     $this->_cleanUp();
 }
Пример #19
0
<?php

use lithium\core\Libraries;
use lithium\action\Dispatcher;
use lithium\net\http\Media;
use li3_amf\extensions\media\Amf;
/*
*	Load Zend Framework Libraries (for AMF encoding and decoding).
* 	http://rad-dev.org/lithium/wiki/guides/using/zend
* 
* 	'path' should be set to the location of the Zend folder.
* 	'includePath' should be set to the loation of folder containing the Zend folder.
* 
*/
if (!Libraries::get('Zend')) {
    Libraries::add("Zend", array("prefix" => "Zend_", 'path' => '/Library/Webserver/Documents/lithium/libraries/Zend', "includePath" => '/Library/Webserver/Documents/lithium/libraries', "bootstrap" => "Loader/Autoloader.php", "loader" => array("Zend_Loader_Autoloader", "autoload"), "transform" => function ($class) {
        return str_replace("_", "/", $class) . ".php";
    }));
}
/**
 * Declare AMF media type.
 */
Media::type('amf', 'application/x-amf', array('decode' => function ($data) {
    $amf = new Amf();
    $response = $amf->processResponseBodies();
    $response->finalize();
    die(print_r(debug_backtrace(), 1));
    return $response;
}, 'encode' => function ($data) {
    return $data;
}, 'view' => false));
Пример #20
0
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Media.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Request.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Response.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Route.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Router.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Controller.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Dispatcher.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Request.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Response.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/View.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Renderer.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Compiler.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/adapter/File.php';
require LITHIUM_LIBRARY_PATH . '/lithium/storage/Cache.php';
require LITHIUM_LIBRARY_PATH . '/lithium/storage/cache/adapter/Apc.php';
/**
 * Add the Lithium core library.  This sets default paths and initializes the autoloader.  You
 * generally should not need to override any settings.
 */
Libraries::add('lithium');
/**
 * Add the application.  You can pass a `'path'` key here if this bootstrap file is outside of
 * your main application, but generally you should not need to change any settings.
 */
Libraries::add('app', array('default' => true));
/**
 * Add some plugins:
 */
// Libraries::add('li3_docs');
Libraries::add('li3_less');
Пример #21
0
<?php

use lithium\core\Libraries;
Libraries::add('lightopenid', array('path' => LITHIUM_LIBRARY_PATH . '/li3_openid_auth/libraries/lightopenid', 'prefix' => null));
Пример #22
0
<?php

use lithium\core\Libraries;
use lithium\core\ConfigException;
use lithium\template\View;
use lithium\net\http\Media;
use lithium\util\Set;
// Define path to plugin and other constants
defined('SMARTY_VERSION') or define('SMARTY_VERSION', '3.1.10');
// Allows us to test different versions without breaking things
defined('LI3_SMARTY_PATH') or define('LI3_SMARTY_PATH', dirname(__DIR__));
defined('LI3_SMARTY_LIB') or define('LI3_SMARTY_LIB', dirname(__DIR__) . "/libraries/Smarty/" . SMARTY_VERSION . "/libs/");
Libraries::add('Smarty', array("path" => LI3_SMARTY_LIB, "bootstrap" => "Smarty.class.php"));
$defaults = array('view' => '\\lithium\\template\\View', 'renderer' => '\\li3_smarty\\template\\view\\adapter\\Smarty', 'paths' => array('template' => array(LITHIUM_APP_PATH . '/views/{:controller}/{:template}.{:type}.tpl', '{:library}/views/{:controller}/{:template}.{:type}.tpl'), 'element' => array(LITHIUM_APP_PATH . '/views/elements/{:template}.html.tpl', '{:library}/views/elements/{:template}.html.tpl'), 'layout' => false), 'compile_dir' => LITHIUM_APP_PATH . '/resources/templates_c', 'cache_dir' => LITHIUM_APP_PATH . '/resources/cache', 'template_dir' => array(LITHIUM_APP_PATH . "/views", LITHIUM_APP_PATH . "/views/pages"), 'plugin_dir' => array(LI3_SMARTY_PATH . "/plugins", LITHIUM_APP_PATH . "/extensions/plugins"));
$keys = array_intersect_key($config, $defaults);
foreach ($keys as $key => $val) {
    if (is_array($defaults[$key])) {
        $defaults[$key] = Set::merge($defaults[$key], $config[$key]);
    } else {
        $defaults[$key] = $val;
    }
}
/**
 * Map to the new renderer
 */
Media::type('default', null, $defaults);
Пример #23
0
<?php

/**
 * Orchestra.io Bootstap for Lithium
 *
 * add `require __DIR__ . '/bootstrap/orchestra.php';` immediately after
 * `require __DIR__ . '/bootstrap/libraries.php';` in bootstrap.php
 */
use lithium\core\Libraries;
Libraries::add('app', array('default' => true, 'resources' => call_user_func(function () {
    if (!is_dir($resources = str_replace("//", "/", sys_get_temp_dir() . '/resources'))) {
        foreach (array($resources, "{$resources}/logs", "{$resources}/tmp/cache/templates") as $d) {
            mkdir($d, 0777, true);
        }
    }
    return $resources;
})));
Пример #24
0
 public function testRunGroupForTestAppModel()
 {
     $testApp = Libraries::get(true, 'resources') . '/tmp/tests/test_app';
     mkdir($testApp);
     Libraries::add('test_app', array('path' => $testApp));
     mkdir($testApp . '/tests/cases/models', 0777, true);
     file_put_contents($testApp . '/tests/cases/models/UserTest.php', "<?php namespace test_app\\tests\\cases\\models;\n\n\t\t\tclass UserTest extends \\lithium\\test\\Unit { public function testMe() {\n\t\t\t\t\$this->assertTrue(true);\n\t\t\t}}");
     Libraries::cache(false);
     $group = new Group(array('data' => array('\\test_app\\tests\\cases')));
     $expected = array('test_app\\tests\\cases\\models\\UserTest');
     $result = $group->to('array');
     $this->assertEqual($expected, $result);
     $expected = 'pass';
     $result = $group->tests()->run();
     $this->assertEqual($expected, $result[0][0]['result']);
     Libraries::cache(false);
     $this->_cleanUp();
 }
Пример #25
0
require LITHIUM_LIBRARY_PATH . '/lithium/core/Environment.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/Message.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Message.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Media.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Request.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Response.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Route.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Router.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Controller.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Dispatcher.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Request.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Response.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/View.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Renderer.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Compiler.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/adapter/File.php';
require LITHIUM_LIBRARY_PATH . '/lithium/storage/Cache.php';
require LITHIUM_LIBRARY_PATH . '/lithium/storage/cache/adapter/Apc.php';
/**
 * Add the Lithium core library.  This sets default paths and initializes the autoloader.  You
 * generally should not need to override any settings.
 */
Libraries::add('lithium');
/**
 * Add the application.  You can pass a `'path'` key here if this bootstrap file is outside of
 * your main application, but generally you should not need to change any settings.
 */
Libraries::add('app', array('default' => true));
Libraries::add('li3_flash_message');
Libraries::add('li3_mailer');
Пример #26
0
 /**
  * Tests that `Libraries::map()` and `Libraries::unmap()`
  *
  */
 public function testMapUnmap()
 {
     $testApp = Libraries::get(true, 'resources') . '/tmp/tests/test_app';
     mkdir($testApp, 0777, true);
     Libraries::add('test_app', array('path' => $testApp));
     mkdir($testApp . '/lib', 0777);
     mkdir($testApp . '/_patch', 0777);
     file_put_contents($testApp . '/lib/LibTest.php', "<?php namespace test_app\\lib;\n\n\t\t\tclass LibTest{ public function testMe() {\n\t\t\t\treturn 'core class';\n\t\t\t}}");
     file_put_contents($testApp . '/_patch/PatchedLibTest.php', "<?php namespace test_app\\lib;\n\n\t\t\tclass LibTest{ public function testMe() {\n\t\t\t\treturn 'patched class';\n\t\t\t}}");
     $expected = $result = Libraries::realPath($testApp . '/lib/LibTest.php');
     $result = Libraries::path('test_app\\lib\\LibTest');
     $this->assertEqual($expected, $result);
     Libraries::map(array('test_app\\lib\\LibTest' => $testApp . '/_patch/PatchedLibTest.php'));
     $expected = $result = Libraries::realPath($testApp . '/_patch/PatchedLibTest.php');
     $result = Libraries::path('test_app\\lib\\LibTest');
     Libraries::unmap(array('test_app\\lib\\LibTest'));
     $expected = $result = Libraries::realPath($testApp . '/lib/LibTest.php');
     $result = Libraries::path('test_app\\lib\\LibTest');
     $this->assertEqual($expected, $result);
     Libraries::map(array('test_app\\lib\\LibTest' => $testApp . '/_patch/PatchedLibTest.php'));
     Libraries::unmap('test_app\\lib\\LibTest');
     $expected = $result = Libraries::realPath($testApp . '/lib/LibTest.php');
     $result = Libraries::path('test_app\\lib\\LibTest');
     Libraries::map(array('test_app\\lib\\LibTest' => $testApp . '/_patch/PatchedLibTest.php'));
     $object = new \test_app\lib\LibTest();
     $result = $object->testMe();
     $this->assertEqual('patched class', $result);
     $this->_cleanUp();
 }
Пример #27
0
 public function testGetLibraryWebroot()
 {
     $this->assertTrue(is_dir(Media::webroot(true)));
     $this->assertNull(Media::webroot('foobar'));
     Libraries::add('foobar', array('path' => __DIR__, 'webroot' => __DIR__));
     $this->assertEqual(__DIR__, Media::webroot('foobar'));
     Libraries::remove('foobar');
 }
Пример #28
0
/**
 * Locate and load Lithium core library files.  Throws a fatal error if the core can't be found.
 * If your Lithium core directory is named something other than `lithium`, change the string below.
 */
if (!(include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php')) {
    $message = "Lithium core could not be found.  Check the value of LITHIUM_LIBRARY_PATH in ";
    $message .= __FILE__ . ".  It should point to the directory containing your ";
    $message .= "/libraries directory.";
    throw new ErrorException($message);
}
use lithium\core\Libraries;
use lithium\data\Connections;
/**
 * Add the Lithium core library.  This sets default paths and initializes the autoloader.  You
 * generally should not need to override any settings.
 */
Libraries::add('lithium');
/**
 * Add the application.  You can pass a `'path'` key here if this bootstrap file is outside of
 * your main application, but generally you should not need to change any settings.
 */
Libraries::add('li3_tree', ['default' => true]);
/**
 * Load test dependencies
 */
Libraries::add('li3_behaviors');
Libraries::add('li3_fixtures');
/**
 * Setup test database
 */
Connections::add('test', ['type' => 'database', 'adapter' => 'MySql', 'host' => 'localhost', 'login' => 'root', 'password' => '', 'database' => 'li3tree_test', 'encoding' => 'UTF-8']);
Пример #29
0
require LITHIUM_LIBRARY_PATH . '/lithium/net/Message.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Message.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Media.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Request.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Response.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Route.php';
require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Router.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Controller.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Dispatcher.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Request.php';
require LITHIUM_LIBRARY_PATH . '/lithium/action/Response.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/View.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Renderer.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Compiler.php';
require LITHIUM_LIBRARY_PATH . '/lithium/template/view/adapter/File.php';
require LITHIUM_LIBRARY_PATH . '/lithium/storage/Cache.php';
require LITHIUM_LIBRARY_PATH . '/lithium/storage/cache/adapter/Apc.php';
/**
 * Add the Lithium core library.  This sets default paths and initializes the autoloader.  You
 * generally should not need to override any settings.
 */
Libraries::add('lithium');
/**
 * Add the application.  You can pass a `'path'` key here if this bootstrap file is outside of
 * your main application, but generally you should not need to change any settings.
 */
Libraries::add('app', array('default' => true));
/**
 * Add some plugins:
 */
// Libraries::add('li3_docs');
Пример #30
0
<?php

use lithium\core\Libraries;
if (!Libraries::get('li3_mandrill')) {
    Libraries::add('li3_mandrill');
}