本文整理汇总了PHP中xPDO::loadClass方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::loadClass方法的具体用法?PHP xPDO::loadClass怎么用?PHP xPDO::loadClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDO
的用法示例。
在下文中一共展示了xPDO::loadClass方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put
/**
* Wrap artifact with an {@link xPDOVehicle} and register in the transport.
*
* @param mixed $artifact An artifact to load into the transport.
* @param array $attributes A set of attributes related to the artifact; these
* can be anything from rules describing how to pack or unpack the artifact,
* or any other data that might be useful when dealing with a transportable
* artifact.
*/
public function put($artifact, $attributes = array())
{
$added = false;
if (!empty($artifact)) {
$vehiclePackage = isset($attributes['vehicle_package']) ? $attributes['vehicle_package'] : '';
$vehiclePackagePath = isset($attributes['vehicle_package_path']) ? $attributes['vehicle_package_path'] : '';
$vehicleClass = isset($attributes['vehicle_class']) ? $attributes['vehicle_class'] : '';
if (empty($vehiclePackage)) {
$vehiclePackage = $attributes['vehicle_package'] = 'transport';
}
if (empty($vehicleClass)) {
$vehicleClass = $attributes['vehicle_class'] = 'xPDOObjectVehicle';
}
if ($className = $this->xpdo->loadClass("{$vehiclePackage}.{$vehicleClass}", $vehiclePackagePath, true, true)) {
$vehicle = new $className();
$vehicle->put($this, $artifact, $attributes);
if ($added = $vehicle->store($this)) {
$this->registerVehicle($vehicle);
}
} else {
$this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "The specified xPDOVehicle class ({$vehiclePackage}.{$vehicleClass}) could not be loaded.");
}
}
return $added;
}
示例2: getProfilePhoto
/**
* Retrieve the profile photo, if any
*
* @param int $width The desired photo width
* @param int $height The desired photo height
*
* @return string The photo URL
*/
public function getProfilePhoto($width = 128, $height = 128)
{
if (empty($this->Profile->photo)) {
return '';
}
$this->xpdo->loadClass('sources.modMediaSource');
/** @var modMediaSource $source */
$source = modMediaSource::getDefaultSource($this->xpdo, $this->xpdo->getOption('photo_profile_source'));
$source->initialize();
$path = $source->getBasePath($this->Profile->photo) . $this->Profile->photo;
return $this->xpdo->getOption('connectors_url', MODX_CONNECTORS_URL) . "system/phpthumb.php?zc=1&h={$height}&w={$width}&src={$path}";
}
示例3: getValidator
/**
* Get the xPDOValidator class configured for this instance.
*
* @return string|boolean The xPDOValidator instance or false if it could
* not be loaded.
*/
public function getValidator() {
if (!is_object($this->_validator)) {
$validatorClass = $this->xpdo->loadClass('validation.xPDOValidator', XPDO_CORE_PATH, true, true);
if ($derivedClass = $this->getOption(xPDO::OPT_VALIDATOR_CLASS)) {
if ($derivedClass = $this->xpdo->loadClass($derivedClass, '', false, true)) {
$validatorClass = $derivedClass;
}
}
if ($validatorClass) {
$this->_validator= new $validatorClass($this);
}
}
return $this->_validator;
}
示例4: getDashboard
/**
* Get the dashboard for this user
*
* @return modDashboard
*/
public function getDashboard()
{
$this->xpdo->loadClass('modDashboard');
/** @var modUserGroup $userGroup */
$userGroup = $this->getPrimaryGroup();
if ($userGroup) {
/** @var modDashboard $dashboard */
$dashboard = $userGroup->getOne('Dashboard');
if (empty($dashboard)) {
$dashboard = modDashboard::getDefaultDashboard($this->xpdo);
}
} else {
$dashboard = modDashboard::getDefaultDashboard($this->xpdo);
}
return $dashboard;
}
示例5: loadCollection
/**
* Custom collection loader that forces access policy checking.
*
* {@inheritdoc}
*/
public static function loadCollection(xPDO &$xpdo, $className, $criteria = null, $cacheFlag = true)
{
$objCollection = array();
if (!($className = $xpdo->loadClass($className))) {
return $objCollection;
}
$rows = false;
$fromCache = false;
$collectionCaching = (int) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
if (!is_object($criteria)) {
$criteria = $xpdo->getCriteria($className, $criteria, $cacheFlag);
}
if (is_object($criteria)) {
if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag) {
$rows = $xpdo->fromCache($criteria, $className);
$fromCache = is_array($rows) && !empty($rows);
}
if (!$fromCache) {
$rows = xPDOObject::_loadRows($xpdo, $className, $criteria);
}
$cacheRows = array();
if (is_array($rows)) {
foreach ($rows as $row) {
if (modAccessibleObject::_loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag)) {
if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag && !$fromCache) {
$cacheRows[] = $row;
}
}
}
} elseif (is_object($rows)) {
while ($row = $rows->fetch(PDO::FETCH_ASSOC)) {
if (modAccessibleObject::_loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag)) {
if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag && !$fromCache) {
$cacheRows[] = $row;
}
}
}
}
if (!$fromCache && $xpdo->_cacheEnabled && $collectionCaching > 0 && $cacheFlag && !empty($cacheRows)) {
$xpdo->toCache($criteria, $cacheRows, $cacheFlag);
}
} else {
$xpdo->log(xPDO::LOG_LEVEL_ERROR, 'modAccessibleObject::loadCollection() - No valid statement could be found in or generated from the given criteria.');
}
return $objCollection;
}
示例6: getHash
/**
* Get a hash implementation instance.
*
* The implementation is made available as a member variable of the modHashing service.
*
* @param string $key A key string identifying the instance; must be a valid PHP variable name.
* @param string $class A valid fully-qualified modHash derivative class name
* @param array $options
* @return array|null
*/
public function getHash($key, $class, array $options = array()) {
$className = $this->modx->loadClass($class, '', false, true);
if ($className) {
if (empty($key)) $key = strtolower(str_replace('mod', '', $className));
if (!array_key_exists($key, $this->_hashes)) {
$hash = new $className($this);
if ($hash instanceof $className) {
$this->_hashes[$key] = $hash;
$this->$key =& $this->_hashes[$key];
}
}
if (array_key_exists($key, $this->_hashes)) {
return $this->_hashes[$key];
}
}
return null;
}
示例7: array
$properties = array();
$f = dirname(__FILE__) . '/build.properties.php';
$included = false;
if (file_exists($f)) {
$included = @(include $f);
}
if (!$included) {
die('build.properties.php was not found. Please make sure you have created one using the template of build.properties.sample.php.');
}
unset($f, $included);
/* instantiate xpdo instance */
$xpdo = new xPDO(XPDO_DSN, XPDO_DB_USER, XPDO_DB_PASS, array(xPDO::OPT_TABLE_PREFIX => XPDO_TABLE_PREFIX, xPDO::OPT_CACHE_PATH => MODX_CORE_PATH . 'cache/'), array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
$cacheManager = $xpdo->getCacheManager();
$xpdo->setLogLevel(xPDO::LOG_LEVEL_INFO);
$xpdo->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$xpdo->loadClass('transport.xPDOTransport', XPDO_CORE_PATH, true, true);
$packageDirectory = MODX_CORE_PATH . 'packages/';
$xpdo->log(xPDO::LOG_LEVEL_INFO, 'Beginning build script processes...');
flush();
/* remove pre-existing package files and directory */
if (file_exists($packageDirectory . 'core.transport.zip')) {
@unlink($packageDirectory . 'core.transport.zip');
}
if (file_exists($packageDirectory . 'core') && is_dir($packageDirectory . 'core')) {
$cacheManager->deleteTree($packageDirectory . 'core', array('deleteTop' => true, 'skipDirs' => false, 'extensions' => '*'));
}
if (!file_exists($packageDirectory . 'core') && !file_exists($packageDirectory . 'core.transport.zip')) {
$xpdo->log(xPDO::LOG_LEVEL_INFO, 'Removed pre-existing core/ and core.transport.zip.');
flush();
} else {
$xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Could not remove core/ and core.transport.zip before starting build.');
示例8: loadCollection
/**
* Custom collection loader that forces access policy checking.
*
* {@inheritdoc}
*/
public static function loadCollection(xPDO & $xpdo, $className, $criteria= null, $cacheFlag= true) {
$objCollection= array ();
$fromCache = false;
if (!$className= $xpdo->loadClass($className)) return $objCollection;
$rows= false;
$fromCache= false;
$collectionCaching = (integer) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
if (!is_object($criteria)) {
$criteria= $xpdo->getCriteria($className, $criteria, $cacheFlag);
}
if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag) {
$rows= $xpdo->fromCache($criteria);
$fromCache = (is_array($rows) && !empty($rows));
}
if (!$fromCache && is_object($criteria)) {
$rows= xPDOObject :: _loadRows($xpdo, $className, $criteria);
}
if (is_array ($rows)) {
foreach ($rows as $row) {
modAccessibleObject :: _loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag);
}
} elseif (is_object($rows)) {
$cacheRows = array();
while ($row = $rows->fetch(PDO::FETCH_ASSOC)) {
modAccessibleObject :: _loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag);
if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag && !$fromCache) $cacheRows[] = $row;
}
if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag && !$fromCache) $rows =& $cacheRows;
}
if (!$fromCache && $xpdo->_cacheEnabled && $collectionCaching > 0 && $cacheFlag && !empty($rows)) {
$xpdo->toCache($criteria, $rows, $cacheFlag);
}
return $objCollection;
}
示例9: __getClassAbsoluteParent
public static function __getClassAbsoluteParent(xPDO &$xpdo, $className)
{
if (!$className) {
return false;
}
if (!class_exists($className) && !$xpdo->loadClass($className)) {
return false;
}
return self::_getClassAbsoluteParent($className);
}
示例10: __construct
public function __construct(&$xpdo)
{
parent::__construct($xpdo);
$this->xpdo->loadClass('transport.xPDOTransport', XPDO_CORE_PATH, true, true);
}