当前位置: 首页>>代码示例>>PHP>>正文


PHP Libraries::get方法代码示例

本文整理汇总了PHP中lithium\core\Libraries::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Libraries::get方法的具体用法?PHP Libraries::get怎么用?PHP Libraries::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lithium\core\Libraries的用法示例。


在下文中一共展示了Libraries::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: template

 /**
  * Compiles a template and writes it to a cache file, which is used for inclusion.
  *
  * @param string $file The full path to the template that will be compiled.
  * @param array $options Options for compilation include:
  *        - `path`: Path where the compiled template should be written.
  *        - `fallback`: Boolean indicating that if the compilation failed for some
  *                      reason (e.g. `path` is not writable), that the compiled template
  *                      should still be returned and no exception be thrown.
  * @return string The compiled template.
  */
 public static function template($file, array $options = array())
 {
     $cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates';
     $defaults = array('path' => $cachePath, 'fallback' => false);
     $options += $defaults;
     $stats = stat($file);
     $oname = basename(dirname($file)) . '_' . basename($file, '.php');
     $oname .= '_' . ($stats['ino'] ?: hash('md5', $file));
     $template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php";
     $template = "{$options['path']}/{$template}";
     if (file_exists($template)) {
         return $template;
     }
     $compiled = static::compile(file_get_contents($file));
     if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) {
         foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) {
             if ($expired !== $template) {
                 unlink($expired);
             }
         }
         return $template;
     }
     if ($options['fallback']) {
         return $file;
     }
     throw new TemplateException("Could not write compiled template `{$template}` to cache.");
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:38,代码来源:Compiler.php

示例2: _tempFileWithContents

 protected function _tempFileWithContents($contents)
 {
     $path = Libraries::get(true, 'resources') . '/tmp/' . uniqid() . '.php';
     $this->_files[] = $path;
     file_put_contents($path, $contents);
     return $path;
 }
开发者ID:raisinbread,项目名称:li3_qa,代码行数:7,代码来源:DocumentedTest.php

示例3: testCustomConfiguration

	public function testCustomConfiguration() {
		$config = array(
			'session.name' => 'awesome_name', 'session.cookie_lifetime' => 1200,
			'session.cookie_domain' => 'awesome.domain',
			'session.save_path' => Libraries::get(true, 'resources') . '/tmp/',
			'somebad.configuration' => 'whoops'
		);

		$adapter = new Php($config);

		$result = ini_get('session.name');
		$this->assertEqual($config['session.name'], $result);

		$result = ini_get('session.cookie_lifetime');
		$this->assertEqual($config['session.cookie_lifetime'], (integer) $result);

		$result = ini_get('session.cookie_domain');
		$this->assertEqual($config['session.cookie_domain'], $result);

		$result = ini_get('session.cookie_secure');
		$this->assertFalse($result);

		$result = ini_get('session.cookie_httponly');
		$this->assertTrue($result);

		$result = ini_get('session.save_path');
		$this->assertEqual($config['session.save_path'], $result);

		$result = ini_get('somebad.configuration');
		$this->assertFalse($result);
	}
开发者ID:niel,项目名称:lithium,代码行数:31,代码来源:PhpTest.php

示例4: testConfig

 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));
 }
开发者ID:tmaiaroto,项目名称:li3_facebook,代码行数:35,代码来源:FacebookProxyTest.php

示例5: testDeliverLogToDir

 public function testDeliverLogToDir()
 {
     $path = realpath(Libraries::get(true, 'resources') . '/tmp/tests');
     $this->skipIf(!is_writable($path), "Path `{$path}` is not writable.");
     $log = $path . DIRECTORY_SEPARATOR . 'mails';
     if (!is_dir($log)) {
         mkdir($log);
     }
     $glob = $log . DIRECTORY_SEPARATOR . '*.mail';
     $oldresults = glob($glob);
     $options = array('to' => 'foo@bar', 'subject' => 'test subject');
     $message = new Message($options);
     $debug = new Debug();
     $format = 'short';
     $delivered = $debug->deliver($message, compact('log', 'format'));
     $this->assertTrue($delivered);
     $results = array_diff(glob($glob), $oldresults);
     $this->assertEqual(1, count($results));
     $resultFile = current($results);
     $result = file_get_contents($resultFile);
     $pattern = '\\[[\\d:\\+\\-T]+\\]';
     $info = ' Sent to foo@bar with subject `test subject`.\\n';
     $expected = '/^' . $pattern . $info . '$/';
     $this->assertPattern($expected, $result);
     unlink($resultFile);
 }
开发者ID:globus40000,项目名称:li3_mailer,代码行数:26,代码来源:DebugTest.php

示例6: file

 /**
  * Get content of file, parse it with lessc and return formatted css
  *
  * @todo allow for css-file name only, and search it in all avail. webroots
  * @param string $file full path to file
  * @param array $options Additional options to control flow of method
  *                       - header - controls, whether to prepend a header
  *                       - cache - controls, whether to cache the result
  *                       - cachePath - Where to cache files, defaults to
  *                                     resources/tmp/cache
  * @return string|boolean generated css, false in case of error
  */
 public static function file($file, array $options = array())
 {
     $defaults = array('header' => true, 'cache' => true, 'cachePath' => Libraries::get(true, 'resources') . '/tmp/cache', 'cacheKey' => Inflector::slug(str_replace(array(LITHIUM_APP_PATH, '.less'), array('', '.css'), $file)));
     $options += $defaults;
     $css_file = $options['cachePath'] . '/' . $options['cacheKey'];
     if (file_exists($css_file) && filemtime($css_file) >= filemtime($file)) {
         return file_get_contents($css_file);
     }
     if (!file_exists($file)) {
         return false;
     }
     try {
         $less = static::_getLess($file);
         $output = $less->parse();
     } catch (Exception $e) {
         $output = "/* less compiler exception: {$e->getMessage()} */";
     }
     if ($options['header']) {
         $output = static::_prependHeader($output);
     }
     if ($options['cache']) {
         file_put_contents($css_file, $output);
     }
     return $output;
 }
开发者ID:raisinbread,项目名称:li3_less,代码行数:37,代码来源:Less.php

示例7: _init

 protected function _init()
 {
     parent::_init();
     $this->_config = (array) Libraries::get('li3_pecl_oauth');
     $this->_config += array('host' => $this->request->env('SERVER_NAME'), 'oauth_callback' => $this->request->env('SERVER_NAME') . '/oauth/client', 'namespace' => 'li3_pecl_oauth', 'redirect_success' => 'Client::index', 'redirect_failed' => array('Client::index', 'args' => array('failed' => true)));
     return Consumer::config($this->_config) ? true : false;
 }
开发者ID:JacopKane,项目名称:li3_pecl_oauth,代码行数:7,代码来源:ClientController.php

示例8: __construct

 /**
  * Constructor.
  *
  * Takes care of setting appropriate configurations for this object.
  *
  * @param array $config Optional configuration parameters.
  * @return void
  */
 public function __construct(array $config = array())
 {
     if (empty($config['name'])) {
         $config['name'] = basename(Libraries::get(true, 'path')) . 'cookie';
     }
     parent::__construct($config + $this->_defaults);
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:15,代码来源:Cookie.php

示例9: __construct

 /**
  * Constructor.
  *
  * @see lithium\util\String::insert()
  * @param array $config Settings used to configure the adapter. Available options:
  *        - `'path'` _string_: The directory to write log files to. Defaults to
  *          `<app>/resources/tmp/logs`.
  *        - `'timestamp'` _string_: The `date()`-compatible timestamp format. Defaults to
  *          `'Y-m-d H:i:s'`.
  *        - `'file'` _\Closure_: A closure which accepts two parameters: an array
  *          containing the current log message details, and an array containing the `File`
  *          adapter's current configuration. It must then return a file name to write the
  *          log message to. The default will produce a log file name corresponding to the
  *          priority of the log message, i.e. `"debug.log"` or `"alert.log"`.
  *        - `'format'` _string_: A `String::insert()`-compatible string that specifies how
  *          the log message should be formatted. The default format is
  *          `"{:timestamp} {:message}\n"`.
  * @return void
  */
 public function __construct(array $config = array())
 {
     $defaults = array('path' => Libraries::get(true, 'resources') . '/tmp/logs', 'timestamp' => 'Y-m-d H:i:s', 'file' => function ($data, $config) {
         return "{$data['priority']}.log";
     }, 'format' => "{:timestamp} {:message}\n");
     parent::__construct($config + $defaults);
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:26,代码来源:File.php

示例10: find

 public static function find(array $options = array())
 {
     $defaults = array('collect' => true);
     $options += $defaults;
     $data = array();
     $libs = Libraries::get(null, 'path');
     $recursive = true;
     foreach ($libs as $lib => $path) {
         $result = array();
         $path .= '/views/widgets';
         $files = StaticContents::available(compact('path', 'recursive'));
         if (!$files) {
             continue;
         }
         $temp = array_keys(Set::flatten($files, array('separator' => '/')));
         foreach ($temp as $key => $value) {
             if (strpos($value, 'admin.') !== false) {
                 continue;
             }
             if (strpos($value, 'inc.') !== false) {
                 continue;
             }
             $result[$key] = str_replace('.html.php', '', $value);
         }
         $data[$lib] = $result;
     }
     return $data;
 }
开发者ID:bruensicke,项目名称:radium,代码行数:28,代码来源:Widgets.php

示例11: setUp

 public function setUp()
 {
     $this->_backup['catalogConfig'] = Catalog::config();
     Catalog::reset();
     Catalog::config(array('lithium' => array('adapter' => 'Php', 'path' => Libraries::get('lithium', 'path') . '/g11n/resources/php')));
     Validator::__init();
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:7,代码来源:ResourcesValidatorTest.php

示例12: index

 public function index()
 {
     $title = 'Testing Leaderboard';
     $options = Libraries::get('li3_leaderboard');
     $data = StatsPresenter::find('all', $options);
     return compact('data', 'title');
 }
开发者ID:blainesch,项目名称:li3_leaderboard,代码行数:7,代码来源:LeaderboardController.php

示例13: flush

 /**
  *
  */
 public function flush()
 {
     $this->_header();
     $success = false;
     $config = Libraries::get('app');
     $dir = TwigAdapter::cachePath();
     $trash = $config['resources'] . self::PATH_TO_REMOVE;
     $this->out('Starting cache flush.');
     if (!is_dir($dir)) {
         return $this->error('Cache folder not found... exiting.');
     }
     $this->out('Cache folder found : ' . $dir);
     if (is_dir($trash)) {
         $this->out('Old trash folder found (previous command failure possible), deleting it...');
         $this->_rrmdir($trash);
     }
     $this->out('Moving cache folder to temporary location...');
     rename($dir, $trash);
     $this->out('Deleting temporary cache location...');
     $success = $this->_rrmdir($trash);
     if (!$success) {
         return $this->error('Error while deleting Twig template cache.');
     }
     return $this->out('Success!');
 }
开发者ID:unionofrad,项目名称:li3_twig,代码行数:28,代码来源:Twig.php

示例14: setUp

 public function setUp()
 {
     $this->_path = $path = Libraries::get(true, 'resources') . '/tmp/tests';
     mkdir("{$this->_path}/en/LC_MESSAGES", 0755, true);
     mkdir("{$this->_path}/de/LC_MESSAGES", 0755, true);
     $this->adapter = new MockGettext(compact('path'));
 }
开发者ID:newmight2015,项目名称:Blockchain-2,代码行数:7,代码来源:GettextTest.php

示例15: config

 public static function config($name = null)
 {
     if (empty(self::$_config)) {
         $config = Libraries::get('li3_varnish');
         $env = Environment::get();
         if (isset($config[$env])) {
             $config += $config[$env];
             unset($config[$env]);
         }
         foreach ($config as $k => $v) {
             if (isset(self::$_defaults[$k]) && is_array(self::$_defaults[$k])) {
                 $config[$k] += self::$_defaults[$k];
             }
         }
         self::$_config = $config + self::$_defaults;
     }
     if (isset($name)) {
         if (isset(self::$_config[$name])) {
             return self::$_config[$name];
         } else {
             return null;
         }
     }
     return self::$_config;
 }
开发者ID:brandonwestcott,项目名称:li3_varnish,代码行数:25,代码来源:Varnish.php


注:本文中的lithium\core\Libraries::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。