本文整理汇总了PHP中core_kernel_classes_Class::getProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::getProperties方法的具体用法?PHP core_kernel_classes_Class::getProperties怎么用?PHP core_kernel_classes_Class::getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Class
的用法示例。
在下文中一共展示了core_kernel_classes_Class::getProperties方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPropertiesByClass
protected function getPropertiesByClass(\core_kernel_classes_Class $type)
{
if (!isset($this->propertyCache[$type->getUri()])) {
$this->propertyCache[$type->getUri()] = $type->getProperties(true);
// alternativly use non recursiv and union with getPropertiesByClass of parentclasses
}
return $this->propertyCache[$type->getUri()];
}
示例2: deleteClass
/**
* Delete a subclass
*
* @access public
* @author Joel Bout, <joel@taotesting.com>
* @param core_kernel_classes_Class $clazz
* @return boolean
*/
public function deleteClass(core_kernel_classes_Class $clazz)
{
$returnValue = (bool) false;
if ($clazz->isSubClassOf($this->getRootClass()) && !$clazz->equals($this->getRootClass())) {
$returnValue = true;
$subclasses = $clazz->getSubClasses(false);
foreach ($subclasses as $subclass) {
$returnValue = $returnValue && $this->deleteClass($subclass);
}
foreach ($clazz->getProperties() as $classProperty) {
$returnValue = $returnValue && $this->deleteClassProperty($classProperty);
}
$returnValue = $returnValue && $clazz->delete();
} else {
common_Logger::w('Tried to delete class ' . $clazz->getUri() . ' as if it were a subclass of ' . $this->getRootClass()->getUri());
}
return (bool) $returnValue;
}
示例3: testModel
public function testModel()
{
// We must have a property dedicated to Roles in the Generis User class.
$userClass = new core_kernel_classes_Class(CLASS_GENERIS_USER);
$this->assertTrue($userClass->exists());
// The userClass must have a dedicated userRoles property.
$this->assertTrue(array_key_exists(PROPERTY_USER_ROLES, $userClass->getProperties()));
// The class that gather all Roles instances together must exist.
$roleClass = new core_kernel_classes_Class(CLASS_ROLE);
$this->assertTrue($roleClass->exists());
// The Role class must have the right properties (isSystem and includesRole)
$roleClassProperties = $roleClass->getProperties();
$this->assertTrue(array_key_exists(PROPERTY_ROLE_ISSYSTEM, $roleClassProperties));
$this->assertTrue(array_key_exists(PROPERTY_ROLE_INCLUDESROLE, $roleClassProperties));
// The Generis Role must exist after installation.
$generisRole = new core_kernel_classes_Resource(INSTANCE_ROLE_GENERIS);
$this->assertTrue($generisRole->exists());
}
示例4: getPropertyProperties
/**
* Get the properties of the rdfs Property class
*
* @access public
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
* @param string mode
* @return array
*/
public static function getPropertyProperties($mode = 'simple')
{
$returnValue = array();
switch ($mode) {
case 'simple':
$defaultUris = array(PROPERTY_IS_LG_DEPENDENT);
break;
case 'advanced':
default:
$defaultUris = array(RDFS_LABEL, PROPERTY_WIDGET, RDFS_RANGE, PROPERTY_IS_LG_DEPENDENT);
break;
}
$resourceClass = new core_kernel_classes_Class(RDF_PROPERTY);
foreach ($resourceClass->getProperties() as $property) {
if (in_array($property->getUri(), $defaultUris)) {
array_push($returnValue, $property);
}
}
return (array) $returnValue;
}
示例5: removeClassProperty
/**
* Render the add property sub form.
* @throws Exception
* @return void
* @requiresRight classUri WRITE
*/
public function removeClassProperty()
{
$success = false;
if (!tao_helpers_Request::isAjax()) {
throw new Exception("wrong request mode");
}
$class = new core_kernel_classes_Class($this->getRequestParameter('classUri'));
$property = new core_kernel_classes_Property($this->getRequestParameter('uri'));
//delete property mode
foreach ($class->getProperties() as $classProperty) {
if ($classProperty->equals($property)) {
$indexes = $property->getPropertyValues(new core_kernel_classes_Property(INDEX_PROPERTY));
//delete property and the existing values of this property
if ($property->delete(true)) {
//delete index linked to the property
foreach ($indexes as $indexUri) {
$index = new core_kernel_classes_Resource($indexUri);
$index->delete(true);
}
$success = true;
break;
}
}
}
if ($success) {
return $this->returnJson(array('success' => true));
} else {
$this->returnError(__('Unable to remove the property.'));
}
}
示例6: getIndexesByClass
/**
* Get the Search Indexes of a given $class.
*
* The returned array is an associative array where keys are the Property URI
* the Search Index belongs to, and the values are core_kernel_classes_Resource objects
* corresponding to Search Index definitions.
*
* @param \core_kernel_classes_Class $class
* @param boolean $recursive Whether or not to look for Search Indexes that belong to sub-classes of $class. Default is true.
* @return Index[] An array of Search Index to $class.
*/
public static function getIndexesByClass(\core_kernel_classes_Class $class, $recursive = true)
{
$returnedIndexes = array();
// Get properties to the root class hierarchy.
$properties = $class->getProperties(true);
foreach ($properties as $prop) {
$propUri = $prop->getUri();
$indexes = self::getIndexes($prop);
if (count($indexes) > 0) {
if (isset($returnedIndexes[$propUri]) === false) {
$returnedIndexes[$propUri] = array();
}
foreach ($indexes as $index) {
$returnedIndexes[$propUri][] = new Index($index->getUri());
}
}
}
return $returnedIndexes;
}
示例7: toArray
/**
* Format an RDFS Class to an array
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @param Class clazz
* @return array
*/
public function toArray(core_kernel_classes_Class $clazz)
{
$returnValue = array();
$properties = $clazz->getProperties(false);
foreach ($clazz->getInstances(false) as $instance) {
$data = array();
foreach ($properties as $property) {
$data[$property->getLabel()] = null;
$values = $instance->getPropertyValues($property);
if (count($values) > 1) {
$data[$property->getLabel()] = $values;
} elseif (count($values) == 1) {
$data[$property->getLabel()] = $values[0];
}
}
array_push($returnValue, $data);
}
return (array) $returnValue;
}
示例8: testGetProperties
public function testGetProperties()
{
$list = new core_kernel_classes_Class(RDF_LIST);
$properties = $list->getProperties();
$this->assertTrue(count($properties) == 2);
$expectedResult = array(RDF_FIRST, RDF_REST);
foreach ($properties as $property) {
$this->assertTrue($property instanceof core_kernel_classes_Property);
$this->assertTrue(in_array($property->getUri(), $expectedResult));
if ($property->getUri() === RDF_FIRST) {
$this->assertEquals($property->getRange()->getUri(), RDFS_RESOURCE);
$this->assertEquals($property->getLabel(), 'first');
$this->assertEquals($property->getComment(), 'The first item in the subject RDF list.');
}
if ($property->getUri() === RDF_REST) {
$this->assertEquals($property->getRange()->getUri(), RDF_LIST);
$this->assertEquals($property->getLabel(), 'rest');
$this->assertEquals($property->getComment(), 'The rest of the subject RDF list after the first item.');
}
}
$class = $list->createSubClass('toto', 'toto');
$properties2 = $class->getProperties(true);
$this->assertFalse(empty($properties2));
$class->delete();
}