Get storage

If no storage has been set, this method will
set and return a default storage, if any such
value is available

@see getDefaultStorage()

@return Filesystem|null storage or null if none storage has been set
764226
public function getStorage(): ?Filesystem
    {
        if (!$this->hasStorage()) {
            $this->setStorage($this->getDefaultStorage());
        }
        return $this->storage;
    }
907710
public function disk()
    {
        if (is_null($this->disk)) {
            $this->disk = app(Disk::class);
        }

        return $this->disk;
    }
966009
public function getDefaultItemDirectory()
    {
        $filesystemId = common_ext_ExtensionsManager::singleton()
            ->getExtensionById('taoItems')
            ->getConfig(self::CONFIG_DEFAULT_FILESOURCE);

        return $this->getServiceManager()
            ->get(FileSystemService::SERVICE_ID)
            ->getDirectory($filesystemId);
    }
944019
public function get($name = null)
    {
        if ($name === null) {
            $name = $this->mainname;
        }
        if (!isset($this->dbs[$name])) {
            throw new Exceptions\StorageNotFound($name);
        }
        return $this->dbs[$name];
    }
297869
private function getJsonStorage()
    {
        if (!$this->jsonStorage) {
            $this->jsonStorage = new JsonStorage(
                $this->getStorage(),
                new JsonConverterProvider($this),
                $this->getJsonEncoder(),
                $this->getJsonDecoder(),
                $this->getFactoryManager()
            );
        }

        return $this->jsonStorage;
    }
79383
public function getFileSystem()
    {
        if (! $this->storage) {
            $this->storage = $this->getServiceLocator()->get(PortableElementFileStorage::SERVICE_ID);
            $this->storage->setServiceLocator($this->getServiceLocator());
            $this->storage->setModel($this->getModel());
        }
        return $this->storage;
    }
918668
protected function get_file() {
        if (!$this->file) {
            return null;
        }
        // The get_file_by_id call can return false, so normalise to null.
        $file = get_file_storage()->get_file_by_id($this->file);
        return ($file) ? $file : null;
    }
413783
public function getFile(): ?Filesystem
    {
        if (!$this->hasFile()) {
            $this->setFile($this->getDefaultFile());
        }
        return $this->file;
    }
786479
public function getStorage()
    {
        if (null === $this->storage) {
            $this->setStorage(new Session(get_called_class()));
        }

        return $this->storage;
    }
941525
public function getFileName()
    {
        if (null == $this->_storeName) {
            $this->_storeName = $this->getDefaultFileName();
        }
        return $this->_storeName;
    }
546721
public function store($name = null)
    {
        $name = $name ?: $this->getDefaultDriver();

        return $this->stores[$name] = $this->get($name);
    }
693846
protected static function getDevicesFromStorage()
    {
        try {
            $file = (static::$deviceFile !== null) ? static::$deviceFile : WS::config()->get('device_storage');
            $content = @file_get_contents($file);
            if (!empty($content)) {
                $devices = json_decode($content, true);
                if(isset($devices['device'])){
                    return $devices['device'];
                }

                return $devices;
            } else {
                return null;
            }
        } catch (\Exception $e) {
            return null;
        }
    }
194588
public function getStorage()
    {
        if ($this->hasToken()) {
            return $this->temporaryStorage->setToken($this->getToken());
        }

        return $this->storage;
    }
1088952
public function get($key = '', $default = null)
    {
        $key = $this->getCompositeKey($key);
        if (empty($key)) {
            return $this->storage;
        }
        return ArrayHelper::getValue($this->storage, $key, $default);
    }
1016648
private function getStorage()
    {
        $folder = $this->folder;
        if (!is_dir($folder)) {
            if (!mkdir($folder, 0777, true)) {
                throw new Exception("Can not create Filesystem folder: '" . $folder . "'. Please verify permissions.");
            }
        }

        return $folder;
    }
748589
public function getExportStorageFolder($default = null)
    {
        $folder = array_get($this->manifest, 'storage.folder', array_get($this->manifest, 'storage.path', $default));

        return (empty($folder)) ? $default : $folder;
    }
298046
public function getCloudStorage(): ?Cloud
    {
        if (!$this->hasCloudStorage()) {
            $this->setCloudStorage($this->getDefaultCloudStorage());
        }
        return $this->cloudStorage;
    }