本文整理汇总了PHP中lithium\core\Libraries::paths方法的典型用法代码示例。如果您正苦于以下问题:PHP Libraries::paths方法的具体用法?PHP Libraries::paths怎么用?PHP Libraries::paths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\core\Libraries
的用法示例。
在下文中一共展示了Libraries::paths方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPathTemplateWithGlobBrace
public function testPathTemplateWithGlobBrace()
{
Libraries::paths(array('analysis' => array('{:library}\\analysis\\*{Docblock,Debugger}')));
$analysis = list($docblock, $debugger) = Libraries::locate('analysis', null, array('recursive' => false, 'format' => false));
$this->assertCount(2, $analysis);
$this->assertPattern('/Docblock\\.php/', $docblock);
$this->assertPattern('/Debugger\\.php/', $debugger);
}
示例2: _init
/**
* Exercise initialization.
*
* @return void
*/
public function _init()
{
parent::_init();
Libraries::paths(array('exercises' => '{:library}\\extensions\\exercises\\{:name}'));
$exercises = Libraries::locate('exercises');
foreach ($exercises as $exercise) {
$this->_exercises[$this->exerciseName($exercise)] = $exercise;
}
}
示例3: setUp
public function setUp()
{
Libraries::paths(array('models' => '{:library}\\tests\\mocks\\data\\model\\{:name}Model'));
$this->classes = array('response' => 'lithium\\tests\\mocks\\console\\MockResponse');
$this->_backup['cwd'] = getcwd();
$this->_backup['_SERVER'] = $_SERVER;
$_SERVER['argv'] = array();
$this->collection = $this->getCollection('li3_ensureindex\\tests\\mocks\\data\\model\\MockModel');
$this->collection->deleteIndexes();
}
示例4: testPathTemplate
public function testPathTemplate()
{
$expected = array('{:app}/libraries/{:name}', '{:root}/libraries/{:name}');
$result = Libraries::paths('libraries');
$this->assertEqual($expected, $result);
$this->assertNull(Libraries::locate('authAdapter', 'Form'));
$paths = Libraries::paths();
$test = array('authAdapter' => array('lithium\\security\\auth\\adapter\\{:name}'));
Libraries::paths($test);
$this->assertEqual($paths + $test, Libraries::paths());
$class = Libraries::locate('authAdapter', 'Form');
$expected = 'lithium\\security\\auth\\adapter\\Form';
$this->assertEqual($expected, $class);
}
示例5: import
public function import()
{
Libraries::paths(array('neons' => array('{:library}\\data\\{:class}\\{:name}.neon')));
$libraries = Libraries::get(null, 'name');
$data = array();
$namespaces = true;
foreach ($libraries as $library) {
$files = Libraries::locate('neons', null, compact('namespaces', 'library'));
if (!empty($files)) {
$data[$library] = $files;
}
}
return compact('data');
}
示例6: mkdir
<?php
use lithium\core\Libraries;
$path = Libraries::get(true, 'path') . '/webroot/themes/default';
if (!is_dir($path)) {
mkdir($path);
rename(Libraries::get(true, 'path') . '/views', $path . '/views');
}
$existing = Libraries::paths('helper');
Libraries::paths(array('helper' => array_merge(array('{:library}\\extensions\\helper\\{:class}\\{:name}', '{:library}\\template\\helper\\{:class}\\{:name}' => array('libraries' => 'li3_themes')), (array) $existing)));
require __DIR__ . '/bootstrap/media.php';
require __DIR__ . '/bootstrap/errors.php';
示例7: find
/**
* Loads entities and records from file-based structure
*
* Trys to implement a similar method to load datasets not from database, but rather from
* a file that holds all relevant model data and is laid into the filesystem of each library.
* This allows for easy default-data to be loaded without using a database as backend.
*
* Put your files into `{:library}\data\{:class}\{:name}.neon` and let the content be found
* with loading just the id or slug of that file.
*
* Attention: This feature is considered experimental and should be used with care. It might
* not work as expected. Also, not all features are implemented.
*
* If nothing is found, it just returns null or an empty array to ensure a falsey value.
*
* @param string|array $model fully namespaced model class, e.g. `radium\models\Contents`
* can also be an array, in which case `key` and `source` must be given
* according to the internal structure of `Model::meta()`.
* @param string $type The find type, which is looked up in `Model::$_finders`. By default it
* accepts `all`, `first`, `list` and `count`. Later two are not implement, yet.
* @param array $options Options for the query. By default, accepts:
* - `conditions`: The conditional query elements, e.g.
* `'conditions' => array('published' => true)`
* - `fields`: The fields that should be retrieved. When set to `null`, defaults to
* all fields.
* - `order`: The order in which the data will be returned, e.g. `'order' => 'ASC'`.
* - `limit`: The maximum number of records to return.
* - `page`: For pagination of data.
* @return mixed returns null or an empty array if nothing is found
* If `$type` is `first` returns null or the correct entity with given data
* If `$type` is `all` returns null or a DocumentSet object with loaded entities
*/
public static function find($model, $type, array $options = array())
{
$defaults = array('conditions' => null, 'fields' => null);
$options += $defaults;
$paths = self::$_paths;
Libraries::paths($paths);
$meta = is_array($model) ? $model : $model::meta();
$locate = sprintf('neons.%s', $meta['source']);
$data = Libraries::locate($locate, null, array('namespaces' => true));
$files = new Collection(compact('data'));
unset($data);
$files->each(function ($file) {
return str_replace('\\', '/', $file) . 'neon';
});
extract($options);
if (isset($conditions['slug'])) {
$field = 'slug';
}
if (isset($conditions[$meta['key']])) {
$field = $meta['key'];
}
if (!isset($field)) {
$field = 'all';
// var_dump($field);
// return array();
}
$value = $conditions[$field];
switch (true) {
case is_string($value):
$pattern = sprintf('/%s/', $value);
break;
case isset($value['like']):
$pattern = $value['like'];
break;
}
if (isset($pattern)) {
$filter = function ($file) use($pattern) {
return (bool) preg_match($pattern, $file);
};
}
if (isset($filter)) {
$files = $files->find($filter);
}
if (isset($order)) {
// TODO: add sort
}
if ($type == 'count') {
return count($files);
}
if ($type == 'list') {
// TODO: implement me
}
if ($type == 'first' && count($files)) {
$data = self::file($files->first());
$data[$field] = $value;
if ($model === 'radium\\models\\Configurations') {
$data['value'] = Neon::encode($data['value']);
}
return $model::create($data);
}
// we found one (!) file with name 'all.neon', this is the entire set
if ($type == 'all' && count($files) == 1 && substr($files->first(), -strlen('all.neon')) === 'all.neon') {
$rows = self::file($files->first());
$data = array();
foreach ($rows as $row) {
$data[] = $model::create($row);
}
if (is_array($model)) {
//.........这里部分代码省略.........
示例8: array
<?php
use lithium\core\Libraries;
/**
* Register paths for mail template helpers.
*/
$existing = Libraries::paths('helper');
Libraries::paths(array('helper' => array_merge(array('{:library}\\extensions\\helper\\{:class}\\{:name}', '{:library}\\template\\helper\\{:class}\\{:name}' => array('libraries' => 'li3_mailer')), (array) $existing)));
/**
* Add paths for delivery transport adapters from this library (plugin).
*/
$existing = Libraries::paths('adapter');
$key = '{:library}\\{:namespace}\\{:class}\\adapter\\{:name}';
$existing[$key]['libraries'] = array_merge((array) $existing[$key]['libraries'], (array) 'li3_mailer');
Libraries::paths(array('adapter' => $existing));
/*
* Ensure the mail template resources path exists.
*/
$path = Libraries::get(true, 'resources') . '/tmp/cache/mails';
if (!is_dir($path)) {
mkdir($path);
}
/**
* Load the file that configures the delivery system.
*/
require __DIR__ . '/bootstrap/delivery.php';
示例9: array
<?php
/**
* Lithium: the most rad php framework
*
* @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
use lithium\core\Libraries;
/**
* This adds the `'behavior'` type to the list of recognized class types. You can look up the
* behaviors available to your application by running `Libraries::locate('behavior')`.
*/
Libraries::paths(array(
'behavior' => array('{:library}\extensions\data\behavior\{:name}')
));
?>
示例10: testServiceLocateAll
public function testServiceLocateAll()
{
$result = Libraries::locate('tests');
$this->assertTrue(count($result) > 30);
$expected = array('lithium\\template\\view\\adapter\\File', 'lithium\\template\\view\\adapter\\Simple');
$result = Libraries::locate('adapter.template.view');
$this->assertEqual($expected, $result);
$result = Libraries::locate('test.filter');
$this->assertTrue(count($result) >= 4);
$this->assertTrue(in_array('lithium\\test\\filter\\Affected', $result));
$this->assertTrue(in_array('lithium\\test\\filter\\Complexity', $result));
$this->assertTrue(in_array('lithium\\test\\filter\\Coverage', $result));
$this->assertTrue(in_array('lithium\\test\\filter\\Profiler', $result));
foreach (Libraries::paths() as $type => $paths) {
if (count($paths) <= 1 || $type == 'libraries') {
continue;
}
$this->assertTrue(count(Libraries::locate($type)) > 1);
}
}
示例11: array
<?php
use lithium\core\Libraries;
Libraries::paths(array('resources' => array('{:library}\\controllers\\{:namespace}\\{:class}\\{:name}')));
Libraries::add("Mockery", array('path' => dirname(__DIR__) . '/libraries/mockery/library', 'prefix' => ''));
示例12: array
<?php
/**
* Lithium: the most rad php framework
*
* @copyright Copyright 2011, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
use lithium\core\Libraries;
use lithium\g11n\Multibyte;
Libraries::paths(array('rules' => array('{:library}\\extensions\\qa\\rules\\{:class}\\{:name}', '{:library}\\qa\\rules\\{:class}\\{:name}' => array('libraries' => 'li3_quality'))));
Multibyte::config(array('li3_quality' => array('adapter' => 'Mbstring')));
示例13: dirname
<?php
use lithium\core\Libraries;
define('LI3_RESQUE_PATH', dirname(__DIR__));
define('LI3_RESQUE_LIB_PATH', LI3_RESQUE_PATH . '/libraries/Resque');
// load up third party lib
// Libraries::add('resque', array(
// 'path' => LI3_RESQUE_LIB_PATH,
// 'prefix' => false,
// 'transform' => function($class, $config) {
// $class = str_replace("_", "/", $class);
// return "{$config['path']}/{$class}{$config['suffix']}";
// }
// ));
if (Libraries::paths('job') === null) {
Libraries::paths(array('job' => '{:library}\\extensions\\job\\{:name}'));
}
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require __DIR__ . '/../vendor/autoload.php';
}
示例14: array
<?php
use lithium\core\Libraries;
// Adapters nested under security/access/adapters instead
// of under extensions until core has the paths changed.
Libraries::paths(array('adapter' => array_merge(Libraries::paths('adapter'), array('{:library}\\{:namespace}\\{:class}\\adapter\\{:name}'))));
示例15: testPathTemplateWithGlobBrace
/**
* @deprecated
*/
public function testPathTemplateWithGlobBrace()
{
error_reporting(($original = error_reporting()) & ~E_USER_DEPRECATED);
Libraries::paths(array('analysis' => array('{:library}\\analysis\\*{Docblock,Debugger}')));
$analysis = list($docblock, $debugger) = Libraries::locate('analysis', null, array('recursive' => false, 'format' => false));
$this->assertCount(2, $analysis);
$this->assertPattern('/Docblock\\.php/', $docblock);
$this->assertPattern('/Debugger\\.php/', $debugger);
error_reporting($original);
}