![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ts.corals.io/corals-api/Corals/core/Elfinder/Console/ |
<?php namespace Corals\Elfinder\Console; use Illuminate\Console\Command; use Illuminate\Filesystem\Filesystem; /** * Publish the elFinder assets to the public directory * * @author Barry vd. Heuvel <[email protected]> */ class PublishCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'elfinder:publish'; /** * The console command description. * * @var string */ protected $description = 'Publish the elFinder assets'; /** @var Filesystem $fs */ protected $files; protected $publishPath; /** * Create a new Publish command * * @param \Illuminate\Filesystem\Filesystem $files * @param string $publishPath */ public function __construct($files, $publishPath) { parent::__construct(); $this->files = $files; $this->publishPath = $publishPath; } /** * Execute the console command. * * @return void */ public function handle() { $package = 'barryvdh/elfinder'; $destination = $this->publishPath . "/packages/{$package}"; if (!is_null($path = $this->getElfinderPath())) { if ($this->files->exists($destination)) { $this->files->deleteDirectory($destination); $this->info('Old published Assets have been removed'); } $copyElfinder = $this->copyElfinderFiles($destination); } else { $copyElfinder = false; $this->error('Could not find elfinder path'); } if (!is_null($path = $this->getPath())) { $copyPublic = $this->files->copyDirectory($path, $destination); } else { $copyPublic = false; $this->error('Could not find public path'); } if ($copyElfinder && $copyPublic) { $this->info('Published assets to: ' . $package); } else { $this->error('Could not publish alles assets for ' . $package); } } /** * Copy specific directories from elFinder to their destination * * @param $destination * @return bool */ protected function copyElfinderFiles($destination) { $result = true; $directories = array('js', 'css', 'img', 'sounds'); $elfinderPath = $this->getElfinderPath(); foreach ($directories as $dir) { $path = $elfinderPath . '/' . $dir; $success = $this->files->copyDirectory($path, $destination . '/' . $dir); $result = $success && $result; } return $result; } /** * Get the path of the public folder, to merge with the elFinder folders. */ protected function getPath() { return __DIR__ . '/../../resources/assets'; } /** * Find the elFinder path from the vendor dir. * * @return string */ protected function getElfinderPath() { $reflector = new \ReflectionClass('elFinder'); return realpath(dirname($reflector->getFileName()) . '/..'); } }