本文整理汇总了PHP中Cake\Filesystem\Folder::errors方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::errors方法的具体用法?PHP Folder::errors怎么用?PHP Folder::errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Filesystem\Folder
的用法示例。
在下文中一共展示了Folder::errors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDelete
/**
* testDelete method
*
* @return void
*/
public function testDelete()
{
$path = TMP . 'tests' . DS . 'folder_delete_test';
mkdir($path, 0777, true);
touch($path . DS . 'file_1');
mkdir($path . DS . 'level_1_1');
touch($path . DS . 'level_1_1/file_1_1');
mkdir($path . DS . 'level_1_1/level_2_1');
touch($path . DS . 'level_1_1/level_2_1/file_2_1');
touch($path . DS . 'level_1_1/level_2_1/file_2_2');
mkdir($path . DS . 'level_1_1/level_2_2');
$Folder = new Folder($path, true);
$return = $Folder->delete();
$this->assertTrue($return);
$messages = $Folder->messages();
$errors = $Folder->errors();
$this->assertEquals([], $errors);
$expected = [$path . DS . 'file_1 removed', $path . DS . 'level_1_1' . DS . 'file_1_1 removed', $path . DS . 'level_1_1' . DS . 'level_2_1' . DS . 'file_2_1 removed', $path . DS . 'level_1_1' . DS . 'level_2_1' . DS . 'file_2_2 removed', $path . DS . 'level_1_1' . DS . 'level_2_1 removed', $path . DS . 'level_1_1' . DS . 'level_2_2 removed', $path . DS . 'level_1_1 removed', $path . ' removed'];
sort($expected);
sort($messages);
$this->assertEquals($expected, $messages);
}
示例2: sync
public function sync($id = null)
{
$folder = new Folder();
$folders_to_copy = ['f1' => ['dev' => '../src', 'prod' => '../../production/src'], 'f2' => ['dev' => '../plugins', 'prod' => '../../production/plugins'], 'f3' => ['dev' => '../webroot', 'prod' => '../../production/webroot'], 'f4' => ['dev' => '../config', 'prod' => '../../production/config']];
$pass = 0;
$fail = 0;
foreach ($folders_to_copy as $ftc) {
$p = new Folder($ftc['prod']);
$d = new Folder($ftc['dev']);
if ($folder->copy(['to' => $p->pwd(), 'from' => $d->pwd(), 'scheme' => Folder::MERGE])) {
$pass++;
} else {
$fail++;
}
}
if ($fail == 0) {
$this->Flash->success(__('Production updated successfully.'));
} else {
$errors = '';
foreach ($folder->errors() as $error) {
$errors .= ' : ' . $error;
}
$this->Flash->error(__('Unable to update {0} folders on production. Errors' . $errors, $fail));
}
return $this->redirect($this->referer());
}
示例3: bake
/**
* Bake the plugin, create directories and files
*
* @param string $plugin Name of the plugin in CamelCased format
* @return bool
*/
public function bake($plugin)
{
$pathOptions = App::path('Plugin');
if (count($pathOptions) > 1) {
$this->findPath($pathOptions);
}
$this->hr();
$this->out(sprintf("<info>Plugin Name:</info> %s", $plugin));
$this->out(sprintf("<info>Plugin Directory:</info> %s", $this->path . $plugin));
$this->hr();
$classBase = 'src';
$looksGood = $this->in('Look okay?', ['y', 'n', 'q'], 'y');
if (strtolower($looksGood) === 'y') {
$Folder = new Folder($this->path . $plugin);
$directories = ['config', $classBase . DS . 'Model' . DS . 'Behavior', $classBase . DS . 'Model' . DS . 'Table', $classBase . DS . 'Model' . DS . 'Entity', $classBase . DS . 'Shell' . DS . 'Task', $classBase . DS . 'Controller' . DS . 'Component', $classBase . DS . 'View' . DS . 'Helper', $classBase . DS . 'Template', 'tests' . DS . 'TestCase' . DS . 'Controller' . DS . 'Component', 'tests' . DS . 'TestCase' . DS . 'View' . DS . 'Helper', 'tests' . DS . 'TestCase' . DS . 'Model' . DS . 'Behavior', 'tests' . DS . 'Fixture', 'webroot'];
foreach ($directories as $directory) {
$dirPath = $this->path . $plugin . DS . $directory;
$Folder->create($dirPath);
new File($dirPath . DS . 'empty', true);
}
foreach ($Folder->messages() as $message) {
$this->out($message, 1, Shell::VERBOSE);
}
$errors = $Folder->errors();
if (!empty($errors)) {
foreach ($errors as $message) {
$this->error($message);
}
return false;
}
$controllerFileName = 'AppController.php';
$out = "<?php\n\n";
$out .= "namespace {$plugin}\\Controller;\n\n";
$out .= "use App\\Controller\\AppController as BaseController;\n\n";
$out .= "class AppController extends BaseController {\n\n";
$out .= "}\n";
$this->createFile($this->path . $plugin . DS . $classBase . DS . 'Controller' . DS . $controllerFileName, $out);
$emptyFile = $this->path . 'empty';
$this->_deleteEmptyFile($emptyFile);
$hasAutoloader = $this->_modifyAutoloader($plugin, $this->path);
$this->_generateRoutes($plugin, $this->path);
$this->_modifyBootstrap($plugin, $hasAutoloader);
$this->_generatePhpunitXml($plugin, $this->path);
$this->_generateTestBootstrap($plugin, $this->path);
$this->hr();
$this->out(sprintf('<success>Created:</success> %s in %s', $plugin, $this->path . $plugin), 2);
}
return true;
}