本文整理汇总了PHP中core_kernel_classes_Class::createProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::createProperty方法的具体用法?PHP core_kernel_classes_Class::createProperty怎么用?PHP core_kernel_classes_Class::createProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Class
的用法示例。
在下文中一共展示了core_kernel_classes_Class::createProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addClassProperty
/**
* Render the add property sub form.
* @throws Exception
* @return void
* @requiresRight id WRITE
*/
public function addClassProperty()
{
if (!tao_helpers_Request::isAjax()) {
throw new Exception("wrong request mode");
}
$clazz = new core_kernel_classes_Class($this->getRequestParameter('id'));
if ($this->hasRequestParameter('index')) {
$index = $this->getRequestParameter('index');
} else {
$index = count($clazz->getProperties(false)) + 1;
}
$propMode = 'simple';
if ($this->hasSessionAttribute('property_mode')) {
$propMode = $this->getSessionAttribute('property_mode');
}
//instanciate a property form
$propFormClass = 'tao_actions_form_' . ucfirst(strtolower($propMode)) . 'Property';
if (!class_exists($propFormClass)) {
$propFormClass = 'tao_actions_form_SimpleProperty';
}
$propFormContainer = new $propFormClass($clazz, $clazz->createProperty('Property_' . $index), array('index' => $index));
$myForm = $propFormContainer->getForm();
$this->setData('data', $myForm->renderElements());
$this->setView('blank.tpl', 'tao');
}
示例2: createContextOfThetest
public function createContextOfThetest()
{
// ----- Top Class : TaoSubject
$subjectClass = new core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAOSubject.rdf#Subject');
// Create a new subject class for the unit test
$this->targetSubjectClass = $subjectClass->createSubClass("Sub Subject Class (Unit Test)");
// Add a custom property to the newly created class
// Add an instance to this subject class
$this->subject1 = $this->targetSubjectClass->createInstance("Sub Subject (Unit Test)");
// Create a new subject sub class to the previous sub class
$this->targetSubjectSubClass = $this->targetSubjectClass->createSubClass("Sub Sub Subject Class (Unit Test)");
// Add an instance to this sub subject class
$this->subject2 = $this->targetSubjectSubClass->createInstance("Sub Sub Subject (Unit Test)");
// ----- Top Class : Work
// Create a class and test its instances & properties.
$this->taoClass = new core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAO.rdf#TAOObject');
$this->targetWorkClass = $this->taoClass->createSubClass('Work', 'The Work class');
// Add properties to the Work class.
$this->targetAuthorProperty = $this->targetWorkClass->createProperty('Author', 'The author of the work.');
$literalClass = new core_kernel_classes_Class(RDFS_LITERAL);
$this->targetAuthorProperty->setRange($literalClass);
// Create the Movie class that extends the Work class.
$this->targetMovieClass = $this->targetWorkClass->createSubClass('Movie', 'The Movie class');
$this->targetMovieClass = new core_kernel_classes_Class($this->targetMovieClass->getUri());
// Add properties to the Movie class.
$this->targetProducerProperty = $this->targetMovieClass->createProperty('Producer', 'The producer of the movie.');
$this->targetProducerProperty->setRange($literalClass);
$this->targetProducerProperty->setMultiple(true);
$this->targetActorsProperty = $this->targetMovieClass->createProperty('Actors', 'The actors playing in the movie.');
$this->targetActorsProperty->setRange($literalClass);
$this->targetActorsProperty->setMultiple(true);
$this->targetRelatedMoviesProperty = $this->targetMovieClass->createProperty('Related Movies', 'Movies related to the movie.');
$this->targetRelatedMoviesProperty->setRange($this->targetMovieClass);
$this->targetRelatedMoviesProperty->setMultiple(true);
//$this->generisUser = core_kernel_users_Service::singleton()->addUser('testCaseUser','testCasepass');
}
示例3: testDeleteInstances
public function testDeleteInstances()
{
$taoClass = new core_kernel_classes_Class(CLASS_GENERIS_RESOURCE);
$creativeWorkClass = $taoClass->createSubClass('Creative Work');
$authorProperty = $taoClass->createProperty('Author');
$relatedWorksProperty = $creativeWorkClass->createProperty('Related Works');
$bookLotr = $creativeWorkClass->createInstance('The Lord of The Rings (book)');
$bookLotr->setPropertyValue($authorProperty, 'J.R.R. Tolkien');
$movieLotr = $creativeWorkClass->createInstance('The Lord of The Rings (movie)');
$movieLotr->setPropertyValue($authorProperty, 'Peter Jackson');
$movieLotr->setPropertyValue($relatedWorksProperty, $bookLotr);
$bookLotr->setPropertyValue($relatedWorksProperty, $movieLotr);
$movieMinorityReport = $creativeWorkClass->createInstance('Minority Report');
$movieMinorityReport->setPropertyValue($authorProperty, 'Steven Spielberg');
$this->assertEquals(count($creativeWorkClass->getInstances()), 3);
// delete the LOTR movie with its references.
$relatedWorks = $bookLotr->getPropertyValuesCollection($relatedWorksProperty);
$this->assertEquals($relatedWorks->sequence[0]->getLabel(), 'The Lord of The Rings (movie)');
$creativeWorkClass->deleteInstances(array($movieLotr), true);
$relatedWorks = $bookLotr->getPropertyValues($relatedWorksProperty);
$this->assertEquals(count($relatedWorks), 0);
// Only 1 resource deleted ?
$this->assertFalse($movieLotr->exists());
$this->assertTrue($bookLotr->exists());
$this->assertTrue($movieMinorityReport->exists());
// Remove the rest.
$creativeWorkClass->deleteInstances(array($bookLotr, $movieMinorityReport));
$this->assertEquals(count($creativeWorkClass->getInstances()), 0);
$this->assertFalse($bookLotr->exists());
$this->assertFalse($movieMinorityReport->exists());
$this->assertTrue($authorProperty->delete());
$this->assertTrue($relatedWorksProperty->delete());
$creativeWorkClass->delete(true);
}