本文整理汇总了PHP中Includes\Utils\FileManager::unlinkRecursive方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::unlinkRecursive方法的具体用法?PHP FileManager::unlinkRecursive怎么用?PHP FileManager::unlinkRecursive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Includes\Utils\FileManager
的用法示例。
在下文中一共展示了FileManager::unlinkRecursive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doActionCleanAggregationCache
/**
* Clean aggregation cache directory
*
* @return void
*/
public function doActionCleanAggregationCache()
{
\Includes\Utils\FileManager::unlinkRecursive(LC_DIR_CACHE_RESOURCES);
\Less_Cache::SetCacheDir(LC_DIR_DATACACHE);
\Less_Cache::CleanCache();
\XLite\Core\TopMessage::addInfo('Aggregation cache has been cleaned');
}
示例2: testGetPublicTitle
public function testGetPublicTitle()
{
\Includes\Utils\FileManager::unlinkRecursive(LC_DIR_FILES . 'attachments');
$attach = $this->getTestAttachment();
$this->assertEquals('max_ava.png', $attach->getPublicTitle(), 'check default title');
$this->assertEquals('', $attach->getTitle(), 'check empty title');
$attach->setTitle('test');
$this->assertEquals('test', $attach->getPublicTitle(), 'check normal title');
}
示例3: executeHookHandler
/**
* Execute certain hook handler
*
* @return void
*/
public function executeHookHandler()
{
// Remove old capsular directories
if (\Includes\Decorator\Utils\CacheManager::isCapsular()) {
$currentKey = \Includes\Decorator\Utils\CacheManager::getKey();
foreach (\Includes\Decorator\Utils\CacheManager::getCacheDirs(true) as $dir) {
$list = glob(rtrim($dir, LC_DS) . '.*');
if ($list) {
foreach ($list as $subdir) {
list($main, $key) = explode('.', $subdir, 2);
if ($key && $key != $currentKey) {
\Includes\Utils\FileManager::unlinkRecursive($subdir);
}
}
}
}
}
\Includes\Decorator\Utils\CacheManager::cleanupCache();
// Load classes from "classes" (do not use cache)
\Includes\Autoloader::switchLcAutoloadDir();
\Includes\Decorator\Plugin\Doctrine\Plugin\QuickData\Main::initializeCounter();
}
示例4: doActionCleanAggregationCache
/**
* Clean aggregation cache directory
*
* @return void
*/
public function doActionCleanAggregationCache()
{
\Includes\Utils\FileManager::unlinkRecursive(LC_DIR_CACHE_RESOURCES);
\XLite\Core\TopMessage::addInfo('Aggregation cache has been cleaned');
$this->setReturnURL($this->buildURL($this->get('target'), '', array('page' => 'Performance')));
}
示例5: uninstallModule
/**
* Uninstall module
*
* @param \XLite\Model\Module $module Module object
* @param array &$messages Messages list
*
* @return boolean
*/
public function uninstallModule(\XLite\Model\Module $module, &$messages)
{
$result = false;
// Get module pack
$pack = new \XLite\Core\Pack\Module($module);
$dirs = $pack->getDirs();
$nonWritableDirs = array();
// Check module directories permissions
foreach ($dirs as $dir) {
if (\Includes\Utils\FileManager::isExists($dir) && !\Includes\Utils\FileManager::isDirWriteable($dir)) {
$nonWritableDirs[] = \Includes\Utils\FileManager::getRelativePath($dir, LC_DIR_ROOT);
}
}
$params = array('name' => sprintf('%s v%s (%s)', $module->getModuleName(), $module->getVersion(), $module->getAuthorName()));
if (empty($nonWritableDirs)) {
$yamlData = array();
$yamlFiles = \Includes\Utils\ModulesManager::getModuleYAMLFiles($module->getAuthor(), $module->getName());
foreach ($yamlFiles as $yamlFile) {
$yamlData[] = \Includes\Utils\FileManager::read($yamlFile);
}
if (!$module->checkModuleMainClass()) {
$classFile = LC_DIR_CLASSES . \Includes\Utils\Converter::getClassFile($module->getMainClass());
if (\Includes\Utils\FileManager::isFileReadable($classFile)) {
require_once $classFile;
}
}
// Call uninstall event method
$r = $module->callModuleMethod('callUninstallEvent', 111);
if (111 == $r) {
\XLite\Logger::getInstance()->log($module->getActualName() . ': Method callUninstallEvent() was not called');
}
// Remove from FS
foreach ($dirs as $dir) {
\Includes\Utils\FileManager::unlinkRecursive($dir);
}
\Includes\Utils\ModulesManager::disableModule($module->getActualName());
\Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName());
// Remove module from DB
try {
// Refresh module entity as it was changed by disableModule() method above
$module = $this->find($module->getModuleID());
$this->delete($module);
} catch (\Exception $e) {
$messages[] = $e->getMessage();
}
if ($module->getModuleID()) {
$messages[] = \XLite\Core\Translation::getInstance()->translate('A DB error occured while uninstalling the module X', $params);
} else {
if (!empty($yamlData)) {
foreach ($yamlData as $yaml) {
\XLite\Core\Database::getInstance()->unloadFixturesFromYaml($yaml);
}
}
$messages[] = \XLite\Core\Translation::getInstance()->translate('The module X has been uninstalled successfully', $params);
$result = true;
}
} else {
$messages[] = \XLite\Core\Translation::getInstance()->translate('Unable to delete module X files: some dirs have no writable permissions: Y', $params + array('dirs' => implode(', ', $nonWritableDirs)));
}
return $result;
}
示例6: deleteFileCallback
/**
* Callback for a common operation for upgrade
*
* @param string $path File short path
* @param boolean $isTestMode If in test mode
*
* @return void
*/
protected function deleteFileCallback($path, $isTestMode)
{
if ($isTestMode) {
if (!\Includes\Utils\FileManager::isDirWriteable($this->manageFile($path, 'getDir'))) {
$this->addFileErrorMessage('File\'s directory is not writable', $path, false);
$this->wrongPermissions[] = $this->manageFile($path, 'getDir');
}
} elseif ($this->manageFile($path, 'deleteFile')) {
$this->addFileInfoMessage('File is deleted', $path, true);
// Remove the parent directory if upgrade process removes all files in it
$dir = dirname($path);
if (\Includes\Utils\FileManager::isEmptyDir($dir)) {
\Includes\Utils\FileManager::unlinkRecursive($dir);
if (!\Includes\Utils\FileManager::isExists($dir)) {
$this->addFileInfoMessage('Directory is deleted', $dir, true);
} else {
$this->addFileInfoMessage('Unable to delete directory', $dir, true);
}
}
} else {
$this->addFileErrorMessage('Unable to delete file', $path, true);
}
}
示例7: doActionUninstall
/**
* Uninstall module
*
* @return void
*/
protected function doActionUninstall()
{
$module = $this->getModule();
if ($module) {
$pack = new \XLite\Core\Pack\Module($module);
$dirs = $pack->getDirs();
$nonWritableDirs = array();
// Check permissions
foreach ($dirs as $dir) {
if (!\Includes\Utils\FileManager::isDirWriteable($dir)) {
$nonWritableDirs[] = \Includes\Utils\FileManager::getRelativePath($dir, LC_DIR_ROOT);
}
}
$params = array('name' => $module->getActualName());
if (empty($nonWritableDirs)) {
$yaml = \Includes\Utils\FileManager::read(\Includes\Utils\ModulesManager::getModuleYAMLFile($module->getAuthor(), $module->getName()));
// Remove from FS
foreach ($dirs as $dir) {
\Includes\Utils\FileManager::unlinkRecursive($dir);
}
// Disable this and depended modules
\Includes\Utils\ModulesManager::disableModule($module->getActualName());
\Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName());
// Remove from DB
\XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->delete($module);
if ($module->getModuleID()) {
$message = 'A DB error occured while uninstalling the module "{{name}}"';
$this->showError(__FUNCTION__, $message, $params);
} else {
if (!empty($yaml)) {
\XLite\Core\Database::getInstance()->unloadFixturesFromYaml($yaml);
}
$message = 'The module "{{name}}" has been uninstalled successfully';
$this->showInfo(__FUNCTION__, $message, $params);
}
// To restore previous state
\XLite\Core\Marketplace::getInstance()->saveAddonsList(0);
// Flag to rebuild cache
\XLite::setCleanUpCacheFlag(true);
} else {
$message = 'Unable to delete module "{{name}}" files: some dirs have no writable permissions: {{dirs}}';
$this->showError(__FUNCTION__, $message, $params + array('dirs' => implode(', ', $nonWritableDirs)));
}
}
}
示例8: cleanupCache
/**
* Clean up the cache
*
* @return void
*/
public static function cleanupCache()
{
foreach (static::$cacheDirs as $dir) {
\Includes\Utils\FileManager::unlinkRecursive($dir);
static::checkPermissions($dir);
}
}
示例9: setUp
protected function setUp()
{
parent::setUp();
\XLite\Core\Database::getEM()->clear();
\Includes\Utils\FileManager::unlinkRecursive(LC_DIR_IMAGES . 'product');
}
示例10: deleteAllFiles
/**
* Delete all files
*
* @return void
*/
public function deleteAllFiles()
{
$dir = \Includes\Utils\FileManager::getRealPath(LC_DIR_VAR . $this->getOptions()->dir);
if (!\Includes\Utils\FileManager::isExists($dir)) {
\Includes\Utils\FileManager::mkdir($dir);
}
$list = glob($dir . LC_DS . '*');
if ($list) {
foreach ($list as $path) {
if (is_file($path)) {
\Includes\Utils\FileManager::deleteFile($path);
} else {
\Includes\Utils\FileManager::unlinkRecursive($path);
}
}
}
}
示例11: setRepositoryPath
/**
* Set repository path
*
* @param string $path Path to set
* @param boolean $preventCheck Flag OPTIONAL
* @param boolean $preventDeletion Flag OPTIONAL
*
* @return void
*/
public function setRepositoryPath($path, $preventCheck = false, $preventDeletion = false)
{
if (!empty($path) && !$preventCheck) {
$path = \Includes\Utils\FileManager::getRealPath($path);
if (empty($path) || !\Includes\Utils\FileManager::isReadable($path)) {
$path = null;
}
}
if (!$preventDeletion && !empty($this->repositoryPath) && $path !== $this->repositoryPath) {
if ($this->isDownloaded()) {
\Includes\Utils\FileManager::deleteFile($this->repositoryPath);
} elseif ($this->isUnpacked()) {
\Includes\Utils\FileManager::deleteFile($this->getCurrentVersionHashesFilePath());
\Includes\Utils\FileManager::unlinkRecursive($this->repositoryPath);
}
}
$this->repositoryPath = $path;
}
示例12: reset
/**
* Reset language driver
*
* @return void
*/
public function reset()
{
\Includes\Utils\FileManager::unlinkRecursive(LC_DIR_LOCALE);
$this->domains = array();
$this->lastLanguage = null;
$this->getRepo()->cleanCache();
}
示例13: saveCode
/**
* Save
*
* @param string $code Code
*
* @return void
*/
protected function saveCode($code)
{
if ("\r\n" != PHP_EOL) {
$code = str_replace("\r\n", PHP_EOL, $code);
}
$code = str_replace(chr(194) . chr(160), ' ', $code);
$file = $this->getFileName();
\Includes\Utils\FileManager::write($file, $code);
if (\Includes\Utils\FileManager::isFileWriteable($file)) {
\XLite\Core\TopMessage::addInfo('Your custom file is successfully saved');
\Includes\Utils\FileManager::deleteFile(str_replace('custom', 'custom.min', $file));
\XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('name' => $this->getBackupName(), 'value' => $code, 'category' => 'XC\\ThemeTweaker'));
\XLite\Core\Config::updateInstance();
$config = \XLite\Core\Config::getInstance()->Performance;
if ($config->aggregate_css || $config->aggregate_js) {
\Includes\Utils\FileManager::unlinkRecursive(LC_DIR_CACHE_RESOURCES);
\XLite\Core\TopMessage::addInfo('Aggregation cache has been cleaned');
}
} else {
\XLite\Core\TopMessage::addError('The file {{file}} does not exist or is not writable.', array('file' => $file));
}
}
示例14: copyRecursive
function copyRecursive($from, $to, $mode = 0666, $dir_mode = 0777)
{
$orig_dir_mode = $dir_mode;
if ($dir_mode == 0777) {
$dir_mode = get_filesystem_permissions(0777);
} elseif ($dir_mode == 0755) {
$dir_mode = get_filesystem_permissions(0755);
}
$orig_mode = $mode;
if ($mode == 0666) {
$mode = get_filesystem_permissions(0666, $from);
} elseif ($mode == 0644) {
$mode = get_filesystem_permissions(0644, $from);
}
if (@is_file($from)) {
@copy($from, $to);
@umask(00);
@chmod($to, $mode);
} elseif (@is_dir($from)) {
if (!@file_exists($to)) {
@umask(00);
$attempts = 5;
while (!@mkdir($to, $dir_mode)) {
\Includes\Utils\FileManager::unlinkRecursive($to);
$attempts--;
if ($attempts < 0) {
echo "Can't create directory {$to}: permission denied";
die;
}
}
}
if ($handle = @opendir($from)) {
while (false !== ($file = @readdir($handle))) {
if (!($file == "." || $file == "..")) {
copyRecursive($from . '/' . $file, $to . '/' . $file, $orig_mode, $orig_dir_mode);
}
}
@closedir($handle);
}
} else {
return 1;
}
}
示例15: suite
/**
* Creates the phpunit test suite
*
* @return PHPUnit_Framework_TestSuite
* @access public
* @see ____func_see____
* @since 1.0.0
*/
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite(ROOT_TEST_SUITE_NAME);
$deploy = null;
$includes = false;
$includeTests = array();
$excludes = array();
$ds = preg_quote(LC_DS, '/');
if (defined('INCLUDE_ONLY_TESTS')) {
$includes = array_map('trim', explode(',', INCLUDE_ONLY_TESTS));
if (in_array('LOCAL_TESTS', $includes)) {
$k = array_search('LOCAL_TESTS', $includes);
unset($includes[$k]);
}
if (in_array('NOWEB', $includes)) {
if (!defined('SELENIUM_DISABLED')) {
define('SELENIUM_DISABLED', true);
}
$k = array_search('NOWEB', $includes);
unset($includes[$k]);
}
if (in_array('ONLYWEB', $includes)) {
if (!defined('UNITS_DISABLED')) {
define('UNITS_DISABLED', true);
}
$k = array_search('ONLYWEB', $includes);
unset($includes[$k]);
}
if (in_array('DEPLOY_DRUPAL', $includes)) {
$deploy = 'Drupal';
} elseif (in_array('DEPLOY_STANDALONE', $includes)) {
$deploy = 'Standalone';
}
if (!is_null($deploy)) {
if (!defined('UNITS_DISABLED')) {
define('UNITS_DISABLED', true);
}
$k = array_search('DEPLOY_' . strtoupper($deploy), $includes);
if (!defined('DIR_TESTS')) {
define('DIR_TESTS', 'Deploy' . LC_DS . $deploy);
}
unset($includes[$k]);
}
if (in_array('W3C', $includes)) {
if (!defined('W3C_VALIDATION')) {
define('W3C_VALIDATION', true);
}
$k = array_search('W3C', $includes);
unset($includes[$k]);
}
foreach ($includes as $k => $v) {
if ('-' == substr($v, 0, 1)) {
$excludes[] = substr($v, 1);
unset($includes[$k]);
}
}
foreach ($includes as $k => $v) {
$tmp = explode(':', $v, 2);
$includes[$k] = $tmp[0];
if (isset($tmp[1])) {
$includeTests[$tmp[0]] = $tmp[1];
}
}
}
if (isset($deploy) && !defined('DEPLOYMENT_TEST')) {
define('DEPLOYMENT_TEST', true);
}
// Include abstract classes
$classesDir = dirname(__FILE__);
$pattern = '/^' . preg_quote($classesDir, '/') . '.*' . $ds . '(?:\\w*Abstract|A[A-Z][a-z]\\w*)\\.php$/Ss';
$dirIterator = new RecursiveDirectoryIterator($classesDir . LC_DS);
$iterator = new RecursiveIteratorIterator($dirIterator, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $filePath => $fileObject) {
if (preg_match($pattern, $filePath, $matches)) {
require_once $filePath;
}
}
// Include fake classes
if (!defined('DEPLOYMENT_TEST')) {
$classesDir = dirname(__FILE__) . LC_DS . 'FakeClass' . LC_DS;
$pattern = '/^' . preg_quote($classesDir, '/') . '.+\\.php$/Ss';
$dirIterator = new RecursiveDirectoryIterator($classesDir . LC_DS);
$iterator = new RecursiveIteratorIterator($dirIterator, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $filePath => $fileObject) {
if (preg_match($pattern, $filePath, $matches)) {
require_once $filePath;
}
}
}
if (!isset($deploy) || !$deploy) {
\Includes\Utils\FileManager::unlinkRecursive(__DIR__ . '/images');
\Includes\Utils\FileManager::mkdirRecursive(__DIR__ . '/images');
//.........这里部分代码省略.........