ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilWebResourceImporter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected ?ilObjLinkResource $link = null;
27
28 protected ilLogger $logger;
29
30 public function __construct()
31 {
32 global $DIC;
33
35 $this->logger = $DIC->logger()->webr();
36 }
37
41 public function importXmlRepresentation(
42 string $a_entity,
43 string $a_id,
44 string $a_xml,
45 ilImportMapping $a_mapping
46 ): void {
47 if ($new_id = $a_mapping->getMapping(
48 'components/ILIAS/Container',
49 'objs',
50 $a_id
51 )) {
52 $this->link = ilObjectFactory::getInstanceByObjId((int) $new_id, false);
53 if (!$this->link instanceof ilObjLinkResource) {
55 'Invalid id given ' . $a_id
56 );
57 }
58 } else {
59 $this->link = new ilObjLinkResource();
60 $this->link->setType('webr');
61 $this->link->create();
62 }
63
64 try {
65 $parser = new ilWebLinkXmlParser($this->link, $a_xml);
66 $parser->setMode(ilWebLinkXmlParser::MODE_CREATE);
67 $parser->start();
68 $a_mapping->addMapping(
69 'components/ILIAS/WebResource',
70 'webr',
71 $a_id,
72 (string) $this->link->getId()
73 );
74
75 $a_mapping->addMapping(
76 'components/ILIAS/MetaData',
77 'md',
78 $a_id . ':0:webr',
79 $this->link->getId() . ':0:webr'
80 );
81 } catch (ilSaxParserException $e) {
82 $this->logger->error(
83 ': Parsing failed with message, "' . $e->getMessage() . '".'
84 );
85 } catch (ilWebLinkXMLParserException $e) {
86 $this->logger->error(
87 ': Parsing failed with message, "' . $e->getMessage() . '".'
88 );
89 }
90 }
91}
Component logger with individual log levels by component id.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
@inheritDoc
Xml importer class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
link(string $caption, string $href, bool $new_viewport=false)
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26