本文整理汇总了PHP中App::path方法的典型用法代码示例。如果您正苦于以下问题:PHP App::path方法的具体用法?PHP App::path怎么用?PHP App::path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Datasource constructor, creates the Configuration, Connection and DocumentManager objects
*
* ### You can pass the following configuration options
*
* - server: name of the server that will be used to connect to Mongo (default: `localhost`)
* - database: name of the database to use when connecting to Mongo (default: `cake`)
* - documentPaths: array containing a list of full path names where Document classes can be located (default: `App::path('Model')`)
* - proxyDir: full path to the directory that will contain the generated proxy classes for each document (default: `TMP . 'cache'`)
* - proxyNamespace: string representing the namespace the proxy classes will reside in (default: `Proxies`)
* - hydratorDir: directory well the hydrator classes will be generated in (default: `TMP . 'cache'`)
* - hydratorNamespace: string representing the namespace the hydrator classes will reside in (default: `Hydrators`)
*
* @param arary $config
* @param boolean $autoConnect whether this object should attempt connection on creation
* @throws MissingConnectionException if it was not possible to connect to MongoDB
*/
public function __construct($config = array(), $autoConnect = true)
{
$modelPaths = $this->_cleanupPaths(App::path('Model'));
$this->_baseConfig = array('proxyDir' => TMP . 'cache', 'proxyNamespace' => 'Proxies', 'hydratorDir' => TMP . 'cache', 'hydratorNamespace' => 'Hydrators', 'server' => 'localhost', 'database' => 'cake', 'documentPaths' => $modelPaths, 'prefix' => null);
foreach (CakePlugin::loaded() as $plugin) {
$this->_baseConfig['documentPaths'] = array_merge($this->_baseConfig['documentPaths'], $this->_cleanupPaths(App::path('Model', $plugin)));
}
parent::__construct($config);
extract($this->config, EXTR_OVERWRITE);
$configuration = new Configuration();
$configuration->setProxyDir($proxyDir);
$configuration->setProxyNamespace($proxyNamespace);
$configuration->setHydratorDir($hydratorDir);
$configuration->setHydratorNamespace($hydratorNamespace);
$configuration->setDefaultDB($database);
$configuration->setMetadataDriverImpl($this->_getMetadataReader($documentPaths));
if (Configure::read('debug') === 0) {
$configuration->setAutoGenerateHydratorClasses(false);
$configuration->setAutoGenerateProxyClasses(false);
$configuration->setMetadataCacheImpl(new ApcCache());
}
$this->configuration = $configuration;
$this->connection = new Connection($server, array(), $configuration);
$this->documentManager = DocumentManager::create($this->connection, $configuration);
$this->documentManager->getEventManager()->addEventListener(array(Events::prePersist, Events::preUpdate, Events::preRemove, Events::postPersist, Events::postUpdate, Events::postRemove), $this);
try {
if ($autoConnect) {
$this->connect();
}
} catch (Exception $e) {
throw new MissingConnectionException(array('class' => get_class($this)));
}
$this->setupLogger();
}
示例2: output
/**
* Run $input through Closure compiler
*
* @param string $filename Filename being generated.
* @param string $input Contents of file
* @throws Exception $e
* @return Compressed file
*/
public function output($filename, $input)
{
$output = null;
$jar = $this->_findExecutable(App::path('vendors'), $this->_settings['path']);
//Closure works better if you specify an input file. Also supress warnings by default
$tmpFile = tempnam(TMP, 'CLOSURE');
file_put_contents($tmpFile, $input);
$options = array('js' => $tmpFile) + $this->_settings;
$options = array_diff_key($options, array('path' => null, 'paths' => null, 'target' => null, 'theme' => null));
$cmd = 'java -jar "' . $jar . '"';
foreach ($options as $key => $value) {
$cmd .= sprintf(' --%s=%s', $key, $value);
}
try {
$output = $this->_runCmd($cmd, null);
} catch (Exception $e) {
//If there is an error need to remove tmpFile.
// @codingStandardsIgnoreStart
@unlink($tmpFile);
// @codingStandardsIgnoreStart
throw $e;
}
// @codingStandardsIgnoreStart
@unlink($tmpFile);
// @codingStandardsIgnoreStart
return $output;
}
示例3: _getFiles
public function _getFiles($type)
{
$files = App::objects($type);
# lib
$paths = (array) App::path($type . 's');
$libFiles = App::objects($type, $paths[0] . 'lib' . DS, false);
$plugins = App::objects('plugin');
if (!empty($plugins)) {
foreach ($plugins as $plugin) {
$pluginFiles = App::objects($type, App::pluginPath($plugin) . $type . 's' . DS, false);
if (!empty($pluginFiles)) {
foreach ($pluginFiles as $t) {
$files[] = $t;
//"$plugin.$type";
}
}
}
}
$files = array_merge($files, $libFiles);
$files = array_unique($files);
$appIndex = array_search('App', $files);
if ($appIndex !== false) {
unset($files[$appIndex]);
}
# no test/tmp files etc (helper.test.php or helper.OLD.php)
foreach ($files as $key => $file) {
if (strpos($file, '.') !== false || !preg_match('/^[\\da-zA-Z_]+$/', $file)) {
unset($files[$key]);
}
}
return $files;
}
示例4: getLayoutFile
/**
* Looks for the view file according to the given view name.
*
* @return string the view file path, false if the view file does not exist
*/
public function getLayoutFile() {
if( $this->layout == NULL ) {
return false;
}
return App::path( array( 'view', $this->layout ) );
}
示例5: startup
public function startup()
{
$this->_welcome();
$this->out('TwitterBootstrap Shell');
$this->hr();
$this->pluginPath = App::pluginPath($this->pluginName);
$paths = array_unique(array_merge(App::path('Vendor', $this->pluginName), App::path('Vendor')));
foreach ($paths as $path) {
$dir = 'twitter' . DS . 'bootstrap' . DS;
if (is_dir($path . $dir . self::IMG_DIR) && is_dir($path . $dir . self::JS_DIR) && is_dir($path . $dir . self::LESS_DIR)) {
$this->bootstrapPath = $path . $dir;
break;
}
$dir = 'bootstrap' . DS;
if (is_dir($path . $dir . self::IMG_DIR) && is_dir($path . $dir . self::JS_DIR) && is_dir($path . $dir . self::LESS_DIR)) {
$this->bootstrapPath = $path . $dir;
break;
}
}
if (!$this->bootstrapPath) {
$this->out('<error>Bootstrap files were not found.</error>');
exit(0);
}
$this->Folder = new Folder($this->bootstrapPath);
}
示例6: startTest
/**
* start test
*
* @return void
**/
function startTest()
{
$this->Version =& new MigrationVersion(array('connection' => 'test_suite'));
$plugins = $this->plugins = App::path('plugins');
$plugins[] = dirname(dirname(dirname(__FILE__))) . DS . 'test_app' . DS . 'plugins' . DS;
App::build(array('plugins' => $plugins), true);
}
示例7: initialize
/**
* Overwrite shell initialize to dynamically load all Queue Related Tasks.
*
* @return void
*/
public function initialize()
{
$paths = App::path('Console/Command/Task');
foreach ($paths as $path) {
$Folder = new Folder($path);
$res = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
foreach ($res as &$r) {
$r = basename($r, 'Task.php');
}
$this->tasks = $res;
}
$plugins = CakePlugin::loaded();
foreach ($plugins as $plugin) {
$pluginPaths = App::path('Console/Command/Task', $plugin);
foreach ($pluginPaths as $pluginPath) {
$Folder = new Folder($pluginPath);
$res = $Folder->find('Queue.*Task\\.php');
foreach ($res as &$r) {
$r = $plugin . '.' . basename($r, 'Task.php');
}
$this->tasks = array_merge($this->tasks, $res);
}
}
parent::initialize();
$this->QueuedTask->initConfig();
}
示例8: jobs
/**
* Get the jobs that are currently queued. Returns the jobs as objects
* structured like :
*
*
* - pId = process ID of job.
* - time = time job was enetered.
* - delay = delay the job was told to wait before execution.
* - object = the actual object or Closure that will execute the job.
* - method = the method to call on the object.
* - vars = the variables to be passed to the method.
*
*
* @return array An array of job objects.
*/
public function jobs()
{
exec('ps -ef | grep "php[[:space:]]' . \App::path() . '/public/index\\.php[[:space:]]resolve"', $jobs);
$f = 'php ' . \App::path() . '/public/index.php resolve';
$j = array();
foreach ($jobs as $k => $v) {
if (stripos($v, $f) !== false) {
$v = preg_replace('!\\s+!', ' ', $v);
$j[] = $v;
}
//if
}
//foreach
foreach ($j as $k => $job) {
$job = explode(' ', $job, 15);
$j[$k] = new \stdClass();
$j[$k]->pId = $job[1];
$j[$k]->time = $job[4];
$j[$k]->delay = $job[10];
$j[$k]->object = unserialize(base64_decode($job[11]));
$j[$k]->method = $job[12];
$j[$k]->vars = $job[13] == 'disco-no-variable' ? '' : unserialize(base64_decode($job[13]));
}
//foreach
return $j;
}
示例9: startTest
/**
* startTest method
*
* @return void
* @access public
*/
function startTest() {
$this->Dispatcher =& new TestProjectTaskMockShellDispatcher();
$this->Dispatcher->shellPaths = App::path('shells');
$this->Task =& new MockProjectTask($this->Dispatcher);
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->path = TMP . 'tests' . DS;
}
示例10: execute
/**
* execute
*
* Overriden so all the interactive options take defaults
*
* @return void
*/
public function execute()
{
$this->_getPaths();
$path = $this->_paths[0];
$this->params['extract-core'] = 'no';
if (!isset($this->params['ignore-model-validation'])) {
$this->params['ignore-model-validation'] = true;
}
$pluginPaths = App::path('plugins');
if ($this->_isExtractingApp()) {
$this->_exclude = array_merge($this->_exclude, $pluginPaths);
}
if (!isset($this->params['output'])) {
$this->params['output'] = $path . 'Locale' . DS;
}
$this->params['merge'] = 'no';
$this->params['overwrite'] = true;
// set plugin param if a plugin path is given and the default domain is set
if (preg_match('/Plugin\\/(?P<plugin>.+)\\//', $path, $matches) && isset($this->_defaultDomain)) {
$this->params['plugin'] = $matches['plugin'];
} else {
$this->params['paths'] = $path;
}
parent::execute();
}
示例11: initialize
/**
* Overwrite shell initialize to dynamically load all Queue Related Tasks.
*
* @return void
*/
public function initialize()
{
$this->_loadModels();
$x = App::objects('Queue.Task');
//'Console/Command/Task'
//$x = App::path('Task', 'Queue');
$paths = App::path('Console/Command/Task');
foreach ($paths as $path) {
$Folder = new Folder($path);
$this->tasks = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
}
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
$pluginPaths = App::path('Console/Command/Task', $plugin);
foreach ($pluginPaths as $pluginPath) {
$Folder = new Folder($pluginPath);
$res = $Folder->find('Queue.*Task\\.php');
foreach ($res as &$r) {
$r = $plugin . '.' . basename($r, 'Task.php');
}
$this->tasks = array_merge($this->tasks, $res);
}
}
//Config can be overwritten via local app config.
Configure::load('Queue.queue');
$conf = (array) Configure::read('Queue');
//merge with default configuration vars.
Configure::write('Queue', array_merge(['maxruntime' => DAY, 'cleanuptimeout' => MONTH], $conf));
}
示例12: load
/**
* Loads a plugin and optionally loads bootstrapping, routing files or loads a initialization function
*
* Examples:
*
* `CakePlugin::load('DebugKit')` will load the DebugKit plugin and will not load any bootstrap nor route files
* `CakePlugin::load('DebugKit', array('bootstrap' => true, 'routes' => true))` will load the bootstrap.php and routes.php files
* `CakePlugin::load('DebugKit', array('bootstrap' => false, 'routes' => true))` will load routes.php file but not bootstrap.php
* `CakePlugin::load('DebugKit', array('bootstrap' => array('config1', 'config2')))` will load config1.php and config2.php files
* `CakePlugin::load('DebugKit', array('bootstrap' => 'aCallableMethod'))` will run the aCallableMethod function to initialize it
*
* Bootstrap initialization functions can be expressed as a PHP callback type, including closures. Callbacks will receive two
* parameters (plugin name, plugin configuration)
*
* It is also possible to load multiple plugins at once. Examples:
*
* `CakePlugin::load(array('DebugKit', 'ApiGenerator'))` will load the DebugKit and ApiGenerator plugins
* `CakePlugin::load(array('DebugKit', 'ApiGenerator'), array('bootstrap' => true))` will load bootstrap file for both plugins
*
* {{{
* CakePlugin::load(array(
* 'DebugKit' => array('routes' => true),
* 'ApiGenerator'
* ), array('bootstrap' => true))
* }}}
*
* Will only load the bootstrap for ApiGenerator and only the routes for DebugKit
*
* @param string|array $plugin name of the plugin to be loaded in CamelCase format or array or plugins to load
* @param array $config configuration options for the plugin
* @throws MissingPluginException if the folder for the plugin to be loaded is not found
* @return void
*/
public static function load($plugin, $config = array())
{
if (is_array($plugin)) {
foreach ($plugin as $name => $conf) {
list($name, $conf) = is_numeric($name) ? array($conf, $config) : array($name, $conf);
self::load($name, $conf);
}
return;
}
$config += array('bootstrap' => false, 'routes' => false, 'ignoreMissing' => false);
if (empty($config['path'])) {
foreach (App::path('plugins') as $path) {
if (is_dir($path . $plugin)) {
self::$_plugins[$plugin] = $config + array('path' => $path . $plugin . DS);
break;
}
//Backwards compatibility to make easier to migrate to 2.0
$underscored = Inflector::underscore($plugin);
if (is_dir($path . $underscored)) {
self::$_plugins[$plugin] = $config + array('path' => $path . $underscored . DS);
break;
}
}
} else {
self::$_plugins[$plugin] = $config;
}
if (empty(self::$_plugins[$plugin]['path'])) {
throw new MissingPluginException(array('plugin' => $plugin));
}
if (!empty(self::$_plugins[$plugin]['bootstrap'])) {
self::bootstrap($plugin);
}
}
示例13: startTest
/**
* startTest method
*
* @return void
* @access public
*/
function startTest()
{
$this->Dispatcher =& new TestTemplateTaskMockShellDispatcher();
$this->Task =& new MockTemplateTask($this->Dispatcher);
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->Dispatch->shellPaths = App::path('shells');
}
示例14: getData
/**
* Get the content of theme.json file from a theme
*
* @param string $alias theme folder name
* @return array
*/
public function getData($alias = null)
{
if ($alias == null || $alias == 'default') {
$manifestFile = WWW_ROOT . 'theme.json';
} else {
$viewPaths = App::path('views');
foreach ($viewPaths as $viewPath) {
if (file_exists($viewPath . 'Themed' . DS . $alias . DS . 'webroot' . DS . 'theme.json')) {
$manifestFile = $viewPath . 'Themed' . DS . $alias . DS . 'webroot' . DS . 'theme.json';
continue;
}
}
if (!isset($manifestFile)) {
$manifestFile = WWW_ROOT . 'theme.json';
}
}
if (isset($manifestFile) && file_exists($manifestFile)) {
$themeData = json_decode(file_get_contents($manifestFile), true);
if ($themeData == null) {
$themeData = array();
}
} else {
$themeData = array();
}
return $themeData;
}
示例15: _findSubthemes
/**
* Find the paths to all the installed shell themes extensions in the app.
*
* @return array Array of bake themes that are installed.
*/
protected function _findSubthemes()
{
$paths = App::path('shells');
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
$paths[$plugin] = $this->_pluginPath($plugin) . 'Console' . DS;
}
foreach ($paths as $i => $path) {
$paths[$i] = rtrim($path, DS) . DS;
}
$subthemes = array();
foreach ($paths as $plugin => $path) {
$Folder = new Folder($path . 'SubTemplates', false);
$contents = $Folder->read();
$subDirs = $contents[0];
foreach ($subDirs as $dir) {
if (empty($dir) || preg_match('@^skel$|_skel|\\..+$@', $dir)) {
continue;
}
$Folder = new Folder($path . 'SubTemplates' . DS . $dir);
$contents = $Folder->read();
$subDirs = $contents[0];
$templateDir = $path . 'SubTemplates' . DS . $dir . DS;
$subthemes[$plugin . '.' . $dir] = $templateDir;
}
}
return $subthemes;
}