本文整理汇总了PHP中Gantry\Component\Filesystem\Folder::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::delete方法的具体用法?PHP Folder::delete怎么用?PHP Folder::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gantry\Component\Filesystem\Folder
的用法示例。
在下文中一共展示了Folder::delete方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
/** @var UniformResourceLocator $locator */
$locator = $this->container['locator'];
Folder::delete($locator('gantry-cache://'), false);
return new JsonResponse(['html' => 'Cache was successfully cleared', 'title' => 'Cache Cleared']);
}
示例2: updateCss
/**
* Update all CSS files in the theme.
*
* @param array $configurations
* @return array List of CSS warnings.
*/
public function updateCss(array $configurations = null)
{
$gantry = static::gantry();
$compiler = $this->compiler();
if (is_null($configurations)) {
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$path = $locator->findResource($compiler->getTarget(), true, true);
// Make sure that all the CSS files get deleted.
if (is_dir($path)) {
Folder::delete($path, false);
}
$configurations = $gantry['configurations'];
}
// Make sure that PHP has the latest data of the files.
clearstatcache();
$warnings = [];
foreach ($configurations as $configuration => $title) {
$config = ConfigServiceProvider::load($gantry, $configuration);
$compiler->reset()->setConfiguration($configuration)->setVariables($config->flatten('styles', '-'));
$results = $compiler->compileAll()->getWarnings();
if ($results) {
$warnings[$configuration] = $results;
}
}
return $warnings;
}
示例3: index
public function index()
{
/** @var UniformResourceLocator $locator */
$locator = $this->container['locator'];
Folder::delete($locator('gantry-cache://theme'), false);
Folder::delete($locator('gantry-cache://admin'), false);
// Make sure that PHP has the latest data of the files.
clearstatcache();
return new JsonResponse(['html' => 'Cache was successfully cleared', 'title' => 'Cache Cleared']);
}
示例4: delete
public static function delete($id)
{
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$path = $locator->findResource('gantry-config://' . $id, true, true);
if (is_dir($path)) {
Folder::delete($path, true);
}
}
示例5: updateCss
/**
* Update all CSS files in the theme.
*/
public function updateCss()
{
$gantry = static::gantry();
$compiler = $this->compiler();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$path = $locator->findResource($compiler->getTarget(), true, true);
// Make sure that all the CSS files get deleted.
if (is_dir($path)) {
Folder::delete($path, false);
}
/** @var Configurations $configurations */
$configurations = $gantry['configurations'];
foreach ($configurations as $configuration => $title) {
$config = ConfigServiceProvider::load($gantry, $configuration);
$compiler->reset()->setConfiguration($configuration)->setVariables($config->flatten('styles', '-'));
$compiler->compileAll();
}
}
示例6: delete
public function delete($id)
{
$model = StyleHelper::loadModel();
$item = $model->getTable();
$item->load($id);
if (!$item->id) {
throw new \RuntimeException('Outline not found', 404);
}
try {
if (!$model->delete($id)) {
$error = $model->getError();
// Well, Joomla can always send enqueue message instead!
if (!$error) {
$messages = \JFactory::getApplication()->getMessageQueue();
$message = reset($messages);
$error = $message ? $message['message'] : 'Unknown error';
}
throw new \RuntimeException($error);
}
} catch (\Exception $e) {
throw new \RuntimeException('Deleting outline failed: ' . $e->getMessage(), 400, $e);
}
// Remove configuration directory.
$gantry = $this->container;
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$path = $locator->findResource("{$this->path}/{$item->id}", true, true);
if ($path) {
if (file_exists($path)) {
Folder::delete($path);
}
}
}
示例7: cleanup
public function cleanup()
{
$name = $this->extension->name;
$path = JPATH_SITE . '/templates/' . $name;
// Remove compiled CSS files if they exist.
$cssPath = $path . '/custom/css-compiled';
if (is_dir($cssPath)) {
\JFolder::delete($cssPath);
} elseif (is_file($cssPath)) {
\JFile::delete($cssPath);
}
// Remove wrongly named file if it exists.
$md5path = $path . '/MD5SUM';
if (is_file($md5path)) {
\JFile::delete($md5path);
}
// Restart Gantry and initialize it.
$gantry = Gantry::restart();
$gantry['theme.name'] = $name;
$gantry['streams']->register();
// Only add error service if debug mode has been enabled.
if ($gantry->debug()) {
$gantry->register(new ErrorServiceProvider());
}
/** @var Platform $patform */
$patform = $gantry['platform'];
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
// Initialize theme stream.
$details = new ThemeDetails($name);
$locator->addPath('gantry-theme', '', $details->getPaths(), false, true);
// Initialize theme cache stream and clear theme cache.
$cachePath = $patform->getCachePath() . '/' . $name;
if (is_dir($cachePath)) {
Folder::delete($cachePath);
}
Folder::create($cachePath);
$locator->addPath('gantry-cache', 'theme', [$cachePath], true, true);
$gantry['file.yaml.cache.path'] = $locator->findResource('gantry-cache://theme/compiled/yaml', true, true);
/** @var Outlines $outlines */
$outlines = $gantry['configurations'];
// Update positions in manifest file.
$positions = $outlines->positions();
$manifest = new Manifest($name);
$manifest->setPositions(array_keys($positions));
$manifest->save();
}
示例8: delete
/**
* @param string $id
* @throws \RuntimeException
*/
public function delete($id)
{
if (!$this->canDelete($id)) {
throw new \RuntimeException("Outline '{$id}' cannot be deleted", 400);
}
$gantry = $this->container;
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$path = $locator->findResource("{$this->path}/{$id}", true, true);
if (!is_dir($path)) {
throw new \RuntimeException('Outline not found', 404);
}
if (file_exists($path)) {
Folder::delete($path);
}
}