本文整理汇总了PHP中Cake\Filesystem\Folder类的典型用法代码示例。如果您正苦于以下问题:PHP Folder类的具体用法?PHP Folder怎么用?PHP Folder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Folder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: install
/**
* Installing plugin
* @param null $zipPath
* @return array|bool
* @throws CakeException
*/
public function install($zipPath = null)
{
if (!file_exists($zipPath)) {
throw new Exception(__d('spider', 'Invalid plugin file path'));
}
$pluginInfo = $this->getPluginMeta($zipPath);
$pluginHomeDir = App::path('Plugin');
$pluginHomeDir = reset($pluginHomeDir);
$pluginPath = $pluginHomeDir . $pluginInfo->name . DS;
if (is_dir($pluginPath)) {
throw new Exception(__d('spider', 'Plugin already exists'));
}
$Zip = new \ZipArchive();
if ($Zip->open($zipPath) === true) {
new Folder($pluginPath, true);
$Zip->extractTo($pluginPath);
if (!empty($pluginInfo->rootPath)) {
$old = $pluginPath . $pluginInfo->rootPath;
$new = $pluginPath;
$Folder = new Folder($old);
$Folder->move($new);
}
$Zip->close();
return (array) $pluginInfo;
} else {
throw new CakeException(__d('spider', 'Failed to extract plugin'));
}
return false;
}
开发者ID:mohammadsaleh,项目名称:spider,代码行数:35,代码来源:PluginInstaller.php
示例2: testLoadList
/**
* Test plugin load by list.
*
* @return void
*/
public function testLoadList()
{
$Folder = new Folder();
$pluginsDir = APP_ROOT . 'Plugins' . DS;
$TestPlgPath = $pluginsDir . 'PluginTest';
$Folder->create($TestPlgPath, 0777);
new File($TestPlgPath . '/config/bootstrap.php', true);
new File($TestPlgPath . '/config/routes.php', true);
$NoRoutesPlgPath = $pluginsDir . 'NoRoutes';
$Folder->create($NoRoutesPlgPath, 0777);
new File($NoRoutesPlgPath . '/config/bootstrap.php', true);
$NoBootstrapPlgPath = $pluginsDir . 'NoBootstrap';
$Folder->create($NoBootstrapPlgPath, 0777);
new File($NoBootstrapPlgPath . '/config/routes.php', true);
$NoConfigPlgPath = $pluginsDir . 'NoConfig';
$Folder->create($NoConfigPlgPath, 0777);
Plugin::load('Migrations');
Plugin::loadList(['NoConfig', 'NoRoutes', 'PluginTest', 'Migrations', 'NoBootstrap']);
$this->assertTrue(Plugin::loaded('NoBootstrap'));
$this->assertTrue(Plugin::loaded('PluginTest'));
$this->assertTrue(Plugin::loaded('NoRoutes'));
$this->assertTrue(Plugin::loaded('NoConfig'));
// Check virtual paths.
$this->assertSame(1, count(vPath()->getPaths('NoBootstrap:')));
$this->assertSame(1, count(vPath()->getPaths('PluginTest:')));
$this->assertSame(1, count(vPath()->getPaths('NoRoutes:')));
$this->assertSame(1, count(vPath()->getPaths('NoConfig:')));
$Folder->delete($TestPlgPath);
$Folder->delete($NoRoutesPlgPath);
$Folder->delete($NoConfigPlgPath);
$Folder->delete($NoBootstrapPlgPath);
}
开发者ID:UnionCMS,项目名称:Core,代码行数:37,代码来源:PluginTest.php
示例3: initialize
/**
* Overwrite shell initialize to dynamically load all Queue Related Tasks.
*
* @return void
*/
public function initialize()
{
$plugins = Plugin::loaded();
foreach ($plugins as $plugin) {
$pluginPaths = App::path('Shell/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);
}
}
$paths = App::path('Shell/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;
}
parent::initialize();
$this->QueuedTasks->initConfig();
}
开发者ID:repher,项目名称:cakephp-queue,代码行数:31,代码来源:QueueShell.php
示例4: testPostAutoloadDump
/**
* Test composer post autoload dump event.
*
* @return void
*/
public function testPostAutoloadDump()
{
Plugin::load('DebugKit');
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
if (!defined('TMP')) {
define('TMP', sys_get_temp_dir() . DS);
}
$vendorDir = ROOT . 'vendor';
$webRoot = $vendorDir . '/cakephp/debug_kit/webroot';
$assetsDir = $vendorDir . '/cakephp/debug_kit/assets';
if (!is_dir($webRoot) && is_dir($assetsDir)) {
$debugWebroot = new Folder($assetsDir);
$debugWebroot->copy($webRoot);
$debugWebroot->delete($assetsDir);
}
$composer = new Composer();
/** @var Config $config */
$config = new Config();
$config->merge(['config' => ['vendor-dir' => $vendorDir]]);
$composer->setConfig($config);
/** @var IOInterface $io */
$io = $this->getMock('Composer\\IO\\IOInterface');
$event = new Event('postAutoloadDump', $composer, $io);
Installer::postAutoloadDump($event);
Plugin::unload('DebugKit');
}
开发者ID:UnionCMS,项目名称:Core,代码行数:33,代码来源:InstallerTest.php
示例5: tearDown
/**
* @return void
*/
public function tearDown()
{
parent::tearDown();
$dir = new Folder(TMP . 'lock');
$dir->delete();
unset($this->Lock);
}
开发者ID:uafrica,项目名称:delayed-jobs,代码行数:10,代码来源:LockTest.php
示例6: scanFolder
/**
* Scan folder by path.
*
* @param null $path
* @return void|\Cake\Network\Response
*/
public function scanFolder($path = null)
{
if (!$path) {
$path = WWW_ROOT;
}
$Folder = new Folder();
$_path = $this->request->query('path') ? $this->request->query('path') : $path;
if (!is_dir($_path)) {
$Folder->create($_path);
}
$_path = realpath($_path) . DS;
$regex = '/^' . preg_quote(realpath($path), '/') . '/';
if (preg_match($regex, $_path) == false) {
$this->_controller->Flash->error(__d('file_manager', 'Path {0} is restricted', $_path));
return $this->_controller->redirect(['action' => 'browse']);
}
$blacklist = ['.git', '.svn', '.CVS'];
$regex = '/(' . preg_quote(implode('|', $blacklist), '.') . ')/';
if (in_array(basename($_path), $blacklist) || preg_match($regex, $_path)) {
$this->_controller->Flash->error(__d('file_manager', 'Path %s is restricted', $_path));
return $this->_controller->redirect(['action' => 'browse']);
}
$Folder->path = $_path;
$content = $Folder->read();
$this->_controller->set('path', $_path);
$this->_controller->set('content', $content);
}
开发者ID:Cheren,项目名称:union,代码行数:33,代码来源:FileManagerComponent.php
示例7: beforeMarshal
public function beforeMarshal(Event $event, $data, $options)
{
$config = $this->_config;
foreach ($config['fields'] as $fieldKey => $fieldValue) {
$virtualField = $fieldKey;
$file = $data[$fieldKey];
if ((int) $file['error'] === UPLOAD_ERR_NO_FILE) {
continue;
}
if (!isset($fieldValue['path'])) {
throw new \LogicException(__('The path for the {0} field is required.', $fieldKey));
}
if (isset($fieldValue['prefix']) && (is_bool($fieldValue['prefix']) || is_string($fieldValue['prefix']))) {
$this->_prefix = $fieldValue['prefix'];
}
$extension = (new File($file['name'], false))->ext();
$uploadPath = $this->_getUploadPath($data, $fieldValue['path'], $extension);
if (!$uploadPath) {
throw new \ErrorException(__('Error to get the uploadPath.'));
}
$folder = new Folder($this->_config['root']);
$folder->create($this->_config['root'] . dirname($uploadPath));
if ($this->_moveFile($data, $file['tmp_name'], $uploadPath, $fieldKey, $fieldValue)) {
if (!$this->_prefix) {
$this->_prefix = '';
}
$data[$fieldKey] = $uploadPath;
}
}
}
开发者ID:quicake,项目名称:files,代码行数:30,代码来源:UploadBehavior.php
示例8: beforeSave
/**
* Check if there is some files to upload and modify the entity before
* it is saved.
*
* At the end, for each files to upload, unset their "virtual" property.
*
* @param Event $event The beforeSave event that was fired.
* @param Entity $entity The entity that is going to be saved.
*
* @throws \LogicException When the path configuration is not set.
* @throws \ErrorException When the function to get the upload path failed.
*
* @return void
*/
public function beforeSave(Event $event, Entity $entity)
{
$config = $this->_config;
foreach ($config['fields'] as $field => $fieldOption) {
$data = $entity->toArray();
$virtualField = $field . $config['suffix'];
if (!isset($data[$virtualField]) || !is_array($data[$virtualField])) {
continue;
}
$file = $entity->get($virtualField);
if ((int) $file['error'] === UPLOAD_ERR_NO_FILE) {
continue;
}
if (!isset($fieldOption['path'])) {
throw new \LogicException(__('The path for the {0} field is required.', $field));
}
if (isset($fieldOption['prefix']) && (is_bool($fieldOption['prefix']) || is_string($fieldOption['prefix']))) {
$this->_prefix = $fieldOption['prefix'];
}
$extension = (new File($file['name'], false))->ext();
$uploadPath = $this->_getUploadPath($entity, $fieldOption['path'], $extension);
if (!$uploadPath) {
throw new \ErrorException(__('Error to get the uploadPath.'));
}
$folder = new Folder($this->_config['root']);
$folder->create($this->_config['root'] . dirname($uploadPath));
if ($this->_moveFile($entity, $file['tmp_name'], $uploadPath, $field, $fieldOption)) {
if (!$this->_prefix) {
$this->_prefix = '';
}
$entity->set($field, $this->_prefix . $uploadPath);
}
$entity->unsetProperty($virtualField);
}
}
开发者ID:surjit,项目名称:Cake3-Upload,代码行数:49,代码来源:UploadBehavior.php
示例9: includeCmsAdminAssets
/**
* Includes all necessary JS code for admin editing of CmsBlocks.
*
* @return void
*/
public function includeCmsAdminAssets()
{
$script = 'var Cms = {AdminWidgetControllers: {}};';
$this->Html->scriptBlock($script, ['block' => true]);
$this->Html->script('Cms.app/lib/AdminWidgetController.js', ['block' => true]);
$availableWidgets = WidgetManager::getAvailableWidgets();
$adminControllers = [];
$folder = new Folder();
foreach ($availableWidgets as $widgetIdentifier) {
$widget = WidgetFactory::identifierFactory($widgetIdentifier);
$webrootPath = $widget->getWebrootPath();
if (!is_dir($webrootPath)) {
continue;
}
$folder->cd($webrootPath . 'js/');
$jsFiles = $folder->read();
if (empty($jsFiles[1])) {
continue;
}
foreach ($jsFiles[1] as $filename) {
if (strpos($filename, 'AdminWidgetController.js') !== false) {
$adminControllers[] = '/cms/widget/' . $widgetIdentifier . '/js/' . $filename;
}
}
}
$this->Html->script($adminControllers, ['block' => true]);
}
开发者ID:scherersoftware,项目名称:cake-cms,代码行数:32,代码来源:CmsAdminHelper.php
示例10: extract
/**
* Extract valid theme archive.
*
* @return $this|void
*/
public function extract()
{
$Zip = $this->zip();
$Theme = ThemeExtension::getInstance();
$name = $this->_attr->get('name');
$path = $Theme->getPath() . $name . DS;
$alias = Plugin::nameToAlias($name);
$isExits = $this->table()->findByAlias($alias)->first();
if (is_dir($path) && $isExits !== null) {
$this->_setOutput(__d('extensions', 'The theme «{0}» already exits.', sprintf('<strong>%s</strong>', $name)));
}
new Folder($path);
$tmp = $this->_request->data($this->_inputName);
$Zip->open($tmp);
$Zip->extractTo($path);
if (!empty($this->_rootPath[$tmp])) {
$old = $path . DS . $this->_rootPath[$tmp];
$new = $path;
$Folder = new Folder($old);
$Folder->move($new);
}
$this->_setResult(true);
$this->_setOutput(__d('extensions', 'The theme «{0}» has bin successful uploaded.', sprintf('<strong>%s</strong>', $name)), true);
return $this;
}
开发者ID:Cheren,项目名称:union,代码行数:30,代码来源:Theme.php
示例11: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
$Folder = new Folder($this->Task->path . 'BakeTestApp');
$Folder->delete();
unset($this->Task);
}
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:12,代码来源:ProjectTaskTest.php
示例12: clean
/**
* @return int|null
*/
public function clean()
{
if (!empty($this->args[0])) {
$folder = realpath($this->args[0]);
} else {
$folder = APP;
}
$App = new Folder($folder);
$this->out('Cleaning copyright notices in ' . $folder);
$ext = '.*';
if (!empty($this->params['ext'])) {
$ext = $this->params['ext'];
}
$files = $App->findRecursive('.*\\.' . $ext);
$this->out('Found ' . count($files) . ' files.');
$count = 0;
foreach ($files as $file) {
$this->out('Processing ' . $file, 1, Shell::VERBOSE);
$content = $original = file_get_contents($file);
$content = preg_replace('/\\<\\?php\\s*\\s+\\/\\*\\*\\s*\\s+\\* CakePHP.*\\*\\//msUi', '<?php', $content);
if ($content === $original) {
continue;
}
$count++;
if (empty($this->params['dry-run'])) {
file_put_contents($file, $content);
}
}
$this->out('--------');
$this->out($count . ' files fixed.');
}
开发者ID:dereuromark,项目名称:cakephp-setup,代码行数:34,代码来源:CopyrightRemovalShell.php
示例13: _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;
}
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:42,代码来源:TemplateTask.php
示例14: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
unset($this->Task);
$Folder = new Folder($this->path);
$Folder->delete();
Plugin::unload();
}
开发者ID:alexunique0519,项目名称:Blog_Cakephp_association,代码行数:13,代码来源:ExtractTaskTest.php
示例15: removeAndCreateFolder
private function removeAndCreateFolder($path)
{
$dir = new Folder($path);
$dir->delete();
$dir->create($path);
$file = new File($path . DS . 'empty');
$file->create();
}
开发者ID:Jurrieb,项目名称:Eendagdeals,代码行数:8,代码来源:CacheShell.php
示例16: tearDown
public function tearDown()
{
parent::tearDown();
$testPluginFolder = new Folder(ROOT . DS . 'plugins' . DS . 'PluginInstallerTest');
$testPluginFolder->delete();
$testPluginConfigFolder = new Folder(ROOT . DS . 'config' . DS . 'Plugins' . DS . 'PluginInstallerTest');
$testPluginConfigFolder->delete();
}
开发者ID:mswagencia,项目名称:msw-appcore,代码行数:8,代码来源:PluginStarterTest.php
示例17: tearDown
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
unset($this->Model);
TableRegistry::clear();
$folder = new Folder(WWW_ROOT . 'upload');
$folder->delete(WWW_ROOT . 'upload');
}
开发者ID:arourke,项目名称:Cake3-Upload,代码行数:13,代码来源:UploadBehaviorTest.php
示例18: createFileAndDeleteTmp
private function createFileAndDeleteTmp($identifier, $filename)
{
$tmpFolder = new Folder($this->tmpChunkDir($identifier));
$chunkFiles = $tmpFolder->read(true, true, true)[1];
if ($this->createFileFromChunks($chunkFiles, $this->uploadFolder . DIRECTORY_SEPARATOR . $filename) && $this->deleteTmpFolder) {
$tmpFolder->delete();
}
}
开发者ID:PhysikOnline-FFM,项目名称:riedbergtv-video-converter-script,代码行数:8,代码来源:Resumable.php
示例19: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
$this->File->close();
unset($this->File);
$Folder = new Folder();
$Folder->delete(TMP . 'tests/permissions');
}
开发者ID:Slayug,项目名称:castor,代码行数:13,代码来源:FileTest.php
示例20: getTemplatesList
public function getTemplatesList($dir)
{
$basicDir = $dir . $this->subDir;
$dir = new Folder($basicDir);
$templatesList = array_map(function ($dirAddr) use($basicDir) {
return str_replace($basicDir . '/', '', $dirAddr);
}, $dir->findRecursive('.*\\.html'));
return array_combine($templatesList, $templatesList);
}
开发者ID:1emax,项目名称:ea,代码行数:9,代码来源:RoomHelper.php
注:本文中的Cake\Filesystem\Folder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论