Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 72 lines (63 sloc) 1.605 kB
bd07823 @vicb [Finder] Add support for relative path
vicb authored
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
db96c6a @fabpot replaced symfony-project.org by symfony.com
fabpot authored
6 * (c) Fabien Potencier <fabien@symfony.com>
bd07823 @vicb [Finder] Add support for relative path
vicb authored
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Finder;
13
14 /**
15 * Extends \SplFileInfo to support relative paths
16 *
db96c6a @fabpot replaced symfony-project.org by symfony.com
fabpot authored
17 * @author Fabien Potencier <fabien@symfony.com>
bd07823 @vicb [Finder] Add support for relative path
vicb authored
18 */
19 class SplFileInfo extends \SplFileInfo
20 {
4e85ff1 @fabpot [Finder] moved most protected methods and properties to private
fabpot authored
21 private $relativePath;
22 private $relativePathname;
bd07823 @vicb [Finder] Add support for relative path
vicb authored
23
24 /**
25 * Constructor
26 *
215b265 @pborreli [Phpdoc] Cleaning/fixing
pborreli authored
27 * @param string $file The file name
28 * @param string $relativePath The relative path
29 * @param string $relativePathname The relative path name
bd07823 @vicb [Finder] Add support for relative path
vicb authored
30 */
31 public function __construct($file, $relativePath, $relativePathname)
32 {
33 parent::__construct($file);
34 $this->relativePath = $relativePath;
35 $this->relativePathname = $relativePathname;
36 }
37
38 /**
39 * Returns the relative path
40 *
41 * @return string the relative path
42 */
43 public function getRelativePath()
44 {
45 return $this->relativePath;
46 }
47
48 /**
49 * Returns the relative path name
50 *
51 * @return string the relative path name
52 */
53 public function getRelativePathname()
54 {
55 return $this->relativePathname;
56 }
25382fa @gajdaw [2.1][Component][Finder] $this->current() fix
gajdaw authored
57
58 /**
59 * Returns the contents of the file
60 *
61 * @return string the contents of the file
62 */
63 public function getContents()
64 {
5337704 @fabpot fixed CS
fabpot authored
65 $file = new \SplFileObject($this->getRealpath(), 'rb');
4350d11 @gajdaw [Component][Finder][SplFileInfo] file_get_contents=>fpassthru
gajdaw authored
66 ob_start();
67 $file->fpassthru();
5337704 @fabpot fixed CS
fabpot authored
68
4350d11 @gajdaw [Component][Finder][SplFileInfo] file_get_contents=>fpassthru
gajdaw authored
69 return ob_get_clean();
25382fa @gajdaw [2.1][Component][Finder] $this->current() fix
gajdaw authored
70 }
4e85ff1 @fabpot [Finder] moved most protected methods and properties to private
fabpot authored
71 }
Something went wrong with that request. Please try again.