public function read(Config $source) {
		$path = $source->getPath();

		$sourceData = (object)[
			'baseurl' => $source->baseurl,
			'path' =>  str_replace(realpath($source->getRoot()) . Consts::DS, '', $path),
			'files' => [],
		];

		try {
			$this->accessControl->checkPermission($this->getUserRole(), $this->action, $path);
		} catch (\Exception $e) {
			return $sourceData;
		}


		$dir = opendir($path);

		$config = $this->config;

		while ($file = readdir($dir)) {
			if ($file != '.' && $file != '..' && is_file($path . $file)) {
				$file = new File($path . $file);

				if ($file->isGoodFile($source)) {
					$item = [
						'file' => $file->getPathByRoot($source),
					];

					if ($config->createThumb || !$file->isImage()) {
						$item['thumb'] = Image::getThumb($file, $source)->getPathByRoot($source);
					}

					$item['changed'] = date($config->datetimeFormat, $file->getTime());
					$item['size'] = Helper::humanFileSize($file->getSize());
					$item['isImage'] = $file->isImage();

					$sourceData->files[] = $item;
				}
			}
		}

		return $sourceData;
	}
public function read(Config $source) {
		$path = $source->getPath();

		$sourceData = (object)[
			'baseurl' => $source->baseurl,
			'path' =>  str_replace(realpath($source->getRoot()) . Consts::DS, '', $path),
			'files' => [],
		];

		try {
			$this->accessControl->checkPermission($this->getUserRole(), $this->action, $path);
		} catch (\Exception $e) {
			return $sourceData;
		}


		$dir = opendir($path);

		$config = $this->config;

		while ($file = readdir($dir)) {
			if ($file != '.' && $file != '..' && is_file($path . $file)) {
				$file = new File($path . $file);

				if ($file->isGoodFile($source)) {
					$item = [
						'file' => $file->getPathByRoot($source),
					];

					if ($config->createThumb || !$file->isImage()) {
						$item['thumb'] = Image::getThumb($file, $source)->getPathByRoot($source);
					}

					$item['changed'] = date($config->datetimeFormat, $file->getTime());
					$item['size'] = Helper::humanFileSize($file->getSize());
					$item['isImage'] = $file->isImage();

					$sourceData->files[] = $item;
				}
			}
		}

		return $sourceData;
	}
public function read ( Config $ source ) { $ path = $ source -> getPath ( ) ; $ sourceData = ( object ) [ 'baseurl' => $ source -> baseurl , 'path' => str_replace ( realpath ( $ source -> getRoot ( ) ) . Consts :: DS , '' , $ path ) , 'files' => [ ] , ] ; try { $ this -> accessControl -> checkPermission ( $ this -> getUserRole ( ) , $ this -> action , $ path ) ; } catch ( \ Exception $ e ) { return $ sourceData ; } $ dir = opendir ( $ path ) ; $ config = $ this -> config ; while ( $ file = readdir ( $ dir ) ) { if ( $ file != '.' && $ file != '..' && is_file ( $ path . $ file ) ) { $ file = new File ( $ path . $ file ) ; if ( $ file -> isGoodFile ( $ source ) ) { $ item = [ 'file' => $ file -> getPathByRoot ( $ source ) , ] ; if ( $ config -> createThumb || ! $ file -> isImage ( ) ) { $ item [ 'thumb' ] = Image :: getThumb ( $ file , $ source ) -> getPathByRoot ( $ source ) ; } $ item [ 'changed' ] = date ( $ config -> datetimeFormat , $ file -> getTime ( ) ) ; $ item [ 'size' ] = Helper :: humanFileSize ( $ file -> getSize ( ) ) ; $ item [ 'isImage' ] = $ file -> isImage ( ) ; $ sourceData -> files [ ] = $ item ; } } } return $ sourceData ; }
Read folder and retrun filelist

@param \Jodit\Config $source

@return object
@throws \Exception
Read folder and retrun filelist