本文整理汇总了PHP中core_kernel_classes_Class::getParentClasses方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::getParentClasses方法的具体用法?PHP core_kernel_classes_Class::getParentClasses怎么用?PHP core_kernel_classes_Class::getParentClasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Class
的用法示例。
在下文中一共展示了core_kernel_classes_Class::getParentClasses方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHardModel
public function testHardModel()
{
$this->hardify();
$referencer = ResourceReferencer::singleton();
$propertyProxy = PropertyProxy::singleton();
$proxy = ResourceProxy::singleton();
$domainProperty = new core_kernel_classes_Property(RDFS_DOMAIN);
$rangeProperty = new core_kernel_classes_Property(RDFS_RANGE);
$literalClass = new core_kernel_classes_Class(RDFS_LITERAL);
$subClassOfProperty = new core_kernel_classes_Property(RDFS_SUBCLASSOF);
$this->assertTrue($this->targetActorsProperty->exists());
$this->assertTrue($this->targetMovieClass->exists());
$this->assertTrue($this->targetWorkClass->isSubclassOf($this->taoClass));
$this->assertTrue($this->targetWorkClass->getOnePropertyValue($subClassOfProperty)->getUri() == $this->taoClass->getUri());
$this->assertTrue($referencer->isClassReferenced($this->targetWorkClass));
$this->assertFalse(is_a($proxy->getImpToDelegateTo($this->targetWorkClass), 'core_kernel_persistence_smoothsql_Class'));
$this->assertFalse(is_a($proxy->getImpToDelegateTo($this->targetMovieClass), 'core_kernel_persistence_smoothsql_Class'));
$this->assertTrue($this->targetAuthorProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetWorkClass->getUri());
$this->assertTrue($this->targetAuthorProperty->getOnePropertyValue($rangeProperty)->getUri() == RDFS_LITERAL);
$this->assertTrue($this->targetMovieClass->isSubclassOf($this->targetWorkClass));
$this->assertTrue($this->targetMovieClass->getOnePropertyValue($subClassOfProperty)->getUri() == $this->targetWorkClass->getUri());
$this->assertTrue($referencer->isClassReferenced($this->targetMovieClass));
$this->assertTrue($this->targetProducerProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetMovieClass->getUri());
$this->assertTrue($this->targetProducerProperty->getOnePropertyValue($rangeProperty)->getUri() == RDFS_LITERAL);
$this->assertTrue($this->targetActorsProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetMovieClass->getUri());
$this->assertTrue($this->targetActorsProperty->getOnePropertyValue($rangeProperty)->getUri() == RDFS_LITERAL);
$this->assertTrue($this->targetRelatedMoviesProperty->getOnePropertyValue($domainProperty)->getUri() == $this->targetMovieClass->getUri());
$this->assertTrue($this->targetRelatedMoviesProperty->getOnePropertyValue($rangeProperty)->getUri() == $this->targetMovieClass->getUri());
$parentClasses = $this->targetMovieClass->getParentClasses();
$this->assertEquals(1, count($parentClasses));
$this->assertTrue(array_key_exists($this->targetWorkClass->getUri(), $parentClasses));
$prop = new core_kernel_classes_Property($this->targetRelatedMoviesProperty);
$this->assertTrue($prop->isMultiple());
}
示例2: testGetParentClasses
public function testGetParentClasses()
{
$class = new core_kernel_classes_Class(GENERIS_BOOLEAN);
$indirectParentClasses = $class->getParentClasses(true);
$this->assertEquals(2, count($indirectParentClasses));
$expectedResult = array(CLASS_GENERIS_RESOURCE, RDFS_RESOURCE);
foreach ($indirectParentClasses as $parentClass) {
$this->assertInstanceOf('core_kernel_classes_Class', $parentClass);
$this->assertTrue(in_array($parentClass->getUri(), $expectedResult));
}
$directParentClass = $class->getParentClasses();
$this->assertEquals(1, count($directParentClass));
foreach ($directParentClass as $parentClass) {
$this->assertInstanceOf('core_kernel_classes_Class', $parentClass);
$this->assertEquals(CLASS_GENERIS_RESOURCE, $parentClass->getUri());
}
}
示例3: index
public function index()
{
// load all extensions
\common_ext_ExtensionsManager::singleton()->getInstalledExtensions();
$res = $this->getCurrentResource();
$this->setData('res', $res);
$this->setData('types', $res->getTypes());
//restricted on the currently selected language
//$this->setData('triples', $res->getRdfTriples()->getIterator());
$this->setData('triples', $this->getRdfTriples($res, 'subject')->getIterator());
$this->setData('otriples', $this->getRdfTriples($res, 'object')->getIterator());
$this->setData('ptriples', $this->getRdfTriples($res, 'predicate')->getIterator());
if ($res->isClass()) {
$class = new \core_kernel_classes_Class($res->getUri());
$this->setData('subclassOf', $class->getParentClasses(false));
$this->setData('subclasses', $class->getSubClasses());
$this->setData('instances', $class->getInstances());
}
$this->setData('userLg', $dataLang = \common_session_SessionManager::getSession()->getDataLanguage());
$this->setView('browse.tpl');
}
示例4: indexTypes
public function indexTypes()
{
$toDo = array();
foreach ($this->resource->getTypes() as $class) {
$toDo[] = $class->getUri();
// $document->addField(Document\Field::Text('class', $class->getLabel()));
}
$done = array(RDFS_RESOURCE, TAO_OBJECT_CLASS);
$toDo = array_diff($toDo, $done);
$classes = array();
while (!empty($toDo)) {
$class = new \core_kernel_classes_Class(array_pop($toDo));
$classes[] = $class->getUri();
foreach ($class->getParentClasses() as $parent) {
if (!in_array($parent->getUri(), $done)) {
$toDo[] = $parent->getUri();
}
}
$done[] = $class->getUri();
}
$this->document->type_r = $classes;
}
示例5: indexTypes
/**
* @param Document $document
*/
protected function indexTypes(Document $document)
{
$toDo = array();
foreach ($this->resource->getTypes() as $class) {
$toDo[] = $class->getUri();
$document->addField(Document\Field::Text('class', $class->getLabel()));
}
$done = array(RDFS_CLASS, TAO_OBJECT_CLASS);
$toDo = array_diff($toDo, $done);
$classLabels = array();
while (!empty($toDo)) {
$class = new \core_kernel_classes_Class(array_pop($toDo));
$classLabels[] = $class->getLabel();
foreach ($class->getParentClasses() as $parent) {
if (!in_array($parent->getUri(), $done)) {
$toDo[] = $parent->getUri();
}
}
$done[] = $class->getUri();
}
$field = Document\Field::Keyword('class_r', $classLabels);
$field->isStored = false;
$document->addField($field);
}
示例6: getNodesToOpen
/**
* returns the nodes to open in order to display
* all the listed resources to be visible
*
* @param array $resources list of resources to show
* @param core_kernel_classes_Class $rootNode root node of the tree
* @return array array of the uris of the nodes to open
*/
public static function getNodesToOpen($uris, core_kernel_classes_Class $rootNode)
{
// this array is in the form of
// URI to test => array of uris that depend on the URI
$toTest = array();
foreach ($uris as $uri) {
$resource = new core_kernel_classes_Resource($uri);
foreach ($resource->getTypes() as $type) {
$toTest[$type->getUri()] = array();
}
}
$toOpen = array($rootNode->getUri());
while (!empty($toTest)) {
reset($toTest);
list($classUri, $depends) = each($toTest);
unset($toTest[$classUri]);
if (in_array($classUri, $toOpen)) {
$toOpen = array_merge($toOpen, $depends);
} else {
$class = new core_kernel_classes_Class($classUri);
foreach ($class->getParentClasses(false) as $parent) {
if ($parent->getUri() == RDFS_CLASS) {
continue;
}
if (!isset($toTest[$parent->getUri()])) {
$toTest[$parent->getUri()] = array();
}
$toTest[$parent->getUri()] = array_merge($toTest[$parent->getUri()], array($classUri), $depends);
}
}
}
return $toOpen;
}
示例7: getClassProperties
/**
* Enable you to get the properties of a class.
* The advantage of this method is to limit the level of recusrivity in the
* It get the properties up to the defined top class
*
* @access public
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
* @param core_kernel_classes_Class $clazz
* @param core_kernel_classes_Class $topLevelClazz
* @return array
*/
public static function getClassProperties(core_kernel_classes_Class $clazz, core_kernel_classes_Class $topLevelClazz = null)
{
$returnValue = array();
if (is_null($topLevelClazz)) {
$topLevelClazz = new core_kernel_classes_Class(TAO_OBJECT_CLASS);
}
if ($clazz->getUri() == $topLevelClazz->getUri()) {
$returnValue = $clazz->getProperties(false);
return (array) $returnValue;
}
//determine the parent path
$parents = array();
$top = false;
do {
if (!isset($lastLevelParents)) {
$parentClasses = $clazz->getParentClasses(false);
} else {
$parentClasses = array();
foreach ($lastLevelParents as $parent) {
$parentClasses = array_merge($parentClasses, $parent->getParentClasses(false));
}
}
if (count($parentClasses) == 0) {
break;
}
$lastLevelParents = array();
foreach ($parentClasses as $parentClass) {
if ($parentClass->getUri() == RDFS_CLASS) {
continue;
}
if ($parentClass->getUri() == $topLevelClazz->getUri()) {
$parents[$parentClass->getUri()] = $parentClass;
$top = true;
break;
}
$allParentClasses = $parentClass->getParentClasses(true);
if (array_key_exists($topLevelClazz->getUri(), $allParentClasses)) {
$parents[$parentClass->getUri()] = $parentClass;
}
$lastLevelParents[$parentClass->getUri()] = $parentClass;
}
} while (!$top);
foreach ($parents as $parent) {
$returnValue = array_merge($returnValue, $parent->getProperties(false));
}
$returnValue = array_merge($returnValue, $clazz->getProperties(false));
return (array) $returnValue;
}
示例8: isItemClass
/**
* check if the class is a or a subclass of an Item
*
* @access public
* @author Joel Bout, <joel@taotesting.com>
* @param core_kernel_classes_Class clazz
* @return boolean
*/
public function isItemClass(core_kernel_classes_Class $clazz)
{
$returnValue = (bool) false;
if ($this->itemClass->getUri() == $clazz->getUri()) {
return true;
}
foreach ($clazz->getParentClasses(true) as $parent) {
if ($parent->getUri() == $this->itemClass->getUri()) {
$returnValue = true;
break;
}
}
return (bool) $returnValue;
}
示例9: getParentClasses
/**
* (non-PHPdoc)
* @see core_kernel_persistence_ClassInterface::getParentClasses()
*/
public function getParentClasses(core_kernel_classes_Class $resource, $recursive = false)
{
$returnValue = array();
$sqlQuery = 'SELECT object FROM statements WHERE subject = ? AND predicate = ?';
$sqlResult = $this->getPersistence()->query($sqlQuery, array($resource->getUri(), RDFS_SUBCLASSOF));
while ($row = $sqlResult->fetch()) {
$parentClass = new core_kernel_classes_Class($row['object']);
$returnValue[$parentClass->getUri()] = $parentClass;
if ($recursive == true && $parentClass->getUri() != RDFS_CLASS && $parentClass->getUri() != RDFS_RESOURCE) {
if ($parentClass->getUri() == CLASS_GENERIS_RESOURCE) {
$returnValue[RDFS_RESOURCE] = new core_kernel_classes_Class(RDFS_RESOURCE);
} else {
$plop = $parentClass->getParentClasses(true);
$returnValue = array_merge($returnValue, $plop);
}
}
}
return $returnValue;
}