本文整理汇总了PHP中core_kernel_classes_Class::createInstanceWithProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::createInstanceWithProperties方法的具体用法?PHP core_kernel_classes_Class::createInstanceWithProperties怎么用?PHP core_kernel_classes_Class::createInstanceWithProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Class
的用法示例。
在下文中一共展示了core_kernel_classes_Class::createInstanceWithProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
TaoPhpUnitTestRunner::initTest();
$this->disableCache();
// creates a user using remote script from joel
$testUserData = array(PROPERTY_USER_LOGIN => 'tjdoe', PROPERTY_USER_PASSWORD => 'test123', PROPERTY_USER_LASTNAME => 'Doe', PROPERTY_USER_FIRSTNAME => 'John', PROPERTY_USER_MAIL => 'jdoe@tao.lu', PROPERTY_USER_DEFLG => \tao_models_classes_LanguageService::singleton()->getLanguageByCode(DEFAULT_LANG)->getUri(), PROPERTY_USER_UILG => \tao_models_classes_LanguageService::singleton()->getLanguageByCode(DEFAULT_LANG)->getUri(), PROPERTY_USER_ROLES => array(INSTANCE_ROLE_GLOBALMANAGER));
$testUserData[PROPERTY_USER_PASSWORD] = 'test' . rand();
$data = $testUserData;
$data[PROPERTY_USER_PASSWORD] = \core_kernel_users_Service::getPasswordHash()->encrypt($data[PROPERTY_USER_PASSWORD]);
$tmclass = new \core_kernel_classes_Class(CLASS_TAO_USER);
$user = $tmclass->createInstanceWithProperties($data);
\common_Logger::i('Created user ' . $user->getUri());
// prepare a lookup table of languages and values
$usage = new \core_kernel_classes_Resource(INSTANCE_LANGUAGE_USAGE_GUI);
$propValue = new \core_kernel_classes_Property(RDF_VALUE);
$langService = \tao_models_classes_LanguageService::singleton();
$lookup = array();
foreach ($langService->getAvailableLanguagesByUsage($usage) as $lang) {
$lookup[$lang->getUri()] = (string) $lang->getUniquePropertyValue($propValue);
}
$data = array('rootUrl' => ROOT_URL, 'userUri' => $user->getUri(), 'userData' => $testUserData, 'lang' => $lookup);
$this->login = $data['userData'][PROPERTY_USER_LOGIN];
$this->password = $data['userData'][PROPERTY_USER_PASSWORD];
$this->userUri = $data['userUri'];
}
示例2: setUp
/**
* tests initialization
*/
public function setUp()
{
TaoPhpUnitTestRunner::initTest();
$oauthClass = new core_kernel_classes_Class(CLASS_OAUTH_CONSUMER);
$resource = $oauthClass->createInstanceWithProperties(array(PROPERTY_OAUTH_KEY => 'test_key', PROPERTY_OAUTH_SECRET => md5(rand())));
$this->oauthCustomer = new tao_models_classes_oauth_Credentials($resource);
}
示例3: getDelivery
/**
* Get repeated delivery by parent delivery instance and number of repetition.
* @param \core_kernel_classes_Resource $delivery
* @param integer $numberOfRepetition
* @param boolean $createNew If repeated delivery is not exists then new instance will be created.
* @return \core_kernel_classes_Resource|false
*/
public function getDelivery(\core_kernel_classes_Resource $delivery, $numberOfRepetition, $createNew = false)
{
$rrule = $delivery->getOnePropertyValue(new \core_kernel_classes_Property(DeliveryScheduleService::TAO_DELIVERY_RRULE_PROP));
if ($rrule === null) {
throw new \InvalidArgumentException('Delivery has no recurrence rule');
} else {
$rrule = (string) $rrule;
}
$rule = new \Recurr\Rule($rrule);
$transformer = new \Recurr\Transformer\ArrayTransformer();
$rEvents = $transformer->transform($rule);
if (!isset($rEvents[$numberOfRepetition])) {
throw new \InvalidArgumentException('Delivery has no recurrence number ' . $numberOfRepetition);
}
$repeatedDeliveryClass = new \core_kernel_classes_Class(self::CLASS_URI);
$resources = $repeatedDeliveryClass->searchInstances(array(self::PROPERTY_REPETITION_OF => $delivery->getUri(), self::PROPERTY_NUMBER_OF_REPETITION => $numberOfRepetition), array('like' => false));
if (empty($resources) && $createNew) {
$repeatedDeliveryClass = new \core_kernel_classes_Class(self::CLASS_URI);
$repeatedDeliveryProperties = array(self::PROPERTY_REPETITION_OF => $delivery->getUri(), self::PROPERTY_NUMBER_OF_REPETITION => $numberOfRepetition);
$repeatedDelivery = $repeatedDeliveryClass->createInstanceWithProperties($repeatedDeliveryProperties);
} else {
$repeatedDelivery = current($resources);
}
return $repeatedDelivery;
}
示例4: importDelivery
public static function importDelivery(core_kernel_classes_Class $deliveryClass, $archiveFile)
{
$folder = tao_helpers_File::createTempDir();
$zip = new ZipArchive();
if ($zip->open($archiveFile) === true) {
if ($zip->extractTo($folder)) {
$returnValue = $folder;
}
$zip->close();
}
$manifestPath = $folder . self::MANIFEST_FILE;
if (!file_exists($manifestPath)) {
return common_report_Report::createFailure(__('Manifest not found in assembly'));
}
$manifest = json_decode(file_get_contents($manifestPath), true);
$label = $manifest['label'];
$serviceCall = tao_models_classes_service_ServiceCall::fromString(base64_decode($manifest['runtime']));
$dirs = $manifest['dir'];
$resultServer = taoResultServer_models_classes_ResultServerAuthoringService::singleton()->getDefaultResultServer();
try {
foreach ($dirs as $id => $relPath) {
tao_models_classes_service_FileStorage::singleton()->import($id, $folder . $relPath);
}
$delivery = $deliveryClass->createInstanceWithProperties(array(RDFS_LABEL => $label, PROPERTY_COMPILEDDELIVERY_DIRECTORY => array_keys($dirs), PROPERTY_COMPILEDDELIVERY_TIME => time(), PROPERTY_COMPILEDDELIVERY_RUNTIME => $serviceCall->toOntology(), TAO_DELIVERY_RESULTSERVER_PROP => $resultServer));
$report = common_report_Report::createSuccess(__('Delivery "%s" successfully imported', $label), $delivery);
} catch (Exception $e) {
if (isset($delivery) && $delivery instanceof core_kernel_classes_Resource) {
$delivery->delete();
}
$report = common_report_Report::createFailure(__('Unkown error during impoort'));
}
return $report;
}
示例5: setUp
public function setUp()
{
parent::setUp();
TaoPhpUnitTestRunner::initTest();
$class = new core_kernel_classes_Class(CLASS_OAUTH_CONSUMER);
$this->credentials = $class->createInstanceWithProperties(array(RDFS_LABEL => 'test_credentials', PROPERTY_OAUTH_KEY => 'testcase_12345', PROPERTY_OAUTH_SECRET => 'secret_12345'));
}
示例6: importDeliveryResource
protected function importDeliveryResource(core_kernel_classes_Class $deliveryClass, $manifest)
{
$label = $manifest['label'];
$dirs = $manifest['dir'];
$serviceCall = tao_models_classes_service_ServiceCall::fromString(base64_decode($manifest['runtime']));
$resultServer = taoResultServer_models_classes_ResultServerAuthoringService::singleton()->getDefaultResultServer();
$delivery = $deliveryClass->createInstanceWithProperties(array(RDFS_LABEL => $label, PROPERTY_COMPILEDDELIVERY_DIRECTORY => array_keys($dirs), PROPERTY_COMPILEDDELIVERY_TIME => time(), PROPERTY_COMPILEDDELIVERY_RUNTIME => $serviceCall->toOntology(), TAO_DELIVERY_RESULTSERVER_PROP => $resultServer));
return $delivery;
}
示例7: create
/**
* Creates a new simple delivery
*
* @param core_kernel_classes_Class $deliveryClass
* @param core_kernel_classes_Resource $test
* @param string $label
* @return common_report_Report
*/
public function create(core_kernel_classes_Class $deliveryClass, core_kernel_classes_Resource $test, $label)
{
common_Logger::i('Creating ' . $label . ' with ' . $test->getLabel() . ' under ' . $deliveryClass->getLabel());
$contentClass = new core_kernel_classes_Class(CLASS_SIMPLE_DELIVERYCONTENT);
$content = $contentClass->createInstanceWithProperties(array(PROPERTY_DELIVERYCONTENT_TEST => $test->getUri()));
$report = TemplateAssemblyService::singleton()->createAssemblyByContent($deliveryClass, $content, array(RDFS_LABEL => $label));
$content->delete();
return $report;
}
示例8: generateTesttakers
public static function generateTesttakers($count = 1000)
{
$ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoGroups');
$topClass = new \core_kernel_classes_Class(TAO_SUBJECT_CLASS);
$role = new \core_kernel_classes_Resource(INSTANCE_ROLE_DELIVERY);
$class = self::generateUsers($count, $topClass, $role, 'Test-Taker ', 'tt');
$groupClass = new \core_kernel_classes_Class(TAO_GROUP_CLASS);
$group = $groupClass->createInstanceWithProperties(array(RDFS_LABEL => $class->getLabel(), TAO_GROUP_MEMBERS_PROP => $class->getInstances()));
return $class;
}
示例9: createAssemblyFromServiceCall
public function createAssemblyFromServiceCall(core_kernel_classes_Class $deliveryClass, tao_models_classes_service_ServiceCall $serviceCall, $properties = array())
{
$properties[PROPERTY_COMPILEDDELIVERY_TIME] = time();
$properties[PROPERTY_COMPILEDDELIVERY_RUNTIME] = $serviceCall->toOntology();
if (!isset($properties[TAO_DELIVERY_RESULTSERVER_PROP])) {
$properties[TAO_DELIVERY_RESULTSERVER_PROP] = taoResultServer_models_classes_ResultServerAuthoringService::singleton()->getDefaultResultServer();
}
$compilationInstance = $deliveryClass->createInstanceWithProperties($properties);
return $compilationInstance;
}
示例10: buildCompiledDelivery
private function buildCompiledDelivery(core_kernel_classes_Resource $delivery, core_kernel_classes_Resource $workflow)
{
$directory = $this->getCompilationDirectory($delivery);
$this->replaceItemRunner($workflow, $directory);
$serviceCall = new tao_models_classes_service_ServiceCall(new core_kernel_classes_Resource(INSTANCE_SERVICE_PROCESSRUNNER));
$param = new tao_models_classes_service_ConstantParameter(new core_kernel_classes_Resource(INSTANCE_FORMALPARAM_PROCESSDEFINITION), $workflow);
$serviceCall->addInParameter($param);
$compilationClass = new core_kernel_classes_Class(CLASS_COMPILEDDELIVERY);
$compilationInstance = $compilationClass->createInstanceWithProperties(array(RDFS_LABEL => $delivery->getLabel(), PROPERTY_COMPILEDDELIVERY_DELIVERY => $delivery, PROPERTY_COMPILEDDELIVERY_FOLDER => $directory, PROPERTY_COMPILEDDELIVERY_TIME => time(), PROPERTY_COMPILEDDELIVERY_RUNTIME => $serviceCall->toOntology()));
return $compilationInstance;
}
示例11: create
/**
* Short description of method create
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @param Class type
* @param string label
* @param string comment
* @return core_kernel_classes_Resource
*/
public static function create(core_kernel_classes_Class $type, $label = '', $comment = '')
{
$returnValue = null;
$propertiesValues = array();
if (!empty($label)) {
$propertiesValues[RDFS_LABEL] = $label;
}
if (!empty($comment)) {
$propertiesValues[RDFS_COMMENT] = $comment;
}
$returnValue = $type->createInstanceWithProperties($propertiesValues);
return $returnValue;
}
示例12: setUp
/**
* initialize a test method
*/
public function setUp()
{
parent::setUp();
$login = 'wfTester';
$userData = array(PROPERTY_USER_LOGIN => $login, PROPERTY_USER_PASSWORD => core_kernel_users_Service::getPasswordHash()->encrypt($this->userPassword), PROPERTY_USER_DEFLG => 'http://www.tao.lu/Ontologies/TAO.rdf#Lang' . DEFAULT_LANG, PROPERTY_USER_UILG => 'http://www.tao.lu/Ontologies/TAO.rdf#Lang' . DEFAULT_LANG, PROPERTY_USER_ROLES => INSTANCE_ROLE_WORKFLOW);
if (!$this->userService->loginAvailable($login)) {
$this->fail('test login already taken');
}
$userClass = new core_kernel_classes_Class(CLASS_WORKFLOWUSER);
$this->currentUser = $userClass->createInstanceWithProperties($userData);
$this->currentUser0 = $this->currentUser;
$this->service = wfEngine_models_classes_ActivityExecutionService::singleton();
}
示例13: createFileSystem
/**
* creates a new FileSystem
*
* @access public
* @author Jerome Bogaerts, <jerome@taotesting.com>
* @param Resource type
* @param string url
* @param string login
* @param string password
* @param string path
* @param string label
* @param boolean enabled
* @return core_kernel_versioning_Repository
*/
public static function createFileSystem(core_kernel_classes_Resource $type, $url, $login, $password, $path, $label, $enabled = false)
{
$path = rtrim($path, "\\/") . DIRECTORY_SEPARATOR;
if (!file_exists($path)) {
if (!mkdir($path, 0700, true)) {
throw new common_exception_Error("Could not create path '" . $path . "' for filesystem '" . $label . "'");
}
}
$versioningRepositoryClass = new core_kernel_classes_Class(CLASS_GENERIS_VERSIONEDREPOSITORY);
$resource = $versioningRepositoryClass->createInstanceWithProperties(array(RDFS_LABEL => $label, PROPERTY_GENERIS_VERSIONEDREPOSITORY_URL => $url, PROPERTY_GENERIS_VERSIONEDREPOSITORY_PATH => $path, PROPERTY_GENERIS_VERSIONEDREPOSITORY_TYPE => $type, PROPERTY_GENERIS_VERSIONEDREPOSITORY_LOGIN => $login, PROPERTY_GENERIS_VERSIONEDREPOSITORY_PASSWORD => $password, PROPERTY_GENERIS_VERSIONEDREPOSITORY_ENABLED => $enabled ? GENERIS_TRUE : GENERIS_FALSE));
core_kernel_fileSystem_Cache::flushCache();
return new core_kernel_fileSystem_FileSystem($resource);
}
示例14: setUp
public function setUp()
{
TaoPhpUnitTestRunner::initTest();
$this->disableCache();
// creates a user using remote script from joel
$userdata = $this->getUserData();
$password = $userdata[PROPERTY_USER_PASSWORD];
$userdata[PROPERTY_USER_PASSWORD] = \core_kernel_users_Service::getPasswordHash()->encrypt($userdata[PROPERTY_USER_PASSWORD]);
$tmclass = new \core_kernel_classes_Class(CLASS_TAO_USER);
$user = $tmclass->createInstanceWithProperties($userdata);
\common_Logger::i('Created user ' . $user->getUri());
$this->login = $userdata[PROPERTY_USER_LOGIN];
$this->password = $password;
$this->userUri = $user->getUri();
}
示例15: createCardinality
/**
* creates a new cardinality resource that links to "step"
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param Resource step
* @param int cardinality
* @return core_kernel_classes_Resource
*/
public function createCardinality(core_kernel_classes_Resource $step, $cardinality = 1)
{
$returnValue = null;
$cardinalityValue = null;
if (is_numeric($cardinality)) {
$cardinalityValue = intval($cardinality);
} else {
if ($cardinality instanceof core_kernel_classes_Resource || common_Utils::isUri($cardinality)) {
$cardinalityValue = $cardinality;
}
}
if (!is_null($cardinalityValue)) {
$class = new core_kernel_classes_Class(CLASS_ACTIVITYCARDINALITY);
$returnValue = $class->createInstanceWithProperties(array(PROPERTY_STEP_NEXT => $step, PROPERTY_ACTIVITYCARDINALITY_CARDINALITY => $cardinalityValue));
}
return $returnValue;
}