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

Public Member Functions

 __construct ($params)
 
 getFolders ($rootFolder=null)
 
 selectFolder ($globalName)
 
 getCurrentFolder ()
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from Zend_Mail_Storage_Mbox
 countMessages ()
 
 getSize ($id=0)
 
 getMessage ($id)
 
 getRawHeader ($id, $part=null, $topLines=0)
 
 getRawContent ($id, $part=null)
 
 __construct ($params)
 
 close ()
 
 noop ()
 
 removeMessage ($id)
 
 getUniqueId ($id=null)
 
 getNumberByUniqueId ($id)
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from Zend_Mail_Storage_Abstract
 __get ($var)
 
 getCapabilities ()
 
 countMessages ()
 
 getSize ($id=0)
 
 getMessage ($id)
 
 getRawHeader ($id, $part=null, $topLines=0)
 
 getRawContent ($id, $part=null)
 
 __construct ($params)
 
 __destruct ()
 
 close ()
 
 noop ()
 
 removeMessage ($id)
 
 getUniqueId ($id=null)
 
 getNumberByUniqueId ($id)
 
 count ()
 
 offsetExists ($id)
 
 offsetGet ($id)
 
 offsetSet ($id, $value)
 
 offsetUnset ($id)
 
 rewind ()
 
 current ()
 
 key ()
 
 next ()
 
 valid ()
 
 seek ($pos)
 

Protected Member Functions

 _buildFolderTree ($currentDir, $parentFolder=null, $parentGlobalName='')
 
- Protected Member Functions inherited from Zend_Mail_Storage_Mbox
 _getPos ($id)
 
 _isMboxFile ($file, $fileIsString=true)
 
 _openMboxFile ($filename)
 

Protected Attributes

 $_rootFolder
 
 $_rootdir
 
 $_currentFolder
 
- Protected Attributes inherited from Zend_Mail_Storage_Mbox
 $_fh
 
 $_filename
 
 $_filemtime
 
 $_positions
 
 $_messageClass = 'Zend_Mail_Message_File'
 
- Protected Attributes inherited from Zend_Mail_Storage_Abstract
 $_has
 
 $_iterationPos = 0
 
 $_iterationMax = null
 
 $_messageClass = 'Zend_Mail_Message'
 

Detailed Description

Definition at line 47 of file Mbox.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $params)

Create instance with parameters

Disallowed parameters are:

  • filename use Zend_Mail_Storage_Mbox for a single file Supported parameters are:
  • dirname rootdir of mbox structure
  • folder intial selected folder, default is 'INBOX'
Parameters
array$paramsmail reader specific parameters
Exceptions
Zend_Mail_Storage_Exception
See also
Zend_Mail_Storage_Exception
Zend_Mail_Storage_Exception

Definition at line 79 of file Mbox.php.

80  {
81  if (is_array($params)) {
82  $params = (object)$params;
83  }
84 
85  if (isset($params->filename)) {
89  #require_once 'Zend/Mail/Storage/Exception.php';
90  throw new Zend_Mail_Storage_Exception('use Zend_Mail_Storage_Mbox for a single file');
91  }
92 
93  if (!isset($params->dirname) || !is_dir($params->dirname)) {
97  #require_once 'Zend/Mail/Storage/Exception.php';
98  throw new Zend_Mail_Storage_Exception('no valid dirname given in params');
99  }
100 
101  $this->_rootdir = rtrim($params->dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
102 
103  $this->_buildFolderTree($this->_rootdir);
104  $this->selectFolder(!empty($params->folder) ? $params->folder : 'INBOX');
105  $this->_has['top'] = true;
106  $this->_has['uniqueid'] = false;
107  }
_buildFolderTree($currentDir, $parentFolder=null, $parentGlobalName='')
Definition: Mbox.php:121
selectFolder($globalName)
Definition: Mbox.php:200
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

Member Function Documentation

◆ __sleep()

__sleep ( )

magic method for serialize()

with this method you can cache the mbox class

Returns
array name of variables

Definition at line 247 of file Mbox.php.

248  {
249  return array_merge(parent::__sleep(), array('_currentFolder', '_rootFolder', '_rootdir'));
250  }

◆ __wakeup()

__wakeup ( )

magic method for unserialize()

with this method you can cache the mbox class

Returns
null

Definition at line 259 of file Mbox.php.

260  {
261  // if cache is stall selectFolder() rebuilds the tree on error
263  }

◆ _buildFolderTree()

_buildFolderTree (   $currentDir,
  $parentFolder = null,
  $parentGlobalName = '' 
)
protected

find all subfolders and mbox files for folder structure

Result is save in Zend_Mail_Storage_Folder instances with the root in $this->_rootFolder. $parentFolder and $parentGlobalName are only used internally for recursion.

Parameters
string$currentDircall with root dir, also used for recursion.
Zend_Mail_Storage_Folder | null$parentFolderused for recursion
string$parentGlobalNameused for rescursion
Returns
null
Exceptions
Zend_Mail_Storage_Exception
See also
Zend_Mail_Storage_Exception

Definition at line 121 of file Mbox.php.

122  {
123  if (!$parentFolder) {
124  $this->_rootFolder = new Zend_Mail_Storage_Folder('/', '/', false);
125  $parentFolder = $this->_rootFolder;
126  }
127 
128  $dh = @opendir($currentDir);
129  if (!$dh) {
133  #require_once 'Zend/Mail/Storage/Exception.php';
134  throw new Zend_Mail_Storage_Exception("can't read dir $currentDir");
135  }
136  while (($entry = readdir($dh)) !== false) {
137  // ignore hidden files for mbox
138  if ($entry[0] == '.') {
139  continue;
140  }
141  $absoluteEntry = $currentDir . $entry;
142  $globalName = $parentGlobalName . DIRECTORY_SEPARATOR . $entry;
143  if (is_file($absoluteEntry) && $this->_isMboxFile($absoluteEntry)) {
144  $parentFolder->$entry = new Zend_Mail_Storage_Folder($entry, $globalName);
145  continue;
146  }
147  if (!is_dir($absoluteEntry) /* || $entry == '.' || $entry == '..' */) {
148  continue;
149  }
150  $folder = new Zend_Mail_Storage_Folder($entry, $globalName, false);
151  $parentFolder->$entry = $folder;
152  $this->_buildFolderTree($absoluteEntry . DIRECTORY_SEPARATOR, $folder, $globalName);
153  }
154 
155  closedir($dh);
156  }
_buildFolderTree($currentDir, $parentFolder=null, $parentGlobalName='')
Definition: Mbox.php:121
_isMboxFile($file, $fileIsString=true)
Definition: Mbox.php:250

◆ getCurrentFolder()

getCurrentFolder ( )

get Zend_Mail_Storage_Folder instance for current folder

Returns
Zend_Mail_Storage_Folder instance of current folder
Exceptions
Zend_Mail_Storage_Exception

Implements Zend_Mail_Storage_Folder_Interface.

Definition at line 235 of file Mbox.php.

236  {
237  return $this->_currentFolder;
238  }

◆ getFolders()

getFolders (   $rootFolder = null)

get root folder or given folder

Parameters
string$rootFolderget folder structure for given folder, else root
Returns
Zend_Mail_Storage_Folder root or wanted folder
Exceptions
Zend_Mail_Storage_Exception
See also
Zend_Mail_Storage_Exception

Implements Zend_Mail_Storage_Folder_Interface.

Definition at line 165 of file Mbox.php.

166  {
167  if (!$rootFolder) {
168  return $this->_rootFolder;
169  }
170 
171  $currentFolder = $this->_rootFolder;
172  $subname = trim($rootFolder, DIRECTORY_SEPARATOR);
173  while ($currentFolder) {
174  @list($entry, $subname) = @explode(DIRECTORY_SEPARATOR, $subname, 2);
175  $currentFolder = $currentFolder->$entry;
176  if (!$subname) {
177  break;
178  }
179  }
180 
181  if ($currentFolder->getGlobalName() != DIRECTORY_SEPARATOR . trim($rootFolder, DIRECTORY_SEPARATOR)) {
185  #require_once 'Zend/Mail/Storage/Exception.php';
186  throw new Zend_Mail_Storage_Exception("folder $rootFolder not found");
187  }
188  return $currentFolder;
189  }

◆ selectFolder()

selectFolder (   $globalName)

select given folder

folder must be selectable!

Parameters
Zend_Mail_Storage_Folder | string$globalNameglobal name of folder or instance for subfolder
Returns
null
Exceptions
Zend_Mail_Storage_Exception
See also
Zend_Mail_Storage_Exception
Zend_Mail_Storage_Exception

Implements Zend_Mail_Storage_Folder_Interface.

Definition at line 200 of file Mbox.php.

201  {
202  $this->_currentFolder = (string)$globalName;
203 
204  // getting folder from folder tree for validation
205  $folder = $this->getFolders($this->_currentFolder);
206 
207  try {
208  $this->_openMboxFile($this->_rootdir . $folder->getGlobalName());
209  } catch(Zend_Mail_Storage_Exception $e) {
210  // check what went wrong
211  if (!$folder->isSelectable()) {
215  #require_once 'Zend/Mail/Storage/Exception.php';
216  throw new Zend_Mail_Storage_Exception("{$this->_currentFolder} is not selectable", 0, $e);
217  }
218  // seems like file has vanished; rebuilding folder tree - but it's still an exception
219  $this->_buildFolderTree($this->_rootdir);
223  #require_once 'Zend/Mail/Storage/Exception.php';
224  throw new Zend_Mail_Storage_Exception('seems like the mbox file has vanished, I\'ve rebuild the ' .
225  'folder tree, search for an other folder and try again', 0, $e);
226  }
227  }
_buildFolderTree($currentDir, $parentFolder=null, $parentGlobalName='')
Definition: Mbox.php:121
getFolders($rootFolder=null)
Definition: Mbox.php:165
_openMboxFile($filename)
Definition: Mbox.php:282

Field Documentation

◆ $_currentFolder

$_currentFolder
protected

Definition at line 65 of file Mbox.php.

◆ $_rootdir

$_rootdir
protected

Definition at line 59 of file Mbox.php.

◆ $_rootFolder

$_rootFolder
protected

Definition at line 53 of file Mbox.php.


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