本文整理汇总了PHP中Cake\Core\App::core方法的典型用法代码示例。如果您正苦于以下问题:PHP App::core方法的具体用法?PHP App::core怎么用?PHP App::core使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Core\App
的用法示例。
在下文中一共展示了App::core方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _findTemplates
/**
* Find the paths to all the installed shell templates in the app.
*
* Bake templates are directories under `Template/Bake` path.
* They are listed in this order: app -> plugin -> default
*
* @return array Array of bake templates that are installed.
*/
protected function _findTemplates()
{
$paths = App::path('Template');
$plugins = Plugin::loaded();
foreach ($plugins as $plugin) {
$paths[] = Plugin::classPath($plugin) . 'Template' . DS;
}
$core = current(App::core('Template'));
$Folder = new Folder($core . 'Bake' . DS . 'default');
$contents = $Folder->read();
$templateFolders = $contents[0];
$paths[] = $core;
foreach ($paths as $i => $path) {
$paths[$i] = rtrim($path, DS) . DS;
}
$this->_io->verbose('Found the following bake templates:');
$templates = [];
foreach ($paths as $path) {
$Folder = new Folder($path . 'Bake', false);
$contents = $Folder->read();
$subDirs = $contents[0];
foreach ($subDirs as $dir) {
$Folder = new Folder($path . 'Bake' . DS . $dir);
$contents = $Folder->read();
$subDirs = $contents[0];
if (array_intersect($contents[0], $templateFolders)) {
$templateDir = $path . 'Bake' . DS . $dir . DS;
$templates[$dir] = $templateDir;
$this->_io->verbose(sprintf("- %s -> %s", $dir, $templateDir));
}
}
}
return $templates;
}
示例2: getShellList
/**
* Gets the shell command listing.
*
* @return array
*/
public function getShellList()
{
$skipFiles = ['AppShell'];
$hiddenCommands = ['CommandListShell', 'CompletionShell'];
$plugins = Plugin::loaded();
$shellList = array_fill_keys($plugins, null) + ['CORE' => null, 'app' => null];
$corePath = App::core('Console/Command');
$shells = App::objects('file', $corePath[0]);
$shells = array_diff($shells, $skipFiles, $hiddenCommands);
$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);
}
示例3: getShellList
/**
* Gets the shell command listing.
*
* @return array
*/
public function getShellList()
{
$skipFiles = ['AppShell'];
$hiddenCommands = ['CommandListShell', 'CompletionShell'];
$plugins = Plugin::loaded();
$shellList = array_fill_keys($plugins, null) + ['CORE' => null, 'app' => null];
$corePath = App::core('Shell');
$shells = $this->_scanDir($corePath[0]);
$shells = array_diff($shells, $skipFiles, $hiddenCommands);
$shellList = $this->_appendShells('CORE', $shells, $shellList);
$appPath = App::path('Shell');
$appShells = $this->_scanDir($appPath[0]);
$appShells = array_diff($appShells, $shells, $skipFiles);
$shellList = $this->_appendShells('app', $appShells, $shellList);
foreach ($plugins as $plugin) {
$pluginPath = Plugin::classPath($plugin) . 'Shell';
$pluginShells = $this->_scanDir($pluginPath);
$shellList = $this->_appendShells($plugin, $pluginShells, $shellList);
}
return array_filter($shellList);
}
示例4: testPathPluginGeneration
/**
* Test that plugin/$plugin_name is only appended to the paths it should be.
*
* @return void
*/
public function testPathPluginGeneration()
{
$viewOptions = ['plugin' => 'TestPlugin', 'name' => 'TestPlugin', 'viewPath' => 'Tests', 'view' => 'index'];
$View = new TestView(null, null, null, $viewOptions);
$paths = $View->paths();
$expected = array_merge(App::path('Template'), App::core('Template'));
$this->assertEquals($expected, $paths);
$paths = $View->paths('TestPlugin');
$pluginPath = Plugin::path('TestPlugin');
$expected = [TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Plugin' . DS . 'TestPlugin' . DS, $pluginPath . 'src' . DS . 'Template' . DS, TEST_APP . 'TestApp' . DS . 'Template' . DS, CAKE . 'Template' . DS];
$this->assertPathEquals($expected, $paths);
}
示例5: testCore
/**
* testCore method
*
* @return void
*/
public function testCore()
{
$model = App::core('Model');
$this->assertEquals(array(CAKE . 'Model' . DS), $model);
$view = App::core('View');
$this->assertEquals(array(CAKE . 'View' . DS), $view);
$controller = App::core('Controller');
$this->assertEquals(array(CAKE . 'Controller' . DS), $controller);
$component = App::core('Controller/Component');
$this->assertEquals(array(CAKE . 'Controller' . DS . 'Component' . DS), str_replace('/', DS, $component));
$auth = App::core('Controller/Component/Auth');
$this->assertEquals(array(CAKE . 'Controller' . DS . 'Component' . DS . 'Auth' . DS), str_replace('/', DS, $auth));
$datasource = App::core('Model/Datasource');
$this->assertEquals(array(CAKE . 'Model' . DS . 'Datasource' . DS), str_replace('/', DS, $datasource));
}
示例6: _paths
/**
* Return all possible paths to find view files in order
*
* @param string $plugin Optional plugin name to scan for view files.
* @param bool $cached Set to false to force a refresh of view paths. Default true.
* @return array paths
*/
protected function _paths($plugin = null, $cached = true)
{
if ($cached === true) {
if ($plugin === null && !empty($this->_paths)) {
return $this->_paths;
}
if ($plugin !== null && isset($this->_pathsForPlugin[$plugin])) {
return $this->_pathsForPlugin[$plugin];
}
}
$paths = array();
$viewPaths = App::path('Template');
$corePaths = App::core('Template');
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('Template', $plugin));
}
$paths = array_unique(array_merge($paths, $viewPaths));
if (!empty($this->theme)) {
$theme = Inflector::camelize($this->theme);
$themePaths = array();
foreach ($paths as $path) {
if (strpos($path, DS . 'Plugin' . DS) === false) {
if ($plugin) {
$themePaths[] = $path . 'Themed' . DS . $theme . DS . 'Plugin' . DS . $plugin . DS;
}
$themePaths[] = $path . 'Themed' . DS . $theme . DS;
}
}
$paths = array_merge($themePaths, $paths);
}
$paths = array_merge($paths, $corePaths);
if ($plugin !== null) {
return $this->_pathsForPlugin[$plugin] = $paths;
}
return $this->_paths = $paths;
}
示例7: _paths
/**
* Return all possible paths to find view files in order
*
* @param string $plugin Optional plugin name to scan for view files.
* @param bool $cached Set to false to force a refresh of view paths. Default true.
* @return array paths
*/
protected function _paths($plugin = null, $cached = true)
{
if ($cached === true) {
if ($plugin === null && !empty($this->_paths)) {
return $this->_paths;
}
if ($plugin !== null && isset($this->_pathsForPlugin[$plugin])) {
return $this->_pathsForPlugin[$plugin];
}
}
$viewPaths = App::path('Template');
$pluginPaths = $themePaths = [];
if (!empty($plugin)) {
for ($i = 0, $count = count($viewPaths); $i < $count; $i++) {
$pluginPaths[] = $viewPaths[$i] . 'Plugin' . DS . $plugin . DS;
}
$pluginPaths = array_merge($pluginPaths, App::path('Template', $plugin));
}
if (!empty($this->theme)) {
$themePaths = App::path('Template', Inflector::camelize($this->theme));
if ($plugin) {
for ($i = 0, $count = count($viewPaths); $i < $count; $i++) {
array_unshift($themePaths, $themePaths[$i] . 'Plugin' . DS . $plugin . DS);
}
}
}
$paths = array_merge($themePaths, $pluginPaths, $viewPaths, App::core('Template'));
if ($plugin !== null) {
return $this->_pathsForPlugin[$plugin] = $paths;
}
return $this->_paths = $paths;
}