本文整理汇总了PHP中Component::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::setId方法的具体用法?PHP Component::setId怎么用?PHP Component::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Component
的用法示例。
在下文中一共展示了Component::setId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addCourse
/**
* Adds the component to a course
*
* Called when this component receives an HTTP POST request to
* /course(/).
*/
public function addCourse()
{
Logger::Log('starts POST AddCourse', LogLevel::DEBUG);
$header = $this->app->request->headers->all();
$body = $this->app->request->getBody();
$courses = Course::decodeCourse($body);
$processes = array();
if (!is_array($courses)) {
$courses = array($courses);
}
foreach ($courses as $course) {
$process = new Process();
$exercise = new Exercise();
$exercise->setCourseId($course->getId());
$process->setExercise($exercise);
$component = new Component();
$component->setId($this->_conf->getId());
$process->setTarget($component);
$processes[] = $process;
}
foreach ($this->_postProcess as $_link) {
$result = Request::routeRequest('POST', '/process', $header, Process::encodeProcess($processes), $_link, 'process');
// checks the correctness of the query
if ($result['status'] >= 200 && $result['status'] <= 299) {
$this->app->response->setStatus(201);
if (isset($result['headers']['Content-Type'])) {
$this->app->response->headers->set('Content-Type', $result['headers']['Content-Type']);
}
} else {
/* if ($courses->getId()!==null){
$this->deleteCourse($courses->getId());
}*/
Logger::Log('POST AddCourse failed', LogLevel::ERROR);
$this->app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
$this->app->response->setBody(Course::encodeCourse($courses));
$this->app->stop();
}
}
$this->app->response->setBody(Course::encodeCourse($courses));
}
示例2: sendComponentDefinitions
/**
* Initializes all components, with the data, which can be found in database.
*/
public function sendComponentDefinitions()
{
$this->_app->response->setStatus(200);
// starts a query
ob_start();
eval("?>" . file_get_contents(dirname(__FILE__) . '/Sql/GetComponentDefinitions.sql'));
$sql = ob_get_contents();
ob_end_clean();
$result = DBRequest::request($sql, false, parse_ini_file(dirname(__FILE__) . '/config.ini', TRUE));
// checks the correctness of the query
if ((!isset($result['errno']) || !$result['errno']) && $result['content']) {
$data = DBJson::getRows($result['content']);
$Components = DBJson::getObjectsByAttributes($data, Component::getDBPrimaryKey(), Component::getDBConvert());
$Links = DBJson::getObjectsByAttributes($data, Link::getDBPrimaryKey(), Link::getDBConvert());
$objects = DBJson::concatResultObjectLists($data, $Components, Component::getDBPrimaryKey(), Component::getDBConvert()['CO_links'], $Links, Link::getDBPrimaryKey());
$request = new Request_MultiRequest();
$data = parse_ini_file(dirname(__FILE__) . '/config.ini', TRUE);
$tempObjects = array();
foreach ($objects as $object) {
$object = Component::decodeComponent(json_encode($object));
// prüfen, welche Komponente auf diesem Server ist
if (strpos($object->getAddress() . '/', $data['PL']['urlExtern'] . '/') === false) {
continue;
}
$object->setAddress($data['PL']['url'] . substr($object->getAddress(), strlen($data['PL']['urlExtern'])));
$links = $object->getLinks();
foreach ($links as &$link) {
if (strpos($link->getAddress() . '/', $data['PL']['urlExtern'] . '/') === false) {
continue;
}
$link->setAddress($data['PL']['url'] . substr($link->getAddress(), strlen($data['PL']['urlExtern'])));
}
$object->setLinks($links);
$result = Request_CreateRequest::createPost($object->getAddress() . '/control', array(), Component::encodeComponent($object));
$tempObjects[] = $object;
$request->addRequest($result);
}
$results = $request->run();
$objects = $tempObjects;
$i = 0;
$res = array();
foreach ($objects as $object) {
$object = Component::decodeComponent(Component::encodeComponent($object));
$result = $results[$i++];
$newObject = new Component();
$newObject->setId($object->getId());
$newObject->setName($object->getName());
$newObject->setAddress($object->getAddress());
$newObject->setDef($object->getDef());
$newObject->setStatus($result['status']);
$res[] = $newObject;
if ($result['status'] != 201) {
$add = '';
$this->_app->response->setStatus(409);
if (isset($result['content'])) {
$add = $result['content'];
}
Logger::Log($result['status'] . '--' . $object->getName() . '--' . $object->getAddress() . "\n" . $add . "\n", LogLevel::ERROR);
}
}
$this->_app->response->setBody(json_encode($res));
} else {
Logger::Log('GET SendComponentDefinitions failed', LogLevel::ERROR);
$this->_app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
}
}
示例3: addCourse
/**
* Adds the component to a course
*
* Called when this component receives an HTTP POST request to
* /course(/).
*/
public function addCourse()
{
Logger::Log('starts POST AddCourse', LogLevel::DEBUG);
$body = $this->app->request->getBody();
// die Daten der Veranstaltung kommen über den Aufrufkörper rein
$courses = Course::decodeCourse($body);
$processes = array();
if (!is_array($courses)) {
$courses = array($courses);
}
// wenn die Komponente direkt in mehrere Veranstaltungen eingetragen werden soll,
// wird das Eintragen für alle vorgenommen
foreach ($courses as $course) {
// ab hier wird der neue Eintrag zusammengestellt
$process = new Process();
$exercise = new Exercise();
$exercise->setCourseId($course->getId());
$process->setExercise($exercise);
$component = new Component();
$component->setId($this->_conf->getId());
$process->setTarget($component);
// und nun wird gesammelt
$processes[] = $process;
}
// die erstellten Einträge können nun an den Zuständigen geschickt werden
foreach ($this->_postProcess as $_link) {
$result = Request::routeRequest('POST', '/process', array(), Process::encodeProcess($processes), $_link, 'process');
// checks the correctness of the query
if ($result['status'] >= 200 && $result['status'] <= 299) {
// wenn der Erstellvorgang erfolgreich war, können wir dies melden
$this->app->response->setStatus(201);
if (isset($result['headers']['Content-Type'])) {
$this->app->response->headers->set('Content-Type', $result['headers']['Content-Type']);
}
} else {
// der Eintrag konnte nicht erstellt werden
/* if ($courses->getId()!==null){
$this->deleteCourse($courses->getId());
}*/
Logger::Log('POST AddCourse failed', LogLevel::ERROR);
// gibt den Status der "Erstellanfrage" zurück oder eine 409 und zusätzlich
// das eingehende Veranstaltungsobjekt
$this->app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
$this->app->response->setBody(Course::encodeCourse($courses));
$this->app->stop();
}
}
// die bearbeiteten Veranstaltungen können nun zur Ausgabe hinzugefügt werden
$this->app->response->setBody(Course::encodeCourse($courses));
}
示例4: foreach
########################
#endregion
#region create_processors
###############################
### begin create_processors ###
###############################
// create processor data
foreach ($exercise as $key2 => $subexercise) {
if (isset($subexercise['processorType'])) {
$tempProcessors = array();
$processorType = $subexercise['processorType'];
foreach ($processorType as $tempKey => $Data) {
$processor = new Process();
$processor->setExercise(Exercise::decodeExercise(json_encode($subexercise)));
$component = new Component();
$component->setId($Data);
$processor->SetTarget($component);
$processor->SetProcessId(isset($subexercise['processorId'][$tempKey]) ? $subexercise['processorId'][$tempKey] : null);
// add attachement if given
if (isset($_FILES['exercises']) && isset($_FILES['exercises']['error']) && isset($_FILES['exercises']['error'][$key1]) && isset($_FILES['exercises']['error'][$key1]['subexercises']) && isset($_FILES['exercises']['error'][$key1]['subexercises'][$key2]) && isset($_FILES['exercises']['error'][$key1]['subexercises'][$key2]['processAttachment']) && isset($_FILES['exercises']['error'][$key1]['subexercises'][$key2]['processAttachment'][$tempKey])) {
if ($_FILES['exercises']['error'][$key1]['subexercises'][$key2]['processAttachment'][$tempKey] != 4) {
$filePath = $_FILES['exercises']['tmp_name'][$key1]['subexercises'][$key2]['processAttachment'][$tempKey];
$displayName = $_FILES['exercises']['name'][$key1]['subexercises'][$key2]['processAttachment'][$tempKey];
$attachments = array();
foreach ($filePath as $attachKey => $attachPath) {
$attachment = new Attachment();
$attachementFile = File::createFile(NULL, $displayName[$attachKey], NULL, $timestamp, NULL, NULL, NULL);
$attachementFile->setBody(Reference::createReference($attachPath));
$attachment->setFile($attachementFile);
$attachments[] = $attachment;
}