/**
  * @param string $path
  * @return string
  */
 protected function getPath($path = '')
 {
     $root = strtr(App::path(), '\\', '/');
     $path = $this->normalizePath($root . '/storage/' . $path);
     if (!is_dir($path)) {
         App::file()->makeDir($path);
     }
     return $path;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function getSource()
 {
     if (!($path = $this->getPath())) {
         return parent::getSource();
     }
     $path = App::file()->getUrl($path);
     if ($version = $this->getOption('version')) {
         $path .= (false === strpos($path, '?') ? '?' : '&') . 'v=' . $version;
     }
     return $path;
 }
Example #3
0
 /**
  * @param  array $uninstall
  * @return bool
  */
 public function uninstall($uninstall)
 {
     foreach ((array) $uninstall as $name) {
         if (!($package = App::package($name))) {
             throw new \RuntimeException(__('Unable to find "%name%".', ['%name%' => $name]));
         }
         $this->disable($package);
         $this->getScripts($package)->uninstall();
         App::config('system')->remove('packages.' . $package->get('module'));
         if ($this->composer->isInstalled($package->getName())) {
             $this->composer->uninstall($package->getName());
         } else {
             if (!($path = $package->get('path'))) {
                 throw new \RuntimeException(__('Package path is missing.'));
             }
             $this->output->writeln(__("Removing package folder."));
             App::file()->delete($path);
             @rmdir(dirname($path));
         }
     }
 }
 /**
  * @return bool|string
  */
 public function getCachepath()
 {
     $folder = App::path() . '/' . App::module('bixie/portfolio')->config('cache_path');
     if (file_exists($folder) && is_writable($folder)) {
         //all fine, quick return
         return $folder;
     }
     //try to create user-folder
     App::file()->makeDir($folder, 0755);
     if (!file_exists($folder)) {
         //create default folder
         $folder = $this->app['path.cache'] . '/portfolio';
         if (!file_exists($folder)) {
             App::file()->makeDir($folder, 0755);
         }
     }
     if (!file_exists($folder) || !is_writable($folder)) {
         //give up
         return false;
     }
     return $folder;
 }
Example #5
0
 /**
  * @Request({"names": "array"})
  */
 public function removeFilesAction($names)
 {
     foreach ($names as $name) {
         if (!($path = $this->getPath($name))) {
             return $this->error(__('Invalid path.'));
         }
         if ('w' !== $this->getMode($path)) {
             throw new ForbiddenException(__('Permission denied.'));
         }
         try {
             App::file()->delete($path);
         } catch (\Exception $e) {
             return $this->error(__('Unable to remove.'));
         }
     }
     return $this->success(__('Removed selected.'));
 }
 /**
  * @return bool|string
  */
 public function getImageCachepath()
 {
     if ($folder = App::locator()->get(App::module('bixie/framework')->config('image_cache_path')) and is_writable($folder)) {
         //all fine, quick return
         return $folder;
     }
     //try to create user-folder
     App::file()->makeDir($folder, 0755);
     if (!file_exists($folder)) {
         //create default folder
         $folder = $this->app['path.storage'] . '/bixframework';
         if (!file_exists($folder)) {
             App::file()->makeDir($folder, 0755);
         }
     }
     if (!file_exists($folder) || !is_writable($folder)) {
         //give up
         return false;
     }
     return $folder;
 }
 /**
  * @param array $options
  */
 public static function clearCache($options = [])
 {
     if (@$options['temp'] and $cache_path = App::module('bixie/portfolio')->getCachepath()) {
         App::file()->delete($cache_path);
     }
 }
Example #8
0
 /**
  * @param array $options
  */
 public static function clearCache($options = [])
 {
     if (@$options['temp'] and $cache_path = App::module('bixie/framework')->getImageCachepath()) {
         App::file()->delete($cache_path);
     }
 }
 /**
  * @param array $options
  */
 public static function clearCache($options = [])
 {
     if (@$options['temp']) {
         App::file()->delete(App::get('path.cache') . '/portfolio');
     }
 }
Example #10
0
 /**
  * TODO: clear opcache
  */
 public function doClearCache(array $options = [])
 {
     // clear cache
     if (empty($options) || @$options['cache']) {
         App::cache()->flushAll();
         foreach (glob(App::get('path.cache') . '/*.cache') as $file) {
             @unlink($file);
         }
     }
     // clear temp folder
     if (@$options['temp']) {
         foreach (App::finder()->in(App::get('path.temp'))->depth(0)->ignoreDotFiles(true) as $file) {
             App::file()->delete($file->getPathname());
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getSource()
 {
     return ($path = $this->getPath()) ? App::file()->getUrl($path) : parent::getSource();
 }