本文整理汇总了PHP中core_kernel_classes_Class::createInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::createInstance方法的具体用法?PHP core_kernel_classes_Class::createInstance怎么用?PHP core_kernel_classes_Class::createInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Class
的用法示例。
在下文中一共展示了core_kernel_classes_Class::createInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* initialize a test method
*/
public function setUp()
{
TaoPhpUnitTestRunner::initTest();
$activityExecutionClass = new core_kernel_classes_Class(CLASS_ACTIVITY_EXECUTION);
$this->activityExecution = $activityExecutionClass->createInstance('test');
$this->service = wfEngine_models_classes_RecoveryService::singleton();
}
示例2: setUp
/**
* tests initialization
*/
public function setUp()
{
TaoTestRunner::initTest();
$resultsService = taoResults_models_classes_ResultsService::singleton();
$this->resultsService = $resultsService;
$this->statsService = taoResults_models_classes_StatisticsService::singleton();
$this->reportService = taoResults_models_classes_ReportService::singleton();
//create an activity execution
$activityExecutionClass = new core_kernel_classes_Class(CLASS_ACTIVITY_EXECUTION);
//create an activity definition
$activityDefinitionClass = new core_kernel_classes_Class(CLASS_ACTIVITIES);
$this->activityExecution = $activityExecutionClass->createInstance("MyActivityExecution");
//links the activity execution to the activity definition
$this->activityDefinition = $activityDefinitionClass->createInstance("MyActivityDefinition");
$this->activityExecution->setPropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITY_EXECUTION_ACTIVITY), $this->activityDefinition->getUri());
//links the call of service to the activity execution
$interactiveServiceClass = new core_kernel_classes_Class(CLASS_CALLOFSERVICES);
$this->interactiveService = $interactiveServiceClass->createInstance("MyInteractiveServiceCall");
$this->activityDefinition->setPropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_INTERACTIVESERVICES), $this->interactiveService->getUri());
$this->interactiveService->setPropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_SERVICEDEFINITION), "#interactiveServiceDefinition");
$deliveryResult = new core_kernel_classes_Resource("#MyDeliveryResult");
$variableIDentifier = "GRADE";
$value = 0.4;
//create a small delivery
$this->subClass = $this->resultsService->createSubClass(new core_kernel_classes_Class(TAO_DELIVERY_RESULT), "UnitTestingGenClass");
$this->delivery = $this->subClass->createInstance("UnitTestingGenDelivery");
$this->delivery->setPropertyValue(new core_kernel_classes_Property(PROPERTY_RESULT_OF_DELIVERY), "#unitTestResultOfDelivery");
$this->delivery->setPropertyValue(new core_kernel_classes_Property(PROPERTY_RESULT_OF_SUBJECT), "#unitTestResultOfSubject");
$this->delivery->setPropertyValue(new core_kernel_classes_Property(PROPERTY_RESULT_OF_PROCESS), "#unitTestResultOfProcess");
//stores a grade in this delivery
$this->grade = $this->resultsService->storeGrade($this->delivery, $this->activityExecution, $variableIDentifier, $value);
$this->response = $this->resultsService->storeResponse($this->delivery, $this->activityExecution, $variableIDentifier, $value);
}
示例3: addFormalParameter
/**
*
* @param array $formalParam
* @return boolean
*/
private function addFormalParameter($formalParam)
{
if (is_array($formalParam)) {
if ($formalParam['processVar']) {
$label = self::unCamelize(str_replace('^', '', $formalParam['processVar']));
} else {
$label = self::unCamelize($formalParam['name']);
}
$formalParamResource = $this->formalParamClass->createInstance($label);
if (!is_null($formalParamResource)) {
$formalParamResource->setPropertyValue($this->formalParamNameProp, $formalParam['name']);
if ($formalParam['processVar']) {
$processVar = $this->getProcessVar(str_replace('^', '', $formalParam['processVar']));
if (!is_null($processVar)) {
$formalParamResource->setPropertyValue($this->formalParamDefProcessVarProp, $processVar->getUri());
}
}
if ($formalParam['constant']) {
$formalParamResource->setPropertyValue($this->formalParamDefConstantProp, $formalParam['constant']);
}
return true;
}
}
return false;
}
示例4: initRoles
public function initRoles()
{
// Main parent role.
$roleClass = new core_kernel_classes_Class(CLASS_ROLE);
$isSystemProperty = new core_kernel_classes_Property(PROPERTY_ROLE_ISSYSTEM);
$includesRoleProperty = new core_kernel_classes_Property(PROPERTY_ROLE_INCLUDESROLE);
$trueInstance = new core_kernel_classes_Resource(GENERIS_TRUE);
$falseInstance = new core_kernel_classes_Resource(GENERIS_FALSE);
$prefix = LOCAL_NAMESPACE . '#';
// Do not forget that more you go deep in the Roles hierarchy, more rights you have.
$baseRole = $roleClass->createInstance('BASE Role', 'The base role of the hierarchy (minimal rights).', $prefix . 'baseRole');
$baseRole->setPropertyValue($isSystemProperty, $falseInstance);
$subRole1 = $roleClass->createInstance('SUB Role 1', 'Includes BASE role.', $prefix . 'subRole1');
$subRole1->setPropertyValue($includesRoleProperty, $baseRole);
$subRole1->setPropertyValue($isSystemProperty, $falseInstance);
$subRole2 = $roleClass->createInstance('SUB Role 2', 'Includes BASE role.', $prefix . 'subRole2');
$subRole2->setPropertyValue($includesRoleProperty, $baseRole);
$subRole2->setPropertyValue($isSystemProperty, $falseInstance);
$subRole3 = $roleClass->createInstance('SUB Role 3', 'Includes BASE role.', $prefix . 'subRole3');
$subRole3->setPropertyValue($includesRoleProperty, $baseRole);
$subRole3->setPropertyValue($isSystemProperty, $falseInstance);
$subRole11 = $roleClass->createInstance('SUB Role 11', 'Includes SUB Role 1.', $prefix . 'subRole11');
$subRole11->setPropertyValue($includesRoleProperty, $subRole1);
$subRole11->setPropertyValue($isSystemProperty, $falseInstance);
$subRole12 = $roleClass->createInstance('SUB Role 12', 'Includes SUB Role 1.', $prefix . 'subRole12');
$subRole12->setPropertyValue($includesRoleProperty, $subRole1);
$subRole12->setPropertyValue($isSystemProperty, $falseInstance);
$subRole13 = $roleClass->createInstance('SUB Role 13', 'Includes SUB Role 1, SUB Role 11, SUB Role 12.', $prefix . 'subRole13');
$subRole13->setPropertyValue($includesRoleProperty, $subRole1);
$subRole13->setPropertyValue($includesRoleProperty, $subRole11);
$subRole13->setPropertyValue($includesRoleProperty, $subRole12);
$subRole13->setPropertyValue($isSystemProperty, $falseInstance);
}
示例5: setUp
public function setUp()
{
GenerisPhpUnitTestRunner::initTest();
$class = new core_kernel_classes_Class(CLASS_GENERIS_RESOURCE);
$this->topClass = $class->createSubClass('test class 1');
$this->emptyClass = $class->createSubClass('test class 2');
$class1a = $this->topClass->createSubClass('test class 1a');
$class1b = $this->topClass->createSubClass('test class 1b');
$class1c = $this->topClass->createSubClass('test class 1c');
$class1c1 = $class1c->createSubClass('test class 1c1');
$instance1_1 = $this->topClass->createInstance('test instance 1.1');
$instance1_2 = $this->topClass->createInstance('test instance 1.2');
$instance1_3 = $this->topClass->createInstance('test instance 1.3');
$instance1b_1 = $class1b->createInstance('test instance 1b.1');
$instance1b_2 = $class1b->createInstance('test instance 1b.2');
$instance1c1_1 = $class1c1->createInstance('test instance 1c1.1');
$instance1c1_2 = $class1c1->createInstance('test instance 1c1.2');
}
示例6: setUp
/**
* tests initialization
*/
public function setUp()
{
TaoPhpUnitTestRunner::initTest();
$processDefinitionClass = new core_kernel_classes_Class(CLASS_PROCESS);
$processDefinition = $processDefinitionClass->createInstance('process of Checker UnitTest', 'created for the unit test of process cloner');
if ($processDefinition instanceof core_kernel_classes_Resource) {
$this->proc = $processDefinition;
}
$this->authoringService = wfAuthoring_models_classes_ProcessService::singleton();
}
示例7: testIsFile
public function testIsFile()
{
$clazz = new core_kernel_classes_Class(CLASS_GENERIS_FILE);
$instance = $clazz->createInstance('toto.txt', 'toto');
$fileNameProp = new core_kernel_classes_Property(PROPERTY_FILE_FILENAME);
$instance->setPropertyValue($fileNameProp, 'file://toto.txt');
$this->assertTrue(core_kernel_file_File::isFile($instance));
$this->assertFalse(core_kernel_file_File::isFile($clazz));
$instance->delete();
}
示例8: setUp
/**
* tests initialization
*/
public function setUp()
{
TaoPhpUnitTestRunner::initTest();
$this->clearPassword = $this->testUserData[PROPERTY_USER_PASSWORD];
$this->testUserData[PROPERTY_USER_PASSWORD] = core_kernel_users_Service::getPasswordHash()->encrypt($this->testUserData[PROPERTY_USER_PASSWORD]);
$this->userService = tao_models_classes_UserService::singleton();
$class = new core_kernel_classes_Class(CLASS_GENERIS_USER);
$this->testUser = $class->createInstance();
$this->assertNotNull($this->testUser);
$this->userService->bindProperties($this->testUser, $this->testUserData);
}
示例9: setUp
/**
* tests initialization
*/
public function setUp()
{
TaoPhpUnitTestRunner::initTest();
$processDefinitionClass = new core_kernel_classes_Class(CLASS_PROCESS);
$processDefinition = $processDefinitionClass->createInstance('processForUnitTest', 'created for the unit test of process definition service');
if ($processDefinition instanceof core_kernel_classes_Resource) {
$this->processDefinition = $processDefinition;
} else {
$this->fail('fail to create a process definition resource');
}
$this->authoringService = wfAuthoring_models_classes_ProcessService::singleton();
$this->service = wfEngine_models_classes_ProcessDefinitionService::singleton();
}
示例10: getResource
/**
* @return array
*/
protected function getResource($relPath)
{
$dir = $this->getTempDirectory();
$file = $dir->getFile($relPath);
$file->put(file_get_contents(__DIR__ . $relPath));
/** @var FileReferenceSerializer $serializer */
$serializer = ServiceManager::getServiceManager()->get(FileReferenceSerializer::SERVICE_ID);
$fileUri = $serializer->serialize($file);
$class = new \core_kernel_classes_Class('fakeClass');
$resource = $class->createInstance('fakeInstance');
$prop = new \core_kernel_classes_Property('fakeProp');
$prop->setRange(new \core_kernel_classes_Class(CLASS_GENERIS_FILE));
$resource->editPropertyValues($prop, new \core_kernel_classes_Resource($fileUri));
return array($file, $resource);
}
示例11: setUp
/**
* tests initialization
*/
public function setUp()
{
TaoPhpUnitTestRunner::initTest();
$this->authoringService = wfAuthoring_models_classes_ProcessService::singleton();
$this->variableService = wfEngine_models_classes_VariableService::singleton();
$processDefinitionClass = new core_kernel_classes_Class(CLASS_PROCESS);
$this->processDefinition = $processDefinitionClass->createInstance('ProcessForUnitTest', 'Unit test');
//define activities and connectors
$activity = $this->authoringService->createActivity($this->processDefinition, 'activity for interactive service unit test');
if ($activity instanceof core_kernel_classes_Resource) {
$this->activity = $activity;
} else {
$this->fail('fail to create a process definition resource');
}
$this->service = wfEngine_models_classes_ConnectorService::singleton();
}
示例12: testAdd
public function testAdd()
{
$rootClass = new \core_kernel_classes_Class($this->classUri);
$filePath = dirname(__DIR__) . '/sample/Italy.png';
$instance = $rootClass->createInstance();
$instance->setPropertyValue(new \core_kernel_classes_Property(MEDIA_LINK), 'myGreatLink');
$returnedLink = $instance->getUri();
$this->service->expects($this->once())->method('createMediaInstance')->with($filePath, $this->classUri, 'EN_en', 'Italy1.png')->willReturn($returnedLink);
//mock the fileInfo method
$fileInfo = array('name' => 'myName', 'mime' => 'mime/type', 'size' => 1024);
$this->mediaManagerManagement->expects($this->once())->method('getFileInfo')->with($returnedLink)->willReturn($fileInfo);
$success = $this->mediaManagerManagement->add($filePath, 'Italy1.png', $this->classUri);
// has no error
$this->assertInternalType('array', $success, 'Should be a file info array');
$this->assertArrayNotHasKey('error', $success, 'upload doesn\'t succeed');
$this->assertEquals($fileInfo, $success, 'Doesn\'t return the getFileInfo value');
return $returnedLink;
}
示例13: testSetPropertiesValues
public function testSetPropertiesValues()
{
$this->hardify();
$instance = $this->targetMovieClass->createInstance("Hard Sub Movie (Unit Test)");
$instance2 = $this->targetMovieClass->createInstance("Hard Sub Movie2 (Unit Test)");
$instance->setPropertiesValues(array($this->targetRelatedMoviesProperty->getUri() => $instance2, $this->targetActorsProperty->getUri() => array('I\'m special"! !', 'So special"! !'), RDFS_LABEL => 'I\'m special"! !'));
$actors = $instance->getPropertyValues($this->targetActorsProperty);
$this->assertEquals(2, count($actors));
$this->assertTrue(in_array('I\'m special"! !', $actors));
$this->assertTrue(in_array('So special"! !', $actors));
$relateds = $instance->getPropertyValues($this->targetRelatedMoviesProperty);
$this->assertEquals(1, count($relateds));
$related = current($relateds);
$this->assertEquals($instance2->getUri(), $related);
$labels = $instance->getPropertyValues(new core_kernel_classes_Property(RDFS_LABEL));
$this->assertEquals(2, count($labels));
$this->assertTrue(in_array('I\'m special"! !', $labels));
$this->assertTrue(in_array("Hard Sub Movie (Unit Test)", $labels));
$instance->delete();
$instance2->delete();
}
示例14: installManagementRole
/**
* Will make the Global Manager include the Management Role of the extension
* to install (if it exists).
*
* @access public
* @author Jerome Bogaerts <jerome@taotesting.com>
* @return void
* @since 2.4
*/
public function installManagementRole()
{
// Try to get a Management Role described by the extension itself.
// (this information comes actually from the Manifest of the extension)
$roleUri = $this->extension->getManifest()->getManagementRoleUri();
if (!empty($roleUri)) {
$role = new core_kernel_classes_Resource($roleUri);
$roleService = tao_models_classes_RoleService::singleton();
if (!$role->exists()) {
// Management role does not exist yet, so we create it
$roleClass = new core_kernel_classes_Class(CLASS_MANAGEMENTROLE);
$roleLabel = $this->extension->getId() . ' Manager';
$role = $roleClass->createInstance($roleLabel, $roleLabel . ' Role', $role->getUri());
$roleService->includeRole($role, new core_kernel_classes_Resource(INSTANCE_ROLE_BACKOFFICE));
}
// Take the Global Manager role and make it include
// the Management role of the currently installed extension.
if ($role->getUri() !== INSTANCE_ROLE_GLOBALMANAGER) {
$globalManagerRole = new core_kernel_classes_Resource(INSTANCE_ROLE_GLOBALMANAGER);
$roleService->includeRole($globalManagerRole, $role);
}
common_Logger::d("Management Role " . $role->getUri() . " created for extension '" . $this->extension->getId() . "'.");
} else {
// There is no Management role described by the Extension Manifest.
common_Logger::i("No management role for extension '" . $this->extension->getId() . "'.");
}
}
示例15: testVirtualParallelJoinProcess
/**
* Test the tokens into a parallel process
*/
public function testVirtualParallelJoinProcess()
{
error_reporting(E_ALL);
$t_start = microtime(true);
//init services
$activityService = wfEngine_models_classes_ActivityService::singleton();
$processVariableService = wfEngine_models_classes_VariableService::singleton();
$authoringService = wfAuthoring_models_classes_ProcessService::singleton();
$activityExecutionService = wfEngine_models_classes_ActivityExecutionService::singleton();
$activityExecutionService->cache = (bool) self::SERVICE_CACHE;
//process definition
$processDefinitionClass = new core_kernel_classes_Class(CLASS_PROCESS);
$processDefinition = $processDefinitionClass->createInstance('PJ processForUnitTest_' . date(DATE_ISO8601), 'created for the unit test of process execution');
$this->assertNotNull($processDefinition);
/*
+---------------+
| activity 0 |
+-------+-------+
|
+---v---+
| c 0 | split
+--+-+--+
| |
3 +---------+ +---------+ unit_var_12345678
| |
+-------v--------+ +-------v------+
| activity 1 | | activity 2 |
+-------+--------+ +--------+-----+
| |
+--------+ +--------+
+--v----v--+
| c 2 | join
+----+-----+
|
+-------v--------+
| activity 3 |
+----------------+
*/
//activities definitions
$activity0 = $authoringService->createActivity($processDefinition, 'activity0');
$this->assertNotNull($activity0);
$connector0 = null;
$authoringService->setFirstActivity($processDefinition, $activity0);
$connector0 = $authoringService->createConnector($activity0);
$connectorParallele = new core_kernel_classes_Resource(INSTANCE_TYPEOFCONNECTORS_PARALLEL);
$authoringService->setConnectorType($connector0, $connectorParallele);
$this->assertNotNull($connector0);
$parallelActivity1 = $authoringService->createActivity($processDefinition, 'activity1');
$this->assertNotNull($parallelActivity1);
$roleRestrictedUser = new core_kernel_classes_Resource(INSTANCE_ACL_ROLE_RESTRICTED_USER);
$activityService->setAcl($parallelActivity1, $roleRestrictedUser, $this->testUserRole);
//!!! it is mendatory to set the role restricted user ACL mode to make this parallel process test case work
$connector1 = null;
$connector1 = $authoringService->createConnector($parallelActivity1);
$this->assertNotNull($connector1);
$parallelActivity2 = $authoringService->createActivity($processDefinition, 'activity2');
$this->assertNotNull($parallelActivity2);
$activityService->setAcl($parallelActivity2, $roleRestrictedUser, $this->testUserRole);
//!!! it is mendatory to set the role restricted user ACL mode to make this parallel process test case work
$connector2 = null;
$connector2 = $authoringService->createConnector($parallelActivity2);
$this->assertNotNull($connector2);
//define parallel activities, first branch with constant cardinality value, while the second listens to a process variable:
$parallelCount1 = 3;
$parallelCount2 = 5;
$parallelCount2_processVar_key = 'unit_var_' . time();
$parallelCount2_processVar = $processVariableService->createProcessVariable('Var for unit test', $parallelCount2_processVar_key);
$prallelActivitiesArray = array($parallelActivity1->getUri() => $parallelCount1, $parallelActivity2->getUri() => $parallelCount2_processVar);
$result = $authoringService->setParallelActivities($connector0, $prallelActivitiesArray);
$this->assertTrue($result);
//set several split variables:
$splitVariable1_key = 'unit_split_var1_' . time();
$splitVariable1 = $processVariableService->createProcessVariable('Split Var1 for unit test', $splitVariable1_key);
$splitVariable2_key = 'unit_split_var2_' . time();
$splitVariable2 = $processVariableService->createProcessVariable('Split Var2 for unit test', $splitVariable2_key);
$splitVariablesArray = array($parallelActivity1->getUri() => array($splitVariable1), $parallelActivity2->getUri() => array($splitVariable1, $splitVariable2));
$connectorService = wfAuthoring_models_classes_ConnectorService::singleton();
$connectorService->setSplitVariables($connector0, $splitVariablesArray);
$prallelActivitiesArray[$parallelActivity2->getUri()] = $parallelCount2;
$joinActivity = $authoringService->createActivity($processDefinition, 'activity3');
//join parallel Activity 1 and 2 to "joinActivity"
$connector1 = wfAuthoring_models_classes_ConnectorService::singleton()->createJoin(array($parallelActivity1, $parallelActivity2), $joinActivity);
/*
$authoringService->createJoinActivity($connector1, $joinActivity, '', $parallelActivity1);
$authoringService->createJoinActivity($connector2, $joinActivity, '', $parallelActivity2);
*/
//run the process
$processExecName = 'Test Parallel Process Execution';
$processExecComment = 'created for processExecustionService test case by ' . __METHOD__;
$processInstance = $this->service->createProcessExecution($processDefinition, $processExecName, $processExecComment);
$this->assertTrue($this->service->checkStatus($processInstance, 'started'));
$this->out(__METHOD__, true);
$this->out("<strong>Forward transitions:</strong>", true);
$previousActivityExecution = null;
$numberActivities = 2 + $parallelCount1 + $parallelCount2;
$createdUsers = array();
$loginProperty = new core_kernel_classes_Property(PROPERTY_USER_LOGIN);
//.........这里部分代码省略.........