Finds the media by his path.

@param string $path
@return array
@throws NotFoundHttpException
338379
private function findMedia($path)
    {
        /** @var \Ekyna\Bundle\MediaBundle\Model\MediaInterface $media */
        $media = $this
            ->get('ekyna_media.media.repository')
            ->findOneBy(['path' => $path])
        ;
        if (null === $media) {
            throw new NotFoundHttpException('Media not found');
        }

        $fs = $this->get('local_media_filesystem');
        if (!$fs->has($media->getPath())) {
            throw new NotFoundHttpException('Media not found');
        }
        $file = $fs->get($media->getPath());

        return [$media, $file];
    }
705540
public function readStream($path)
    {
        $contents = $this->client->getObject($this->bucket, $path);

        if ($contents != null) {
            $stream = fopen('php://temp', 'w+b');
            fwrite($stream, $contents);
            rewind($stream);

            return ['path' => $path, 'stream' => $stream];
        }

        return false;
    }
622218
private function lsLegacy(string $path) : array
    {
        $list = [];
        foreach ($this->nlist($path) as $name) {
            $type   = $this->isDir($name) ? 'dir' : 'file';
            $size   = $this->size($name);
            $mtime  = $this->mdtm($name);

            if ($mtime == -1) {
                throw new RuntimeException('FTP server doesnt support \'ftp_mdtm\'');
            }

            $list[] = new File(['name' => $name, 'modify' => $mtime, 'type' => $type, 'size' => $size]);
        }
        return $list;
    }
1039945
public function file($path)
    {
        return $this->files(dirname($path))->first(function ($file) use ($path) {
            return $file['path'] === $path;
        }, function () use ($path) {
            throw new FileNotFoundException("File [$path] not found!");
        });
    }
1068140
protected function getContents(/*# string */ $path)/*# string */
    {
        // read in file
        $contents = @file_get_contents($path);

        // failed
        if (false === $contents) {
            throw new NotFoundException(
                Message::get(Message::CONFIG_FILE_NOTFOUND, $path),
                Message::CONFIG_FILE_NOTFOUND
            );
        }
        return $contents;
    }
500268
private function getImagePath($path)
    {
        if ($path && file_exists($this->filesystem->getRootDir() . $path)) {
            return $path;
        }

        return $this->noImagePath;
    }
1148879
protected function getFileInfo($path)
    {
        return [
            'name' => substr($path, strrpos($path, '/') + 1),
            'path' => $path,
            'url'  => $this->getFileUrl($path),
        ];
    }
1001693
public function getSourcePath($path)
    {
        $path = trim($path, '/');
        
        $baseUrl = $this->baseUrl.'/';

        if (substr($path, 0, strlen($baseUrl)) === $baseUrl) {
            $path = trim(substr($path, strlen($baseUrl)), '/');
        }

        if ($path === '') {
            throw new FileNotFoundException('Image path missing.');
        }

        if ($this->sourcePathPrefix) {
            $path = $this->sourcePathPrefix.'/'.$path;
        }

        return rawurldecode($path);
    }
22415
public function getUrl($path)
    {
        if ($this->publish($path)) {
            $obj = $this->getFileObject($path);
            if ($url = $obj->getWebContentLink()) {
                return str_replace('export=download', 'export=media', $url);
            }
            if ($url = $obj->getWebViewLink()) {
                return $url;
            }
        }
        return false;
    }
315606
protected function getSourceFiles($path)
    {
        $files = [];
        foreach (glob($path.'/*.php') as $file) {
            $files[] = $file;
        }

        return $files;
    }
1009458
public function browseAction($path)
    {
        $currentProfile = $this->getCurrentProfile();

        $repository = $this->getDoctrine()->getRepository('HarvestCloudCoreBundle:Category');

        $category = $repository->findOneByPath($path);

        if (!$category)
        {
            throw $this->createNotFoundException('No category found for path '.$path);
        }

        // Set up and empty filter
        $filter = new ProductFilter();
        $filter->setLatitude($currentProfile->getDefaultLocation()->getLatitude());
        $filter->setLongitude($currentProfile->getDefaultLocation()->getLongitude());
        $filter->setRange(100);
        $filter->category = $category;

        $products = $this->getRepo('Product')
            ->findForSearchFilter($filter, $this->getCurrentCart())
        ;

        return $this->render('HarvestCloudMarketPlaceBuyerBundle:Default:index.html.twig', array(
          'products' => $products,
        ));
    }
488949
public function readStream($path)
    {
        $location = $this->applyPathPrefix($path);
        $resource = ($this->ossClient->isUseSSL() ? 'https://' : 'http://') . $this->bucket . '.' . $this->endpoint . '/' . $location;
        return [
            'stream' => $resource = fopen($resource, 'r')
        ];
    }
1178850
protected function getFiles($path)
    {
        $path = Str::finish($path, '/');

        if (file_exists($path . App::getLocale())) {
            return File::files($path . App::getLocale());
        } elseif (file_exists($path . config('app.fallback_locale'))) {
            return File::files($path . config('app.fallback_locale'));
        }

        return [];
    }
942980
public function read($path)
    {
        $location = $this->applyPathPrefix($path);
        return [
            'contents' => $this->ossClient->getObject($this->bucket, $location)
        ];
    }
659047
protected function getScandir($path) {
		$files = array();
		
		!isset($this->dirsCache[$path]) && $this->cacheDir($path);

		foreach ($this->dirsCache[$path] as $p) {
			if (($stat = $this->stat($p)) && empty($stat['hidden'])) {
				$files[] = $stat;
			}
		}

		return $files;
	}
1021491
public function match(string $path): array
    {
        $path = $path === '/' ? $path : \rtrim($path, '/ ');

        if (!isset($this->routes[$path])) {
            return [self::NOT_FOUND, $path];
        }

        return [self::FOUND, $this->routes[$path]];
    }
131130
private function getImageInfoFormatData( string $path ) : array
	{
		if( !file_exists( $path ) ){
			throw new \Exception( "该文件不存在" );
		}
		$data         = [
			// 纯名字
			'name' => '',
			// 相对路径
			'path' => '',
			// 文件字节
			'size' => 0,
			// 媒体类型
			'type' => '',
		];
		$data['name'] = $this->fileName;
		$data['path'] = $path;
		$data['size'] = filesize( $path );
		$data['type'] = $this->mediaType;
		return $data;
	}