Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Filter_RealPath Class Reference
Inheritance diagram for Zend_Filter_RealPath:
Zend_Filter_Interface

Public Member Functions

 __construct ($options=true)
 
 getExists ()
 
 setExists ($exists)
 
 filter ($value)
 

Protected Attributes

 $_exists = true
 

Detailed Description

Definition at line 33 of file RealPath.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options = true)

Class constructor

Parameters
boolean | Zend_Config$optionsOptions to set

Definition at line 45 of file RealPath.php.

46  {
47  $this->setExists($options);
48  }
setExists($exists)
Definition: RealPath.php:68

Member Function Documentation

◆ filter()

filter (   $value)

Defined by Zend_Filter_Interface

Returns realpath($value)

Parameters
string$value
Returns
string

Implements Zend_Filter_Interface.

Definition at line 92 of file RealPath.php.

93  {
94  $path = (string) $value;
95  if ($this->_exists) {
96  return realpath($path);
97  }
98 
99  $realpath = @realpath($path);
100  if ($realpath) {
101  return $realpath;
102  }
103 
104  $drive = '';
105  if (substr(PHP_OS, 0, 3) == 'WIN') {
106  $path = preg_replace('/[\\\\\/]/', DIRECTORY_SEPARATOR, $path);
107  if (preg_match('/([a-zA-Z]\:)(.*)/', $path, $matches)) {
108  list($fullMatch, $drive, $path) = $matches;
109  } else {
110  $cwd = getcwd();
111  $drive = substr($cwd, 0, 2);
112  if (substr($path, 0, 1) != DIRECTORY_SEPARATOR) {
113  $path = substr($cwd, 3) . DIRECTORY_SEPARATOR . $path;
114  }
115  }
116  } elseif (substr($path, 0, 1) != DIRECTORY_SEPARATOR) {
117  $path = getcwd() . DIRECTORY_SEPARATOR . $path;
118  }
119 
120  $stack = array();
121  $parts = explode(DIRECTORY_SEPARATOR, $path);
122  foreach ($parts as $dir) {
123  if (strlen($dir) && $dir !== '.') {
124  if ($dir == '..') {
125  array_pop($stack);
126  } else {
127  array_push($stack, $dir);
128  }
129  }
130  }
131 
132  return $drive . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $stack);
133  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$value
Definition: gender.phtml:16

◆ getExists()

getExists ( )

Returns true if the filtered path must exist

Returns
boolean

Definition at line 55 of file RealPath.php.

56  {
57  return $this->_exists;
58  }

◆ setExists()

setExists (   $exists)

Sets if the path has to exist TRUE when the path must exist FALSE when not existing paths can be given

Parameters
boolean | Zend_Config$existsPath must exist
Returns
Zend_Filter_RealPath

Definition at line 68 of file RealPath.php.

69  {
70  if ($exists instanceof Zend_Config) {
71  $exists = $exists->toArray();
72  }
73 
74  if (is_array($exists)) {
75  if (isset($exists['exists'])) {
76  $exists = (boolean) $exists['exists'];
77  }
78  }
79 
80  $this->_exists = (boolean) $exists;
81  return $this;
82  }

Field Documentation

◆ $_exists

$_exists = true
protected

Definition at line 38 of file RealPath.php.


The documentation for this class was generated from the following file: