Provides method for creating image drivers implementing P4Cms_Image_Driver_Interface.
More...
List of all members.
Static Public Member Functions |
static | create ($className=null) |
| Create and return a single instance of an image driver implementing P4Cms_Image_Driver_Interface.
|
static | getDriverClasses () |
| Return list of driver classes the factory is aware of.
|
static | isValidType ($className) |
| Determine if the given Image driver type is valid.
|
Static Protected Attributes |
static | $_drivers |
Detailed Description
Provides method for creating image drivers implementing P4Cms_Image_Driver_Interface.
- Copyright:
- 2011-2012 Perforce Software. All rights reserved
- License:
- Please see LICENSE.txt in top-level folder of this distribution.
- Version:
- 2012.2/486814
Member Function Documentation
static P4Cms_Image_Driver_Factory::create |
( |
$ |
className = null | ) |
[static] |
Create and return a single instance of an image driver implementing P4Cms_Image_Driver_Interface.
- Parameters:
-
string | $className | optional - driver class name; if omitted, first driver that can be instantiated from the following list (in given order) will be returned: imagick, gmagick, gd |
- Returns:
- P4Cms_Image_Driver_Interface an image driver implementation
- Exceptions:
-
{
if ($className) {
if (!static::isValidType($className)) {
throw new P4Cms_Image_Exception(
"Cannot create a driver: Class " . $className . " is not a valid image driver."
);
}
return new $className;
}
foreach (static::$_drivers as $driver) {
try {
return new $driver;
} catch (P4Cms_Image_Exception $e) {
}
}
throw new P4Cms_Image_Exception("Cannot create image driver.");
}
static P4Cms_Image_Driver_Factory::getDriverClasses |
( |
| ) |
[static] |
Return list of driver classes the factory is aware of.
- Returns:
- array list with available driver classes
static P4Cms_Image_Driver_Factory::isValidType |
( |
$ |
className | ) |
[static] |
Determine if the given Image driver type is valid.
- Parameters:
-
string | $className | the driver implementation class name to check |
- Returns:
- bool true if the given Driver class exists and implements P4Cms_Image_Driver_Interface, false otherwise
{
if (!class_exists($className)) {
return false;
}
if (!in_array('P4Cms_Image_Driver_Interface', class_implements($className))) {
return false;
}
return true;
}
Member Data Documentation
P4Cms_Image_Driver_Factory::$_drivers [static, protected] |
Initial value: array(
'P4Cms_Image_Driver_Imagick',
'P4Cms_Image_Driver_Gd'
)
The documentation for this class was generated from the following file: