[ Index ]

PHP Cross Reference of PHK Manager

title

Body

[close]

/PHK/ -> Mgr.php (summary)

(no description)

Copyright: Francois Laupretre <phk@tekwire.net>
License: http://www.apache.org/licenses/LICENSE-2.0 Apache License, V 2.0
File Size: 569 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Mgr:: (22 methods):
  isMounted()
  validate()
  instance()
  proxy()
  mntList()
  setCache()
  cacheEnabled()
  pathToMnt()
  topLevelPath()
  mount()
  getStoreData()
  computeMnt()
  umount()
  uri()
  isPhkUri()
  baseURI()
  commandURI()
  sectionURI()
  automapURI()
  normalizeURI()
  uriToMnt()
  checkPhpVersion()


Class: Mgr  - X-Ref

The PHK manager

This class manages the table of currently mounted packages.

Each package is uniquely identified by a 'mount point' (a string computed
at mount time). A given package file always gets the same mount point in
every request, as long as it is not modified.

Among others, this class allows to mount and umount packages.

Runtime code -> 100% read-only.

Static-only
API status: Public
Included in the PHK PHP runtime: Yes
Implemented in the extension: Yes
isMounted($mnt)   X-Ref
Checks if a mount point is valid (if it corresponds to a currently mounted
package)

param: string $mnt Mount point to check
return: boolean

validate($mnt)   X-Ref
Same as isMounted but throws an exception is the mount point is invalid.

Returns the mount point so that it can be embedded in a call string.

param: string $mnt Mount point to check
return: string mount point (not modified)

instance($mnt)   X-Ref
Returns the PHK object corresponding to a given mount point

param: string $mnt Mount point
return: PHK instance

proxy($mnt)   X-Ref
Returns the \PHK\Proxy object corresponding to a given mount point

If the corresponding \PHK\Proxy object does not exist yet, it is created.

param: string $mnt Mount point
return: \PHK\Proxy proxy object

mntList()   X-Ref
Returns the list of the defined mount points.

return: array

setCache($caching)   X-Ref
Sets the global caching toggle

Normally, the global cache toggle is always null, except in 'webinfo'
mode, where it is false to inhibit any caching of webinfo information
(2 reasons: useless in terms of performance, and could use the same keys as
the 'non-webinfo' mode, so we would have to use another key prefix).

param: boolean|null $caching True: always cache, False: never cache,
return: void

cacheEnabled($mnt,$command,$params,$path)   X-Ref
Determines if a an URI can be cached.

For performance reasons, the input URI is splitted.

Called by the wrapper to know if it should cache the data it got from its
backend.

The global cache toggle is checked first. If it is null, control is
transferred to the instance logic.

param: string|null $mnt Mount point or null if global command
param: string|null $command command if defined
param: array|null $params Command parameters if defined
param: string $path Path
return: boolean whether the data should be cached or not

pathToMnt($path)   X-Ref
Given a file path, tries to determine if it is currently mounted. If it is
the case, the corresponding mount point is returned. If not, an exception is
thrown.

Note: when dealing with sub-packages, the input path parameter can be a PHK
URI.

param: string $path Path of a PHK package
return: the corresponding mount point

topLevelPath($path)   X-Ref
Given a PHK uri, returns the path of the first-level package for
this path. The function recurses until it finds a physical path.

param: string $path A path typically set as '__FILE__'
return: the physical path of the 1st-level package containing this path

mount($path,$flags=0)   X-Ref
Mount a PHK package and returns the new (or previous, if already loaded)
PHK mount point.

Can also create empty \PHK\Build\Creator instances (when the 'CREATOR' flag is set).

param: string $path The path of an existing PHK archive, or the path of the
param: int $flags Or-ed combination of PHK mount flags.
return: string the mount point

getStoreData($mnt,&$options,&$buildInfo)   X-Ref
Checks the PHK version this package requires against the current version.
Then, retrieves the 'options' and 'buildInfo' arrays.

This function is separated from mount() to mimic the behavior of the PHK
extension, where this data is cached in persistent memory.

param: string $mnt the mount point
param: array $options on return, contains the options array
param: array $buildInfo on return, contains the buildInfo array
return: void

computeMnt($path,&$parentMnt,&$mnt,&$mtime)   X-Ref
Computes the mount point corresponding to a given path.

Also returns the parent mount point (for sub-packages), and the modification
time (allows to call stat() only once).

Mount point uniqueness is based on a combination of device+inode+mtime.

When dealing with sub-packages, the input path is a PHK URI.

Sub-packages inherit their parent's modification time.

param: string $path The path to be mounted
param: $parentMnt string|null returns the parent mount point. Not
param: string $mnt returns the computed mount point
param: int $mtime returns the modification time
return: void

umount($mnt)   X-Ref
Umounts a mounted package and any mounted descendant.

We dont use __destruct because :
1. We don't want this to be called on script shutdown
2. \Exceptions cannot be caught when sent from a destructor.

Accepts to remove a non registered mount point without error

param: string $mnt The mount point to umount

uri($mnt,$path)   X-Ref
Builds a 'phk://' uri, from a mount ID and a path

param: string $mnt The mount point
param: string $path The path
return: string The computed URI

isPhkUri($uri)   X-Ref
No description

baseURI($mnt)   X-Ref
Returns the base string used to build URIs for a given mount point.

The base URI has the form : phk://<mount point>/

param: string $mnt A mount point
return: string

commandURI($mnt,$command)   X-Ref
Returns a 'command' URI, given a mount point and a 'command' string

Command URIs have the form : phk://<mount point>/?<command>

param: string $mnt A mount point
param: string $command Command string
return: string

sectionURI($mnt,$section)   X-Ref
Returns the URI allowing to retrieve a section.

Section URIs have the form : phk://<mount point>/?section&name=<section>

param: string $mnt A mount point
param: string $section The section to retrieve
return: string

automapURI($mnt)   X-Ref
Returns the URI of the Automap map if it is defined

param: string $mnt A mount point
return: string|null returns null if the package does not define an automap.

normalizeURI($uri)   X-Ref
Replaces '\' characters by '/' in a URI.

param: string $uri
return: string

uriToMnt($uri)   X-Ref
Returns the mount ID of a subfile's phk uri.
Allows to reference other subfiles in the same package if you don't want
or cannot use Automap (the preferred method) or a relative path.
Example : include(\PHK\Mgr::uri(\PHK\Mgr::uriToMnt(__FILE__),<path>));

param: string $uri
return: string a mount point

checkPhpVersion()   X-Ref
Check if the current PHP version is supported.

Note that, if PHP version < 5.3, parsing fails because of namespaces and we
don't even start execution. So, this test is only executed when PHP version
>= 5.3

As a side effect, until we require a version > 5.3, this function
never fails.

Calls exit(1) if PHP version is not supported by the PHK runtime

return: void



Generated: Thu Jun 4 18:33:15 2015 Cross-referenced by PHPXref 0.7.1