本文整理汇总了PHP中App::core方法的典型用法代码示例。如果您正苦于以下问题:PHP App::core方法的具体用法?PHP App::core怎么用?PHP App::core使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::core方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCore
/**
* testCore method
*
* @access public
* @return void
*/
function testCore()
{
$model = App::core('models');
$this->assertEqual(array(LIBS . 'model' . DS), $model);
$view = App::core('views');
$this->assertEqual(array(LIBS . 'view' . DS), $view);
$controller = App::core('controllers');
$this->assertEqual(array(LIBS . 'controller' . DS), $controller);
}
示例2: initialize
/**
* Initialization method installs Simpletest and loads all plugins
*
* @return void
*/
public function initialize()
{
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_dispatcher.php';
$corePath = App::core('cake');
if (isset($corePath[0])) {
define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
} else {
define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
}
$this->_dispatcher = new CakeTestSuiteDispatcher();
$this->_dispatcher->loadTestFramework();
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php';
}
示例3: _getShellList
/**
* Gets the shell command listing.
*
* @return array
*/
protected function _getShellList()
{
$shellList = array();
$corePaths = App::core('shells');
$shellList = $this->_appendShells('CORE', $corePaths, $shellList);
$appPaths = array_diff(App::path('shells'), $corePaths);
$shellList = $this->_appendShells('app', $appPaths, $shellList);
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
$pluginPath = App::pluginPath($plugin) . 'console' . DS . 'shells' . DS;
$shellList = $this->_appendShells($plugin, array($pluginPath), $shellList);
}
return $shellList;
}
示例4: _getShellList
/**
* Gets the shell command listing.
*
* @return array
*/
protected function _getShellList()
{
$shellList = array();
$shells = App::objects('file', App::core('Console/Command'));
$shellList = $this->_appendShells('CORE', $shells, $shellList);
$appShells = App::objects('Console/Command', null, false);
$shellList = $this->_appendShells('app', $appShells, $shellList);
$plugins = CakePlugin::loaded();
foreach ($plugins as $plugin) {
$pluginShells = App::objects($plugin . '.Console/Command');
$shellList = $this->_appendShells($plugin, $pluginShells, $shellList);
}
return $shellList;
}
示例5: initialize
/**
* Initialization method installs Simpletest and loads all plugins
*
* @return void
* @access public
*/
function initialize()
{
$corePath = App::core('cake');
if (isset($corePath[0])) {
define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
} else {
define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
}
$this->__installSimpleTest();
require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php';
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cli_reporter.php';
$plugins = App::objects('plugin');
foreach ($plugins as $p) {
$this->plugins[] = Inflector::underscore($p);
}
}
示例6: _getShellList
/**
* Gets the shell command listing.
*
* @return array
*/
protected function _getShellList()
{
$skipFiles = array('AppShell');
$plugins = CakePlugin::loaded();
$shellList = array_fill_keys($plugins, null) + array('CORE' => null, 'app' => null);
$corePath = App::core('Console/Command');
$shells = App::objects('file', $corePath[0]);
$shells = array_diff($shells, $skipFiles);
$this->_appendShells('CORE', $shells, $shellList);
$appShells = App::objects('Console/Command', null, false);
$appShells = array_diff($appShells, $shells, $skipFiles);
$this->_appendShells('app', $appShells, $shellList);
foreach ($plugins as $plugin) {
$pluginShells = App::objects($plugin . '.Console/Command');
$this->_appendShells($plugin, $pluginShells, $shellList);
}
return array_filter($shellList);
}
示例7: _findThemes
/**
* Find the paths to all the installed shell themes in the app.
*
* Bake themes are directories not named `skel` inside a `Console/Templates` path.
* They are listed in this order: app -> plugin -> default
*
* @return array Array of bake themes that are installed.
*/
protected function _findThemes() {
$paths = App::path('Console');
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
$paths[] = $this->_pluginPath($plugin) . 'Console' . DS;
}
$core = current(App::core('Console'));
$separator = DS === '/' ? '/' : '\\\\';
$core = preg_replace('#shells' . $separator . '$#', '', $core);
$Folder = new Folder($core . 'Templates' . DS . 'default');
$contents = $Folder->read();
$themeFolders = $contents[0];
$paths[] = $core;
foreach ($paths as $i => $path) {
$paths[$i] = rtrim($path, DS) . DS;
}
$themes = array();
foreach ($paths as $path) {
$Folder = new Folder($path . 'Templates', false);
$contents = $Folder->read();
$subDirs = $contents[0];
foreach ($subDirs as $dir) {
if (empty($dir) || preg_match('@^skel$|_skel$@', $dir)) {
continue;
}
$Folder = new Folder($path . 'Templates' . DS . $dir);
$contents = $Folder->read();
$subDirs = $contents[0];
if (array_intersect($contents[0], $themeFolders)) {
$templateDir = $path . 'Templates' . DS . $dir . DS;
$themes[$dir] = $templateDir;
}
}
}
return $themes;
}
示例8: _getFiles
protected function _getFiles($type)
{
$files = App::objects($type, null, false);
$corePath = App::core($type);
$coreFiles = App::objects($type, $corePath, false);
$files = am($coreFiles, $files);
//$paths = (array)App::path($type.'s');
//$libFiles = App::objects($type, $paths[0] . 'lib' . DS, false);
if (!isset($this->plugins)) {
$this->plugins = App::objects('plugin');
}
if (!empty($this->plugins)) {
foreach ($this->plugins as $plugin) {
$pluginType = $plugin . '.' . $type;
$pluginFiles = App::objects($pluginType, null, false);
if (!empty($pluginFiles)) {
foreach ($pluginFiles as $t) {
$files[] = $t;
}
}
}
}
$files = array_unique($files);
sort($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;
}
示例9: startTest
/**
* setUp method
*
* @access public
* @return void
*/
function startTest()
{
$this->_get = $_GET;
$_GET = array();
$this->_post = $_POST;
$this->_files = $_FILES;
$this->_server = $_SERVER;
$this->_app = Configure::read('App');
Configure::write('App.base', false);
Configure::write('App.baseUrl', false);
Configure::write('App.dir', 'app');
Configure::write('App.webroot', 'webroot');
$this->_cache = Configure::read('Cache');
Configure::write('Cache.disable', true);
$this->_debug = Configure::read('debug');
App::build(App::core());
}
示例10: testPluginPathGeneration
/**
* Test that plugin/$plugin_name is only appended to the paths it should be.
*
* @return void
*/
public function testPluginPathGeneration()
{
$this->Controller->plugin = 'TestPlugin';
$this->Controller->name = 'TestPlugin';
$this->Controller->viewPath = 'Tests';
$this->Controller->action = 'index';
$View = new TestView($this->Controller);
$paths = $View->paths();
$expected = array_merge(App::path('View'), App::core('View'), App::core('Console/Templates/skel/View'));
$this->assertEquals($expected, $paths);
$paths = $View->paths('TestPlugin');
$pluginPath = CakePlugin::path('TestPlugin');
$expected = array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Plugin' . DS . 'TestPlugin' . DS, $pluginPath . 'View' . DS, CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS, CAKE . 'View' . DS, CAKE . 'Console' . DS . 'Templates' . DS . 'skel' . DS . 'View' . DS);
$this->assertEquals($expected, $paths);
}
示例11: testComponentBeforeRenderChangingViewClass
/**
* test that a component beforeRender can change the controller view class.
*
* @return void
*/
function testComponentBeforeRenderChangingViewClass()
{
$core = App::core('views');
App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS, $core[0])), true);
$Controller =& new Controller();
$Controller->uses = array();
$Controller->components = array('Test');
$Controller->constructClasses();
$Controller->Test->viewclass = 'Theme';
$Controller->viewPath = 'posts';
$Controller->theme = 'test_theme';
$result = $Controller->render('index');
$this->assertPattern('/default test_theme layout/', $result);
App::build();
}
示例12: _paths
/**
* Return all possible paths to find view files in order
*
* @param string $plugin Optional plugin name to scan for view files.
* @param boolean $cached Set to true to force a refresh of view paths.
* @return array paths
*/
protected function _paths($plugin = null, $cached = true)
{
if ($plugin === null && $cached === true && !empty($this->__paths)) {
return $this->__paths;
}
$paths = array();
$viewPaths = App::path('views');
$corePaths = array_flip(App::core('views'));
if (!empty($plugin)) {
$count = count($viewPaths);
for ($i = 0; $i < $count; $i++) {
if (!isset($corePaths[$viewPaths[$i]])) {
$paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS;
}
}
$paths[] = App::pluginPath($plugin) . 'views' . DS;
}
$this->__paths = array_merge($paths, $viewPaths);
return $this->__paths;
}
示例13: load
/**
* Loads a file from app/config/configure_file.php.
* Config file variables should be formated like:
* `$config['name'] = 'value';`
* These will be used to create dynamic Configure vars. load() is also used to
* load stored config files created with Configure::store()
*
* - To load config files from app/config use `Configure::load('configure_file');`.
* - To load config files from a plugin `Configure::load('plugin.configure_file');`.
*
* @link http://book.cakephp.org/view/415/load
* @param string $fileName name of file to load, extension must be .php and only the name
* should be used, not the extenstion
* @return mixed false if file not found, void if load successful
* @access public
*/
public function load($fileName)
{
$found = $plugin = $pluginPath = false;
list($plugin, $fileName) = pluginSplit($fileName);
if ($plugin) {
$pluginPath = App::pluginPath($plugin);
}
$pos = strpos($fileName, '..');
if ($pos === false) {
if ($pluginPath && file_exists($pluginPath . 'config' . DS . $fileName . '.php')) {
include $pluginPath . 'config' . DS . $fileName . '.php';
$found = true;
} elseif (file_exists(CONFIGS . $fileName . '.php')) {
include CONFIGS . $fileName . '.php';
$found = true;
} elseif (file_exists(CACHE . 'persistent' . DS . $fileName . '.php')) {
include CACHE . 'persistent' . DS . $fileName . '.php';
$found = true;
} else {
foreach (App::core('cake') as $key => $path) {
if (file_exists($path . DS . 'config' . DS . $fileName . '.php')) {
include $path . DS . 'config' . DS . $fileName . '.php';
$found = true;
break;
}
}
}
}
if (!$found) {
return false;
}
if (!isset($config)) {
$error = __("Configure::load() - no variable \$config found in %s.php", true);
trigger_error(sprintf($error, $fileName), E_USER_WARNING);
return false;
}
return Configure::write($config);
}
示例14: _paths
/**
* Return all possible paths to find view files in order
*
* @param string $plugin Optional plugin name to scan for view files.
* @param boolean $cached Set to true to force a refresh of view paths.
* @return array paths
*/
protected function _paths($plugin = null, $cached = true)
{
if ($plugin === null && $cached === true && !empty($this->_paths)) {
return $this->_paths;
}
$paths = array();
$viewPaths = App::path('View');
$corePaths = array_flip(App::core('View'));
if (!empty($plugin)) {
$count = count($viewPaths);
for ($i = 0; $i < $count; $i++) {
if (!isset($corePaths[$viewPaths[$i]])) {
$paths[] = $viewPaths[$i] . 'Plugin' . DS . $plugin . DS;
}
}
$paths = array_merge($paths, App::path('View', $plugin));
}
$paths = array_unique(array_merge($paths, $viewPaths, array_keys($corePaths)));
if ($plugin !== null) {
return $paths;
}
return $this->_paths = $paths;
}
示例15: _paths
/**
* Return all possible paths to find view files in order
*
* @param string $plugin Optional plugin name to scan for view files.
* @param boolean $cached Set to true to force a refresh of view paths.
* @return array paths
*/
protected function _paths($plugin = null, $cached = true)
{
if ($plugin === null && $cached === true && !empty($this->_paths)) {
return $this->_paths;
}
$paths = array();
$viewPaths = App::path('View');
$corePaths = array_merge(App::core('View'), App::core('Console/Templates/skel/View'));
if (!empty($plugin)) {
$count = count($viewPaths);
for ($i = 0; $i < $count; $i++) {
if (!in_array($viewPaths[$i], $corePaths)) {
$paths[] = $viewPaths[$i] . 'Plugin' . DS . $plugin . DS;
}
}
$paths = array_merge($paths, App::path('View', $plugin));
}
$paths = array_unique(array_merge($paths, $viewPaths));
// CUSTOMIZE ADD 2013/08/17 ryuring
// >>>
$adminThemePaths = array();
$webroot = Configure::read('App.www_root');
if (!empty($this->adminTheme)) {
foreach ($paths as $path) {
if (strpos($path, DS . 'Plugin' . DS) === false) {
if ($plugin) {
$adminThemePaths[] = $path . 'Themed' . DS . $this->adminTheme . DS . 'Plugin' . DS . $plugin . DS;
}
$adminThemePaths[] = $path . 'Themed' . DS . $this->adminTheme . DS;
}
}
$adminThemePaths = array_merge(array($webroot . 'theme' . DS . $this->adminTheme . DS), $adminThemePaths);
}
// <<<
if (!empty($this->theme)) {
$themePaths = array();
foreach ($paths as $path) {
if (strpos($path, DS . 'Plugin' . DS) === false) {
if ($plugin) {
$themePaths[] = $path . 'Themed' . DS . $this->theme . DS . 'Plugin' . DS . $plugin . DS;
}
$themePaths[] = $path . 'Themed' . DS . $this->theme . DS;
}
}
// CUSTOMIZE MODIFY 2013/08/17 ryuring
// >>>
//$paths = array_merge($themePaths, $paths);
// --
$themePaths = array_merge(array($webroot . 'theme' . DS . $this->theme . DS), $themePaths);
$paths = array_merge($themePaths, $adminThemePaths, $paths);
// <<<
}
// CUSTOMIZE ADD 2013/08/26 ryuring
// Baserディレクトリのパスの優先順位を下げる
// >>>
$baserPaths = array();
foreach ($paths as $key => $path) {
if (strpos($path, BASER) !== false) {
unset($paths[$key]);
$baserPaths[] = $path;
}
}
$paths = array_merge($paths, $baserPaths);
// <<<
$paths = array_merge($paths, $corePaths);
if ($plugin !== null) {
return $paths;
}
return $this->_paths = $paths;
}