本文整理汇总了PHP中core_kernel_classes_Resource::getRepository方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Resource::getRepository方法的具体用法?PHP core_kernel_classes_Resource::getRepository怎么用?PHP core_kernel_classes_Resource::getRepository使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Resource
的用法示例。
在下文中一共展示了core_kernel_classes_Resource::getRepository方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exec
/**
* Short description of method exec
*
* @access public
* @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu>
* @param Resource resource
* @param string command
* @return string
*/
public static function exec(core_kernel_classes_Resource $resource, $command)
{
$returnValue = (string) '';
$username = "";
$password = "";
$repository = null;
try {
if (empty($command)) {
throw new Exception(__CLASS__ . ' -> ' . __FUNCTION__ . '() : $command_ must be specified');
}
//get context variables
if ($resource instanceof core_kernel_versioning_File) {
$repository = $resource->getRepository();
} else {
if ($resource instanceof core_kernel_versioning_Repository) {
$repository = $resource;
} else {
throw new Exception('The first parameter (resource) should be a File or a Repository');
}
}
if (is_null($repository)) {
throw new Exception('Unable to find the repository to work with for the reference resource (' . $resource->getUri() . ')');
}
$username = $repository->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_LOGIN));
$password = $repository->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_PASSWORD));
$returnValue = shell_exec('svn --username ' . $username . ' --password ' . $password . ' ' . $command);
// var_dump('svn --username ' . $username . ' --password ' . $password . ' ' . $command);
// var_dump($returnValue);
} catch (Exception $e) {
die('Error code `svn_error_command` in ' . $e->getMessage());
}
return (string) $returnValue;
}
示例2: getImplementationToDelegateTo
/**
* Short description of method getImplementationToDelegateTo
*
* @access public
* @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu>
* @param Resource resource
* @return core_kernel_versioning_FileInterface
*/
public function getImplementationToDelegateTo(core_kernel_classes_Resource $resource)
{
$returnValue = null;
$repository = $resource->getRepository();
if (!is_null($repository)) {
$VCStype = $repository->getVCSType();
$implClass = '';
// Function of the repository type, define the implementation to attack
switch ($VCStype->getUri()) {
case PROPERTY_GENERIS_VCS_TYPE_SUBVERSION:
$implClass = 'core_kernel_versioning_subversion_File';
break;
case PROPERTY_GENERIS_VCS_TYPE_SUBVERSION_WIN:
$implClass = 'core_kernel_versioning_subversionWindows_File';
break;
case INSTANCE_GENERIS_VCS_TYPE_LOCAL:
$implClass = 'core_kernel_versioning_local_File';
break;
default:
throw new common_exception_Error('unknown Version Control System ' . $VCStype->getLabel() . '(' . $VCStype . ')');
}
// If an implementation has been found
if (!empty($implClass)) {
$reflectionMethod = new ReflectionMethod($implClass, 'singleton');
$delegate = $reflectionMethod->invoke(null);
$returnValue = $delegate;
}
} else {
throw new core_kernel_versioning_exception_FileUnversionedException('no repository associated to the aledged versioned file');
}
return $returnValue;
}