diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..9415fe9 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,83 @@ +setRiskyAllowed(false) + ->setRules([ + '@Symfony' => true, + '@PHP80Migration' => true, + 'array_syntax' => ['syntax' => 'short'], + 'combine_consecutive_unsets' => true, + // one should use PHPUnit methods to set up expected exception instead of annotations + 'general_phpdoc_annotation_remove' => [ + 'annotations' => [ + 'author', + 'package', + 'expectedException', + 'expectedExceptionMessage', + 'expectedExceptionMessageRegExp', + ], + ], + 'function_typehint_space' => false, + 'no_empty_phpdoc' => true, + 'global_namespace_import' => ['import_classes' => true, 'import_functions' => true, 'import_constants' => true], + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => false, 'allow_unused_params' => false], + 'phpdoc_line_span' => ['property' => 'single'], + 'heredoc_to_nowdoc' => true, + 'list_syntax' => ['syntax' => 'short'], + 'blank_line_before_statement' => ['statements' => ['if', 'break', 'continue', 'declare', 'return', 'throw', 'try', 'yield']], + 'no_extra_blank_lines' => [ + 'tokens' => [ + 'break', + 'continue', + 'extra', + 'return', + 'throw', + 'use', + 'parenthesis_brace_block', + 'square_brace_block', + 'curly_brace_block', + ], + ], + 'echo_tag_syntax' => true, + 'method_argument_space' => false, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'ordered_class_elements' => true, + 'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['const', 'class', 'function']], + 'php_unit_test_class_requires_covers' => true, + 'phpdoc_align' => [ + 'tags' => [ + 'param', 'return', 'throws', 'type', 'var' + ], + ], + 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_order' => true, + 'phpdoc_no_alias_tag' => ['replacements' => ['link' => 'website']], + 'phpdoc_summary' => false, + 'phpdoc_to_comment' => false, + 'phpdoc_types_order' => false, // breaks psalm-specific notation sometimes! + 'semicolon_after_instruction' => true, + 'single_blank_line_at_eof' => true, + 'single_line_throw' => false, + 'types_spaces' => false, + 'binary_operator_spaces' => [ + 'default' => 'single_space', + 'operators' => [ + '=' => 'align_single_space_minimal', + '-=' => 'align_single_space_minimal', + '+=' => 'align_single_space_minimal', + '=>' => 'align_single_space_minimal', + '===' => null, + '??=' => 'align_single_space_minimal', + ], + ], + 'concat_space' => [ + 'spacing' => 'one', + ], + 'operator_linebreak' => ['only_booleans' => true, 'position' => 'end'], + 'yoda_style' => false, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__ . '/src') + ); diff --git a/src/Bridge/ElFinderBridge.php b/src/Bridge/ElFinderBridge.php index 18cf683..63f282d 100644 --- a/src/Bridge/ElFinderBridge.php +++ b/src/Bridge/ElFinderBridge.php @@ -2,9 +2,9 @@ namespace FM\ElfinderBundle\Bridge; -use Symfony\Component\HttpFoundation\Session\SessionInterface; -use FM\ElfinderBundle\ElFinder\ElFinder; use elFinderVolumeDriver; +use FM\ElfinderBundle\ElFinder\ElFinder; +use Symfony\Component\HttpFoundation\Session\SessionInterface; class ElFinderBridge extends ElFinder { @@ -19,12 +19,16 @@ public function __construct($opts) parent::__construct($opts); } - /** @param $session */ public function setSession($session) { $this->session = $session; } + public function getVolumes(): array + { + return $this->volumes; + } + /** * @param array $opts */ @@ -32,8 +36,10 @@ protected function mountVolumes($opts) { foreach ($opts['roots'] as $i => $o) { $volume = null; + if (isset($o['service'])) { $driver = $o['service']; + if ($driver instanceof elFinderVolumeDriver) { $volume = $driver; unset($opts['roots'][$i]); @@ -45,6 +51,7 @@ protected function mountVolumes($opts) $id = $volume->id(); $this->volumes[$id] = $volume; + if (!$this->default && $volume->isReadable()) { $this->default = $this->volumes[$id]; } @@ -52,9 +59,4 @@ protected function mountVolumes($opts) } parent::mountVolumes($opts); } - - public function getVolumes(): array - { - return $this->volumes; - } } diff --git a/src/Command/ElFinderInstallerCommand.php b/src/Command/ElFinderInstallerCommand.php index e67945e..5a64271 100644 --- a/src/Command/ElFinderInstallerCommand.php +++ b/src/Command/ElFinderInstallerCommand.php @@ -2,6 +2,7 @@ namespace FM\ElfinderBundle\Command; +use ReflectionClass; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -12,17 +13,16 @@ final class ElFinderInstallerCommand extends Command { - private const ELFINDER_CSS_DIR = 'vendor/studio-42/elfinder/css'; + private const ELFINDER_CSS_DIR = 'vendor/studio-42/elfinder/css'; - private const ELFINDER_JS_DIR = 'vendor/studio-42/elfinder/js'; + private const ELFINDER_JS_DIR = 'vendor/studio-42/elfinder/js'; private const ELFINDER_SOUNDS_DIR = 'vendor/studio-42/elfinder/sounds'; - private const ELFINDER_IMG_DIR = 'vendor/studio-42/elfinder/img'; + private const ELFINDER_IMG_DIR = 'vendor/studio-42/elfinder/img'; protected static $defaultName = 'elfinder:install'; - public function __construct( protected Filesystem $filesystem, protected ParameterBagInterface $parameterBag @@ -36,13 +36,13 @@ protected function configure(): void ->setDescription('Copies elfinder assets to public directory') ->addOption('docroot', null, InputOption::VALUE_OPTIONAL, 'Website document root.', 'public') ->setHelp(<<<'EOF' -Default docroot: - public + Default docroot: + public -You can pass docroot: - Where to install elfinder - php %command.full_name% --docroot=public_html -EOF + You can pass docroot: + Where to install elfinder + php %command.full_name% --docroot=public_html + EOF ); } @@ -57,15 +57,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int $publicDir = sprintf('%s/%s/bundles/fmelfinder', $rootDir, $dr); - $reflection = new \ReflectionClass(\Composer\Autoload\ClassLoader::class); + $reflection = new ReflectionClass(\Composer\Autoload\ClassLoader::class); $vendorRootDir = dirname($reflection->getFileName(), 3); $io->note(sprintf('Starting to install elfinder to %s folder', $publicDir)); - $this->fileSystem->mirror($vendorRootDir.'/'.self::ELFINDER_CSS_DIR, $publicDir.'/css'); - $this->fileSystem->mirror($vendorRootDir.'/'.self::ELFINDER_IMG_DIR, $publicDir.'/img'); - $this->fileSystem->mirror($vendorRootDir.'/'.self::ELFINDER_JS_DIR, $publicDir.'/js'); - $this->fileSystem->mirror($vendorRootDir.'/'.self::ELFINDER_SOUNDS_DIR, $publicDir.'/sounds'); + $this->fileSystem->mirror($vendorRootDir . '/' . self::ELFINDER_CSS_DIR, $publicDir . '/css'); + $this->fileSystem->mirror($vendorRootDir . '/' . self::ELFINDER_IMG_DIR, $publicDir . '/img'); + $this->fileSystem->mirror($vendorRootDir . '/' . self::ELFINDER_JS_DIR, $publicDir . '/js'); + $this->fileSystem->mirror($vendorRootDir . '/' . self::ELFINDER_SOUNDS_DIR, $publicDir . '/sounds'); $io->success('elFinder assets successfully installed'); diff --git a/src/Configuration/ElFinderConfigurationReader.php b/src/Configuration/ElFinderConfigurationReader.php index 8b31b07..323f285 100644 --- a/src/Configuration/ElFinderConfigurationReader.php +++ b/src/Configuration/ElFinderConfigurationReader.php @@ -2,45 +2,43 @@ namespace FM\ElfinderBundle\Configuration; +use Aws\S3\S3Client; +use Barracuda\Copy\API; +use Exception; use FM\ElfinderBundle\Security\ElfinderSecurityInterface; -use League\Flysystem\AdapterInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use League\Flysystem\Filesystem; -use League\Flysystem\Adapter\Local; use League\Flysystem\Adapter\Ftp; -use Spatie\FlysystemDropbox\DropboxAdapter; -use League\Flysystem\Sftp\SftpAdapter; +use League\Flysystem\Adapter\Local; +use League\Flysystem\AdapterInterface; use League\Flysystem\AwsS3v2\AwsS3Adapter as AwsS3v2; use League\Flysystem\AwsS3V3\AwsS3V3Adapter as AwsS3v3; +use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter; +use League\Flysystem\Copy\CopyAdapter; +use League\Flysystem\Filesystem; use League\Flysystem\GridFS\GridFSAdapter; -use OpenCloud\Rackspace; use League\Flysystem\Rackspace\RackspaceAdapter; -use MongoClient; -use League\Flysystem\Copy\CopyAdapter; +use League\Flysystem\Sftp\SftpAdapter; use League\Flysystem\ZipArchive\ZipArchiveAdapter; -use Aws\S3\S3Client; -use Spatie\Dropbox\Client; -use Barracuda\Copy\API; -use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter; use MicrosoftAzure\Storage\Blob\BlobRestProxy; +use MongoClient; +use OpenCloud\Rackspace; +use Spatie\Dropbox\Client; +use Spatie\FlysystemDropbox\DropboxAdapter; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; +use TypeError; /** * Class ElFinderConfigurationReader. */ class ElFinderConfigurationReader implements ElFinderConfigurationProviderInterface { - /** @var array */ protected array $options = []; - /** @var array */ protected array $parameters; - /** @var RequestStack */ protected RequestStack $requestStack; - /** @var ContainerInterface */ protected ContainerInterface $container; public function __construct(array $parameters, RequestStack $requestStack, ContainerInterface $container) @@ -81,45 +79,45 @@ public function getConfiguration(string $instance): array $driver = $this->container->has($parameter['driver']) ? $this->container->get($parameter['driver']) : false; $driverOptions = [ - 'driver' => $parameter['driver'], - 'service' => $driver, - 'glideURL' => $parameter['glide_url'], - 'glideKey' => $parameter['glide_key'], - 'plugin' => $options['plugin'], - 'path' => $pathAndHomeFolder, - 'startPath' => $parameter['start_path'], - 'encoding' => $parameter['encoding'], - 'URL' => $this->getURL($parameter, $request, $homeFolder, $path), - 'alias' => $parameter['alias'], - 'mimeDetect' => $parameter['mime_detect'], - 'mimefile' => $parameter['mimefile'], - 'imgLib' => $parameter['img_lib'], - 'tmbPath' => $parameter['tmb_path'], - 'tmbPathMode' => $parameter['tmb_path_mode'], - 'tmbURL' => $parameter['tmb_url'], - 'tmbSize' => $parameter['tmb_size'], - 'tmbCrop' => $parameter['tmb_crop'], - 'tmbBgColor' => $parameter['tmb_bg_color'], - 'copyOverwrite' => $parameter['copy_overwrite'], - 'copyJoin' => $parameter['copy_join'], - 'copyFrom' => $parameter['copy_from'], - 'copyTo' => $parameter['copy_to'], - 'uploadOverwrite' => $parameter['upload_overwrite'], - 'uploadAllow' => $parameter['upload_allow'], - 'uploadDeny' => $parameter['upload_deny'], - 'uploadMaxSize' => $parameter['upload_max_size'], - 'uploadMaxConn' => $parameter['upload_max_conn'], - 'defaults' => $parameter['defaults'], - 'attributes' => $parameter['attributes'], - 'acceptedName' => $parameter['accepted_name'], - 'disabled' => $parameter['disabled_commands'], - 'treeDeep' => $parameter['tree_deep'], - 'checkSubfolders' => $parameter['check_subfolders'], - 'separator' => $parameter['separator'], - 'timeFormat' => $parameter['time_format'], - 'archiveMimes' => $parameter['archive_mimes'], - 'archivers' => $parameter['archivers'], - 'fileMode' => $parameter['fileMode'], + 'driver' => $parameter['driver'], + 'service' => $driver, + 'glideURL' => $parameter['glide_url'], + 'glideKey' => $parameter['glide_key'], + 'plugin' => $options['plugin'], + 'path' => $pathAndHomeFolder, + 'startPath' => $parameter['start_path'], + 'encoding' => $parameter['encoding'], + 'URL' => $this->getURL($parameter, $request, $homeFolder, $path), + 'alias' => $parameter['alias'], + 'mimeDetect' => $parameter['mime_detect'], + 'mimefile' => $parameter['mimefile'], + 'imgLib' => $parameter['img_lib'], + 'tmbPath' => $parameter['tmb_path'], + 'tmbPathMode' => $parameter['tmb_path_mode'], + 'tmbURL' => $parameter['tmb_url'], + 'tmbSize' => $parameter['tmb_size'], + 'tmbCrop' => $parameter['tmb_crop'], + 'tmbBgColor' => $parameter['tmb_bg_color'], + 'copyOverwrite' => $parameter['copy_overwrite'], + 'copyJoin' => $parameter['copy_join'], + 'copyFrom' => $parameter['copy_from'], + 'copyTo' => $parameter['copy_to'], + 'uploadOverwrite' => $parameter['upload_overwrite'], + 'uploadAllow' => $parameter['upload_allow'], + 'uploadDeny' => $parameter['upload_deny'], + 'uploadMaxSize' => $parameter['upload_max_size'], + 'uploadMaxConn' => $parameter['upload_max_conn'], + 'defaults' => $parameter['defaults'], + 'attributes' => $parameter['attributes'], + 'acceptedName' => $parameter['accepted_name'], + 'disabled' => $parameter['disabled_commands'], + 'treeDeep' => $parameter['tree_deep'], + 'checkSubfolders' => $parameter['check_subfolders'], + 'separator' => $parameter['separator'], + 'timeFormat' => $parameter['time_format'], + 'archiveMimes' => $parameter['archive_mimes'], + 'archivers' => $parameter['archivers'], + 'fileMode' => $parameter['fileMode'], ]; if (null !== $parameter['quarantine']) { @@ -150,6 +148,42 @@ public function getConfiguration(string $instance): array return $options; } + /** + * Simple function to demonstrate how to control file access using "accessControl" callback. + * This method will disable accessing files/folders starting from '.' (dot). + * + * @param string $attr attribute name (read|write|locked|hidden) + * @param string $path file path relative to volume root directory started with directory separator + * + * @return bool|null + */ + public function access($attr, $path, $data, $volume) + { + return str_starts_with(basename($path), '.') // if file/folder begins with '.' (dot) + ? !('read' == $attr || 'write' == $attr) // set read+write to false, other (locked+hidden) set to true + : null; // else elFinder decide it itself + } + + /** + * @return array + */ + protected function parseSecurityConfiguration(ElfinderSecurityInterface $voter) + { + $configuration = $voter->getConfiguration(); + + if (!is_array($configuration)) { + throw new Exception('ElfinderSecurityVoter should return array'); + } + + foreach ($configuration as $role => $commands) { + if ($this->container->get('security.authorization_checker')->isGranted($role)) { + return $commands; + } + } + + return []; + } + private function getURL(array $parameter, Request $request, string $homeFolder, string $path): string { if (isset($parameter['url']) && $parameter['url']) { @@ -157,19 +191,15 @@ private function getURL(array $parameter, Request $request, string $homeFolder, return str_replace('{homeFolder}', $homeFolder, $parameter['url']); } - $path = $parameter['url'].'/'.$homeFolder; + $path = $parameter['url'] . '/' . $homeFolder; } else { - $path = $path.'/'.$homeFolder; + $path = $path . '/' . $homeFolder; } - return $request->getUriForPath('/'.trim($path, '/')); + return $request->getUriForPath('/' . trim($path, '/')); } /** - * @param $opt - * @param $adapter - * @param $serviceName - * * @return Filesystem */ private function configureFlysystem($opt, $adapter, $serviceName) @@ -220,10 +250,11 @@ private function configureFlysystem($opt, $adapter, $serviceName) break; case 'aws_s3_v2': $options = [ - 'key' => $opt['aws_s3_v2']['key'], - 'secret' => $opt['aws_s3_v2']['secret'], - 'region' => $opt['aws_s3_v2']['region'], + 'key' => $opt['aws_s3_v2']['key'], + 'secret' => $opt['aws_s3_v2']['secret'], + 'region' => $opt['aws_s3_v2']['region'], ]; + if (isset($opt['aws_s3_v2']['base_url']) && $opt['aws_s3_v2']['base_url']) { $options['base_url'] = $opt['aws_s3_v2']['base_url']; } @@ -238,6 +269,7 @@ private function configureFlysystem($opt, $adapter, $serviceName) 'endpoint' => $opt['aws_s3_v3']['endpoint'], 'use_path_style_endpoint' => $opt['aws_s3_v3']['use_path_style_endpoint'], ]; + if (!empty($opt['aws_s3_v3']['key']) && !empty($opt['aws_s3_v3']['secret'])) { $s3Options['credentials'] = [ 'key' => $opt['aws_s3_v3']['key'], @@ -284,10 +316,11 @@ private function configureFlysystem($opt, $adapter, $serviceName) break; case 'custom': $adapter = $this->container->get($serviceName); + try { $filesystem = new Filesystem($adapter); - } catch (\TypeError $error) { - throw new \Exception(sprintf('Service %s is not an instance of %s.', $serviceName, AdapterInterface::class)); + } catch (TypeError $error) { + throw new Exception(sprintf('Service %s is not an instance of %s.', $serviceName, AdapterInterface::class)); } break; @@ -299,8 +332,9 @@ private function configureFlysystem($opt, $adapter, $serviceName) private function getFlysystemFilesystem(string $serviceName): Filesystem { $filesystem = $this->container->get($serviceName); + if (!is_object($filesystem) || (!$filesystem instanceof Filesystem)) { - throw new \Exception(sprintf('Service %s is not an instance of %s.', $serviceName, Filesystem::class)); + throw new Exception(sprintf('Service %s is not an instance of %s.', $serviceName, Filesystem::class)); } return $filesystem; @@ -362,16 +396,16 @@ private function configureDriver(array $parameter): array break; case 'box': - $settings['client_id'] = $parameter['box_settings']['client_id']; - $settings['client_secret'] = $parameter['box_settings']['client_secret']; - $settings['accessToken'] = $parameter['box_settings']['accessToken']; - $settings['root'] = $parameter['box_settings']['root']; - $settings['path'] = $parameter['box_settings']['path']; - $settings['separator'] = $parameter['box_settings']['separator']; - $settings['tmbPath'] = $parameter['box_settings']['tmbPath']; - $settings['tmbURL'] = $parameter['box_settings']['tmbURL']; - $settings['acceptedName'] = $parameter['box_settings']['acceptedName']; - $settings['rootCssClass'] = $parameter['box_settings']['rootCssClass']; + $settings['client_id'] = $parameter['box_settings']['client_id']; + $settings['client_secret'] = $parameter['box_settings']['client_secret']; + $settings['accessToken'] = $parameter['box_settings']['accessToken']; + $settings['root'] = $parameter['box_settings']['root']; + $settings['path'] = $parameter['box_settings']['path']; + $settings['separator'] = $parameter['box_settings']['separator']; + $settings['tmbPath'] = $parameter['box_settings']['tmbPath']; + $settings['tmbURL'] = $parameter['box_settings']['tmbURL']; + $settings['acceptedName'] = $parameter['box_settings']['acceptedName']; + $settings['rootCssClass'] = $parameter['box_settings']['rootCssClass']; break; default: @@ -380,42 +414,4 @@ private function configureDriver(array $parameter): array return $settings; } - - /** - * Simple function to demonstrate how to control file access using "accessControl" callback. - * This method will disable accessing files/folders starting from '.' (dot). - * - * @param string $attr attribute name (read|write|locked|hidden) - * @param string $path file path relative to volume root directory started with directory separator - * @param $data - * @param $volume - * - * @return bool|null - */ - public function access($attr, $path, $data, $volume) - { - return str_starts_with(basename($path), '.') // if file/folder begins with '.' (dot) - ? !('read' == $attr || 'write' == $attr) // set read+write to false, other (locked+hidden) set to true - : null; // else elFinder decide it itself - } - - /** - * @return array - */ - protected function parseSecurityConfiguration(ElfinderSecurityInterface $voter) - { - $configuration = $voter->getConfiguration(); - - if (!is_array($configuration)) { - throw new \Exception('ElfinderSecurityVoter should return array'); - } - - foreach ($configuration as $role => $commands) { - if ($this->container->get('security.authorization_checker')->isGranted($role)) { - return $commands; - } - } - - return []; - } } diff --git a/src/Connector/ElFinderConnector.php b/src/Connector/ElFinderConnector.php index e734efd..6bc63b8 100644 --- a/src/Connector/ElFinderConnector.php +++ b/src/Connector/ElFinderConnector.php @@ -11,6 +11,7 @@ public function run($queryParameters = null) if (null === $queryParameters) { $queryParameters = $_GET; } + return $this->execute($queryParameters); } @@ -18,23 +19,24 @@ public function execute($queryParameters) { $isPost = 'POST' == $_SERVER['REQUEST_METHOD']; $src = 'POST' == $_SERVER['REQUEST_METHOD'] ? array_merge($_POST, $queryParameters) : $queryParameters; + if ($isPost && !$src && $rawPostData = @file_get_contents('php://input')) { // for support IE XDomainRequest() $parts = explode('&', $rawPostData); foreach ($parts as $part) { - list($key, $value) = array_pad(explode('=', $part), 2, ''); - $src[$key] = rawurldecode($value); + [$key, $value] = array_pad(explode('=', $part), 2, ''); + $src[$key] = rawurldecode($value); } $_POST = $src; $_REQUEST = array_merge_recursive($src, $_REQUEST); } - $cmd = $src['cmd'] ?? ''; - $args = []; + $cmd = $src['cmd'] ?? ''; + $args = []; if (!function_exists('json_encode')) { $error = $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_JSON); - return $this->output(['error' => '{"error":["'.implode('","', $error).'"]}', 'raw' => true]); + return $this->output(['error' => '{"error":["' . implode('","', $error) . '"]}', 'raw' => true]); } if (!$this->elFinder->loaded()) { @@ -60,6 +62,7 @@ public function execute($queryParameters) if (!is_array($arg)) { $arg = trim($arg); } + if ($req && (!isset($arg) || '' === $arg)) { return $this->output(['error' => $this->elFinder->error(elFinder::ERROR_INV_PARAMS, $cmd)]); } @@ -76,6 +79,7 @@ protected function output(array $data) if (isset($data['pointer'])) { parent::output($data); } + return $data; } } diff --git a/src/Controller/ElFinderController.php b/src/Controller/ElFinderController.php index 598d89f..8335419 100644 --- a/src/Controller/ElFinderController.php +++ b/src/Controller/ElFinderController.php @@ -3,27 +3,27 @@ namespace FM\ElfinderBundle\Controller; use Exception; +use FM\ElfinderBundle\Event\ElFinderPostExecutionEvent; +use FM\ElfinderBundle\Event\ElFinderPreExecutionEvent; use FM\ElfinderBundle\Loader\ElFinderLoader; use FM\ElfinderBundle\Loader\ElFinderLoaderInterface; use FM\ElfinderBundle\Session\ElFinderSession; use Symfony\Component\Asset\Package; use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use FM\ElfinderBundle\Event\ElFinderPreExecutionEvent; -use FM\ElfinderBundle\Event\ElFinderPostExecutionEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Twig\Environment; class ElFinderController { + protected array $params; private Environment $twig; private ElFinderLoaderInterface $loader; - protected array $params; public function __construct(Environment $twig, array $params, ElFinderLoaderInterface $loader) { @@ -44,34 +44,71 @@ public function show(Request $request, string $instance, string $homeFolder): Re if (empty($efParameters['instances'][$instance])) { throw new NotFoundHttpException('Instance not found'); } - $parameters = $efParameters['instances'][$instance]; + $parameters = $efParameters['instances'][$instance]; if (empty($parameters['locale'])) { $parameters['locale'] = $request->getLocale(); } - $assetsPath = $efParameters['assets_path']; - $result = $this->selectEditor($parameters, $instance, $homeFolder, $assetsPath, $request->get('id')); + $assetsPath = $efParameters['assets_path']; + $result = $this->selectEditor($parameters, $instance, $homeFolder, $assetsPath, $request->get('id')); return new Response($this->twig->render($result['template'], $result['params'])); } + public function load(SessionInterface $session, HttpKernelInterface $httpKernel, EventDispatcherInterface $eventDispatcher, Request $request, string $instance, string $homeFolder): JsonResponse + { + $loader = $this->loader; + $efParameters = $this->params; + $loader->initBridge($instance, $efParameters); // builds up the Bridge object for the loader with the given instance + + if ($loader instanceof ElFinderLoader) { + $loader->setSession(new ElFinderSession($session)); + } + + $preExecutionEvent = new ElFinderPreExecutionEvent($request, $httpKernel, $instance, $homeFolder); + $eventDispatcher->dispatch($preExecutionEvent); + + $result = $loader->load($request); // the instance is already set + + $postExecutionEvent = new ElFinderPostExecutionEvent($request, $httpKernel, $instance, $homeFolder, $result); + $eventDispatcher->dispatch($postExecutionEvent); + + // returning result (who may have been modified by a post execution event listener) + return new JsonResponse($postExecutionEvent->getResult()); + } + + public function mainJS(): Response + { + $version = new EmptyVersionStrategy(); + $package = new Package($version); + $mainUrl = $package->getUrl('/bundles/fmelfinder/js'); + + return new Response( + $this->twig->render('@FMElfinder/Elfinder/helper/main.js.twig',['mainUrl' => $mainUrl]), + 200, + [ + 'Content-type' => 'text/javascript', + ] + ); + } + /** * @throws Exception */ private function selectEditor(array $parameters, string $instance, string $homeFolder, string $assetsPath, string $formTypeId = null): array { - $editor = $parameters['editor']; - $locale = $parameters['locale'] ?: $this->container->getParameter('locale'); - $fullScreen = $parameters['fullscreen']; - $relativePath = $parameters['relative_path']; - $pathPrefix = $parameters['path_prefix']; - $theme = $parameters['theme']; + $editor = $parameters['editor']; + $locale = $parameters['locale'] ?: $this->container->getParameter('locale'); + $fullScreen = $parameters['fullscreen']; + $relativePath = $parameters['relative_path']; + $pathPrefix = $parameters['path_prefix']; + $theme = $parameters['theme']; // convert to javascript array - $onlyMimes = count($parameters['visible_mime_types']) - ? "['".implode("','", $parameters['visible_mime_types'])."']" + $onlyMimes = count($parameters['visible_mime_types']) + ? "['" . implode("','", $parameters['visible_mime_types']) . "']" : '[]'; - $result = []; + $result = []; switch ($editor) { case 'custom': @@ -185,53 +222,17 @@ private function selectEditor(array $parameters, string $instance, string $homeF default: $result['template'] = '@FMElfinder/Elfinder/simple.html.twig'; $result['params'] = [ - 'locale' => $locale, - 'fullscreen' => $fullScreen, - 'instance' => $instance, - 'homeFolder' => $homeFolder, - 'prefix' => $assetsPath, - 'onlyMimes' => $onlyMimes, - 'theme' => $theme, - 'pathPrefix' => $pathPrefix, + 'locale' => $locale, + 'fullscreen' => $fullScreen, + 'instance' => $instance, + 'homeFolder' => $homeFolder, + 'prefix' => $assetsPath, + 'onlyMimes' => $onlyMimes, + 'theme' => $theme, + 'pathPrefix' => $pathPrefix, ]; return $result; } } - - public function load(SessionInterface $session, HttpKernelInterface $httpKernel, EventDispatcherInterface $eventDispatcher, Request $request, string $instance, string $homeFolder): JsonResponse - { - $loader = $this->loader; - $efParameters = $this->params; - $loader->initBridge($instance, $efParameters); // builds up the Bridge object for the loader with the given instance - - if ($loader instanceof ElFinderLoader) { - $loader->setSession(new ElFinderSession($session)); - } - - $preExecutionEvent = new ElFinderPreExecutionEvent($request, $httpKernel, $instance, $homeFolder); - $eventDispatcher->dispatch($preExecutionEvent); - - $result = $loader->load($request); // the instance is already set - - $postExecutionEvent = new ElFinderPostExecutionEvent($request, $httpKernel, $instance, $homeFolder, $result); - $eventDispatcher->dispatch($postExecutionEvent); - - // returning result (who may have been modified by a post execution event listener) - return new JsonResponse($postExecutionEvent->getResult()); - } - - public function mainJS(): Response - { - $version = new EmptyVersionStrategy(); - $package = new Package($version); - $mainUrl = $package->getUrl('/bundles/fmelfinder/js'); - return new Response( - $this->twig->render('@FMElfinder/Elfinder/helper/main.js.twig',['mainUrl' => $mainUrl]), - 200, - [ - 'Content-type' => 'text/javascript', - ] - ); - } } diff --git a/src/DependencyInjection/Compiler/ElFinderConfigurationPass.php b/src/DependencyInjection/Compiler/ElFinderConfigurationPass.php index 7180f14..379fe30 100644 --- a/src/DependencyInjection/Compiler/ElFinderConfigurationPass.php +++ b/src/DependencyInjection/Compiler/ElFinderConfigurationPass.php @@ -2,10 +2,15 @@ namespace FM\ElfinderBundle\DependencyInjection\Compiler; +use const E_USER_DEPRECATED; + use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; +use function count; +use function trigger_error; + final class ElFinderConfigurationPass implements CompilerPassInterface { public function process(ContainerBuilder $container): void @@ -19,14 +24,14 @@ public function process(ContainerBuilder $container): void $subscribers = $container->findTaggedServiceIds('fm_elfinder.subscriber'); foreach ($listeners as $serviceId => $tags) { - @\trigger_error('Using "fm_elfinder.listener" tag is deprecated, use "kernel.event_listener" instead.', \E_USER_DEPRECATED); + @trigger_error('Using "fm_elfinder.listener" tag is deprecated, use "kernel.event_listener" instead.', E_USER_DEPRECATED); } foreach ($subscribers as $serviceId => $tags) { - @\trigger_error('Using "fm_elfinder.subscriber" tag is deprecated, use "kernel.event_subscriber" instead.', \E_USER_DEPRECATED); + @trigger_error('Using "fm_elfinder.subscriber" tag is deprecated, use "kernel.event_subscriber" instead.', E_USER_DEPRECATED); } - if (\count($listeners) > 0 || \count($subscribers) > 0) { + if (count($listeners) > 0 || count($subscribers) > 0) { $pass = new RegisterListenersPass('event_dispatcher', 'fm_elfinder.listener', 'fm_elfinder.subscriber'); $pass->process($container); } diff --git a/src/DependencyInjection/Compiler/TwigFormPass.php b/src/DependencyInjection/Compiler/TwigFormPass.php index cf603b2..731f186 100644 --- a/src/DependencyInjection/Compiler/TwigFormPass.php +++ b/src/DependencyInjection/Compiler/TwigFormPass.php @@ -2,8 +2,8 @@ namespace FM\ElfinderBundle\DependencyInjection\Compiler; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; class TwigFormPass implements CompilerPassInterface { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 9987ae9..c384fd2 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -6,6 +6,8 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; +use function method_exists; + final class Configuration implements ConfigurationInterface { /** @@ -486,7 +488,8 @@ private function createDriverOptionsNode() private function createNode($name) { $treeBuilder = new TreeBuilder($name); - if (\method_exists($treeBuilder, 'getRootNode')) { + + if (method_exists($treeBuilder, 'getRootNode')) { $rootNode = $treeBuilder->getRootNode(); } else { $rootNode = $treeBuilder->root($name); diff --git a/src/DependencyInjection/FMElfinderExtension.php b/src/DependencyInjection/FMElfinderExtension.php index 4db100f..163a44d 100644 --- a/src/DependencyInjection/FMElfinderExtension.php +++ b/src/DependencyInjection/FMElfinderExtension.php @@ -3,8 +3,8 @@ namespace FM\ElfinderBundle\DependencyInjection; use FM\ElfinderBundle\Controller\ElFinderController; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; @@ -17,7 +17,7 @@ public function load(array $configs, ContainerBuilder $container): void { $config = $this->processConfiguration(new Configuration(), $configs); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../config')); + $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../config')); $loader->load('elfinder.xml'); $loader->load('form.xml'); $loader->load('command.xml'); diff --git a/src/ElFinder/ElFinder.php b/src/ElFinder/ElFinder.php index 74a9e4d..f61dba1 100644 --- a/src/ElFinder/ElFinder.php +++ b/src/ElFinder/ElFinder.php @@ -3,6 +3,7 @@ namespace FM\ElfinderBundle\ElFinder; use elFinder as BaseElFinder; +use elFinderSession; use elFinderSessionInterface; /** @@ -14,8 +15,6 @@ class ElFinder extends BaseElFinder * Constructor. * * @param array elFinder and roots configurations - * - * @author Dmitry (dio) Levashov */ public function __construct($opts) { @@ -46,6 +45,7 @@ public function __construct($opts) // set error handler of WARNING, NOTICE $errLevel = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_STRICT | E_RECOVERABLE_ERROR; + if (defined('E_DEPRECATED')) { $errLevel |= E_DEPRECATED | E_USER_DEPRECATED; } @@ -59,8 +59,10 @@ public function __construct($opts) // convert PATH_INFO to GET query if (!empty($_SERVER['PATH_INFO'])) { $_ps = explode('/', trim($_SERVER['PATH_INFO'], '/')); + if (!isset($_GET['cmd'])) { $_cmd = $_ps[0]; + if (isset($this->commands[$_cmd])) { $_GET['cmd'] = $_cmd; $_i = 1; @@ -82,6 +84,7 @@ public function __construct($opts) // setup debug mode $this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false); + if ($this->debug) { error_reporting(defined('ELFINDER_DEBUG_ERRORLEVEL') ? ELFINDER_DEBUG_ERRORLEVEL : -1); ini_set('diaplay_errors', '1'); @@ -91,7 +94,7 @@ public function __construct($opts) } if (!interface_exists('elFinderSessionInterface')) { - include_once dirname(__FILE__).'/elFinderSessionInterface.php'; + include_once dirname(__FILE__) . '/elFinderSessionInterface.php'; } // session handler @@ -105,12 +108,13 @@ public function __construct($opts) 'netvolume' => !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes', ], ]; - $this->session = new \elFinderSession($sessionOpts); + $this->session = new elFinderSession($sessionOpts); } // try session start | restart $this->session->start(); $sessionUseCmds = []; + if (isset($opts['sessionUseCmds']) && is_array($opts['sessionUseCmds'])) { $sessionUseCmds = $opts['sessionUseCmds']; } @@ -123,17 +127,20 @@ public function __construct($opts) $this->time = $this->utime(); $this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool) $opts['sessionCloseEarlier'] : true; $this->sessionUseCmds = array_flip($sessionUseCmds); - $this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0); - $this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : ''); - $this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : ''); + $this->timeout = ($opts['timeout'] ?? 0); + $this->uploadTempPath = ($opts['uploadTempPath'] ?? ''); + $this->callbackWindowURL = ($opts['callbackWindowURL'] ?? ''); $this->maxTargets = (isset($opts['maxTargets']) ? intval($opts['maxTargets']) : $this->maxTargets); - self::$commonTempPath = (isset($opts['commonTempPath']) ? $opts['commonTempPath'] : './.tmp'); + self::$commonTempPath = ($opts['commonTempPath'] ?? './.tmp'); + if (!is_writable(self::$commonTempPath)) { self::$commonTempPath = sys_get_temp_dir(); + if (!is_writable(self::$commonTempPath)) { self::$commonTempPath = ''; } } + if (isset($opts['connectionFlagsPath']) && is_writable($opts['connectionFlagsPath'])) { self::$connectionFlagsPath = $opts['connectionFlagsPath']; } else { @@ -143,17 +150,21 @@ public function __construct($opts) if (!empty($opts['tmpLinkPath'])) { self::$tmpLinkPath = $opts['tmpLinkPath']; } + if (!empty($opts['tmpLinkUrl'])) { self::$tmpLinkUrl = $opts['tmpLinkUrl']; } + if (!empty($opts['tmpLinkLifeTime'])) { self::$tmpLinkLifeTime = $opts['tmpLinkLifeTime']; } + if (!empty($opts['textMimes']) && is_array($opts['textMimes'])) { self::$textMimes = $opts['textMimes']; } $this->maxArcFilesSize = isset($opts['maxArcFilesSize']) ? intval($opts['maxArcFilesSize']) : 0; $this->optionsNetVolumes = (isset($opts['optionsNetVolumes']) && is_array($opts['optionsNetVolumes'])) ? $opts['optionsNetVolumes'] : []; + if (isset($opts['itemLockExpire'])) { $this->itemLockExpire = intval($opts['itemLockExpire']); } @@ -164,28 +175,32 @@ public function __construct($opts) // check session cache $_optsMD5 = md5(json_encode($opts['roots'])); + if ($this->session->get('_optsMD5') !== $_optsMD5) { $this->session->set('_optsMD5', $_optsMD5); } // setlocale and global locale regists to elFinder::locale self::$locale = !empty($opts['locale']) ? $opts['locale'] : ('WIN' === substr(PHP_OS, 0, 3) ? 'C' : 'en_US.UTF-8'); + if (false === setlocale(LC_ALL, self::$locale)) { self::$locale = setlocale(LC_ALL, '0'); } // set defaultMimefile - self::$defaultMimefile = (isset($opts['defaultMimefile']) ? $opts['defaultMimefile'] : ''); + self::$defaultMimefile = ($opts['defaultMimefile'] ?? ''); // bind events listeners if (!empty($opts['bind']) && is_array($opts['bind'])) { $_req = 'POST' == $_SERVER['REQUEST_METHOD'] ? $_POST : $_GET; - $_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : ''; + $_reqCmd = $_req['cmd'] ?? ''; foreach ($opts['bind'] as $cmd => $handlers) { $doRegist = (false !== strpos($cmd, '*')); + if (!$doRegist) { $doRegist = ($_reqCmd && in_array($_reqCmd, array_map('self::getCmdOfBind', explode(' ', $cmd)))); } + if ($doRegist) { // for backward compatibility if (!is_array($handlers)) { @@ -198,10 +213,11 @@ public function __construct($opts) foreach ($handlers as $handler) { if ($handler) { if (is_string($handler) && strpos($handler, '.')) { - list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, ''); + [$_domain, $_name, $_method] = array_pad(explode('.', $handler), 3, ''); + if (0 === strcasecmp($_domain, 'plugin')) { - if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : []) - and method_exists($plugin, $_method)) { + if ($plugin = $this->getPluginInstance($_name, $opts['plugin'][$_name] ?? []) and + method_exists($plugin, $_method)) { $this->bind($cmd, [$plugin, $_method]); } } @@ -224,7 +240,7 @@ public function __construct($opts) if (!isset($root['id'])) { // given fixed unique id if (!$root['id'] = $this->getNetVolumeUniqueId($netVolumes)) { - $this->mountErrors[] = 'Netmount Driver "'.$root['driver'].'" : Could\'t given volume id.'; + $this->mountErrors[] = 'Netmount Driver "' . $root['driver'] . '" : Could\'t given volume id.'; continue; } @@ -252,7 +268,7 @@ public function __construct($opts) protected function mountVolumes($opts) { foreach ($opts['roots'] as $i => $o) { - $class = 'elFinderVolume'.(isset($o['driver']) ? $o['driver'] : ''); + $class = 'elFinderVolume' . ($o['driver'] ?? ''); if (class_exists($class)) { $volume = new $class(); @@ -263,25 +279,27 @@ protected function mountVolumes($opts) } // pass session handler $volume->setSession($this->session); + if ($volume->mount($o)) { // unique volume id (ends on "_") - used as prefix to files hash $id = $volume->id(); $this->volumes[$id] = $volume; + if ((!$this->default || $volume->root() !== $volume->defaultPath()) && $volume->isReadable()) { $this->default = $this->volumes[$id]; } } else { $this->removeNetVolume($i, $volume); - $this->mountErrors[] = 'Driver "'.$class.'" : '.implode(' ', $volume->error()); + $this->mountErrors[] = 'Driver "' . $class . '" : ' . implode(' ', $volume->error()); } } catch (Exception $e) { $this->removeNetVolume($i, $volume); - $this->mountErrors[] = 'Driver "'.$class.'" : '.$e->getMessage(); + $this->mountErrors[] = 'Driver "' . $class . '" : ' . $e->getMessage(); } } else { $this->removeNetVolume($i, $volume); - $this->mountErrors[] = 'Driver "'.$class.'" does not exist'; + $this->mountErrors[] = 'Driver "' . $class . '" does not exist'; } } } diff --git a/src/Event/ElFinderPostExecutionEvent.php b/src/Event/ElFinderPostExecutionEvent.php index 55e518c..8b4c0a4 100644 --- a/src/Event/ElFinderPostExecutionEvent.php +++ b/src/Event/ElFinderPostExecutionEvent.php @@ -7,9 +7,7 @@ class ElFinderPostExecutionEvent extends ElFinderPreExecutionEvent { - /** - * Command execution result. - */ + /** Command execution result. */ protected array $result; /** diff --git a/src/Event/ElFinderPreExecutionEvent.php b/src/Event/ElFinderPreExecutionEvent.php index 0e621ac..4c911da 100644 --- a/src/Event/ElFinderPreExecutionEvent.php +++ b/src/Event/ElFinderPreExecutionEvent.php @@ -8,26 +8,18 @@ class ElFinderPreExecutionEvent extends Event { - /** - * Request object containing ElFinder command and parameters. - */ + /** Request object containing ElFinder command and parameters. */ protected Request $request; - /** - * Used to make sub requests. - */ - private HttpKernelInterface $httpKernel; - - /** - * ElFinder instance. - */ + /** ElFinder instance. */ protected string $instance; - /** - * Home folder. - */ + /** Home folder. */ protected string $homeFolder; + /** Used to make sub requests. */ + private HttpKernelInterface $httpKernel; + public function __construct(Request $request, HttpKernelInterface $httpKernel, string $instance, string $homeFolder) { $this->request = $request; diff --git a/src/Form/Type/ElFinderType.php b/src/Form/Type/ElFinderType.php index fb992cf..46f3188 100644 --- a/src/Form/Type/ElFinderType.php +++ b/src/Form/Type/ElFinderType.php @@ -3,9 +3,9 @@ namespace FM\ElfinderBundle\Form\Type; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\FormInterface; +use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; class ElFinderType extends AbstractType @@ -43,9 +43,9 @@ public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefaults([ - 'enable' => true, - 'instance' => 'default', - 'homeFolder' => '', + 'enable' => true, + 'instance' => 'default', + 'homeFolder' => '', ]) ->setAllowedTypes('enable', 'bool') ->setAllowedTypes('instance', ['string', 'null']) diff --git a/src/Loader/ElFinderLoader.php b/src/Loader/ElFinderLoader.php index e91fff4..8b0da0e 100644 --- a/src/Loader/ElFinderLoader.php +++ b/src/Loader/ElFinderLoader.php @@ -2,9 +2,10 @@ namespace FM\ElfinderBundle\Loader; -use FM\ElfinderBundle\Connector\ElFinderConnector; +use Exception; use FM\ElfinderBundle\Bridge\ElFinderBridge; use FM\ElfinderBundle\Configuration\ElFinderConfigurationProviderInterface; +use FM\ElfinderBundle\Connector\ElFinderConnector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\SessionInterface; @@ -34,15 +35,14 @@ public function __construct(ElFinderConfigurationProviderInterface $configurator } /** - * @throws \Exception - * - * @return array + * @throws Exception */ public function configure(): array { $configurator = $this->configurator; + if (!($configurator instanceof ElFinderConfigurationProviderInterface)) { - throw new \Exception('Configurator class must implement ElFinderConfigurationProviderInterface'); + throw new Exception('Configurator class must implement ElFinderConfigurationProviderInterface'); } return $configurator->getConfiguration($this->instance); @@ -53,7 +53,7 @@ public function configure(): array * * @var string * - * @throws \Exception + * @throws Exception */ public function initBridge(string $instance, array $efParameters) { @@ -76,6 +76,7 @@ public function initBridge(string $instance, array $efParameters) } $this->bridge = new ElFinderBridge($this->config); + if ($this->session) { $this->bridge->setSession($this->session); } @@ -91,6 +92,7 @@ public function load(Request $request): array|string if ($this->config['corsSupport']) { return $connector->execute($request->query->all()); } + return $connector->run($request->query->all()); } @@ -121,9 +123,9 @@ public function encode(string $path): mixed return array_values($aPathEncoded)[0]; } elseif (count($aPathEncoded) > 1) { return $aPathEncoded; - } else { - return false; } + + return false; } /** diff --git a/src/Loader/ElFinderLoaderInterface.php b/src/Loader/ElFinderLoaderInterface.php index b902b2a..94953be 100644 --- a/src/Loader/ElFinderLoaderInterface.php +++ b/src/Loader/ElFinderLoaderInterface.php @@ -4,6 +4,7 @@ namespace FM\ElfinderBundle\Loader; +use Exception; use FM\ElfinderBundle\Configuration\ElFinderConfigurationProviderInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\SessionInterface; @@ -11,13 +12,14 @@ interface ElFinderLoaderInterface { /** - * @throws \Exception + * @throws Exception */ public function configure(): array; /** * Configure the Bridge to ElFinder. - * @throws \Exception + * + * @throws Exception */ public function initBridge(string $instance, array $efParameters); @@ -32,4 +34,4 @@ public function encode(string $path): mixed; public function decode(string $hash): string; public function setSession(?SessionInterface $session): void; -} \ No newline at end of file +} diff --git a/src/Session/ElFinderSession.php b/src/Session/ElFinderSession.php index 373038d..79cd308 100644 --- a/src/Session/ElFinderSession.php +++ b/src/Session/ElFinderSession.php @@ -2,9 +2,10 @@ namespace FM\ElfinderBundle\Session; +use elFinderSessionInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface; -class ElFinderSession implements \elFinderSessionInterface +class ElFinderSession implements elFinderSessionInterface { protected SessionInterface $session; diff --git a/src/Twig/Extension/FMElfinderExtension.php b/src/Twig/Extension/FMElfinderExtension.php index 9b3ada7..6b2da26 100644 --- a/src/Twig/Extension/FMElfinderExtension.php +++ b/src/Twig/Extension/FMElfinderExtension.php @@ -36,8 +36,6 @@ public function getFunctions() } /** - * @return mixed - * * @throws LoaderError * @throws RuntimeError * @throws SyntaxError