CInbox (Common-Inbox)  0.1
Common functionality for ingesting files for archiving.
Public Member Functions | Public Attributes | Protected Attributes | List of all members
CIFolder Class Reference
Inheritance diagram for CIFolder:
CIItem

Public Member Functions

 __construct (&$logger, $folderName, $baseFolder=null)
 
 setFolder ($folderName)
 
 moveFolder ($targetFolder)
 
 getLogger ()
 
 setMoveLogs ($status)
 
 getMoveLogs ()
 
 setParentItem (&$item)
 
 getParentItem ()
 
 setParentFolder (&$folder)
 
 getParentFolder ()
 
 hasParent ()
 
 setBaseFolder ($baseFolder)
 
 getBaseFolder ()
 
 getConfig ()
 
 hasOwnConfig ()
 
 getConfigForFolder ($arguments=null)
 
 getSubDir ()
 
 getPathname ()
 
 getFilename ()
 
 setTempFolder ($tempFolder)
 
 getTempFolder ()
 
 getTargetFolderRaw ()
 
 isTargetAbsolute ()
 
 getTargetFolder ($tempMask=null)
 
 getTargetFolderTemp ($targetFolder, $tempMask)
 
 logTargetFolder ($hasOwn=false, $isAbsolute=true)
 
 getChangelogFile ()
 

Public Attributes

const CONF_TARGET_FOLDER = 'TARGET_FOLDER'
 
const CHANGELOG_FILE = 'folder_changelog.txt'
 

Protected Attributes

 $logger
 
 $moveLogs = false
 
 $folderObj
 
 $config
 
 $tempFolder
 
 $changelog = null
 
 $parentItem
 
 $parentFolder
 
 $hasTargetFolder = null
 

Detailed Description

This is a wrapper around a physical folder. It is used to provide common functionality required across folders of Items in CInbox.

It keeps track of folder hierarchies and applies them to handle the settings read from a configfile so that each folder inherits its settings properly.

Since target folders for Item subfolders can be configured individually, respecting inheritance and relative paths, this class also takes care of putting together the actual target path.

Author
Peter Bubestinger-Steindl (pb@av.nosp@m.-rd..nosp@m.com)
See also

Member Function Documentation

CIFolder::getBaseFolder ( )

Returns the folder used as reference for relative paths.

CIFolder::getChangelogFile ( )

Return the absolute filename of the change-log directory listing.

By default, the changelog file is located in the temp folder and its filename is the basename of its corresponding CIFolder.

CIFolder::getConfig ( )

Returns configuration CIConfig object.

CIFolder::getConfigForFolder (   $arguments = null)

Returns config array for this folder.

Configuration per folder as follows:

  • folder : If subfolder has own config it extends/overwrites DEFAULT configuration.
  • DEFAULT : applies to all subfolders.
  • UNDEFINED : Used as config for folders that have no own. Config behavior identical as if these folders had their own (now) ;)
CIFolder::getFilename ( )

Returns the filename (basename) of this folder object.

CIFolder::getLogger ( )

Returns the logger object used in this class.

CIFolder::getMoveLogs ( )

Returns the status of #moveLogs.

CIFolder::getPathname ( )

Returns the pathname + filename of this folder object.

CIFolder::getSubDir ( )

Returns the pathname + filename of this folder object, but relative to its base folder.

CIFolder::getTargetFolder (   $tempMask = null)

Returns the actual target path for this folder.

The ruleset is as follows:

  • Folder has NO target folder set: Use basename of source sub-folder appended to parent's target folder.
  • Folder has target folder set: absolute path: use as-is. relative path: prepend parent's target folder.

Parameter $tempMask: The parameter "$tempMask" is a printf-style format string which is applied to the basename folder on the CIFolder recursion levels where TARGET_FOLDER is set. This allows maintaining the subfolder-structure on the target, but in a temporary folder. Useful for handling errors that would occur during e.g. copying to target, so that an unfinished/erroneous task does not affect the actual target until it is successful.

CIFolder::getTargetFolderRaw ( )

Returns the unmodified value of TARGET_FOLDER setting (placeholders resolved). If it is not configured for this folder, it returns 'null'.

CIFolder::getTempFolder ( )

Returns the foldername to use for temporary files.

CIFolder::hasParent ( )

Returns 'true' if this folder has a parent folder object set. False if not.

CIFolder::isTargetAbsolute ( )

Checks if the configured target path is absolute or relative.

Returns 'true' if absolute, 'false' if relative and 'NULL' if no target path is configured.

CIFolder::logTargetFolder (   $hasOwn = false,
  $isAbsolute = true 
)

Writes a message in the logs that contains a greppable/parseable string containing the resolved target folder.

$hasOwn = false: Only log if this folder has TARGET_FOLDER set in config file. $isAbsolute = true: Only log if the TARGET_FOLDER is an absolute path.

Returns
bool success True if line was logged, false if not (This is not an error).
CIFolder::moveFolder (   $targetFolder)

Renames/moves the current folder while making sure that all internal things stay working. Parent folders for target must be created before. Returns 'true' on success. Throws exceptions on errors.

CIFolder::setBaseFolder (   $baseFolder)

Sets a base folder as reference to handle relative sub-dir names.

CIFolder::setFolder (   $folderName)

Set the folder that this CIFolder object represents. Populates the property "$folderObj". Returns 'true' on success. Throws exceptions on errors.

CIFolder::setMoveLogs (   $status)

Turn #moveLogs on or off.

CIFolder::setParentFolder ( $folder)

Set parent CIFolder object of that this folder is a subfolder of.

CIFolder::setParentItem ( $item)

Set parent CIItem object of that this folder belongs to.

CIFolder::setTempFolder (   $tempFolder)

Set where temporary files are to be stored in.

Folder must already exist, be writable - and subfolders there must follow naming conventions of Common Inbox, so data can be exchanged in temporary files between different tasks - and Inbox runs.


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