ILIAS  release_8 Revision v8.24
class.ilWebResourceImporter.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
28 protected ?ilObjLinkResource $link = null;
29
30 protected ilLogger $logger;
31
32 public function __construct()
33 {
34 global $DIC;
35
37 $this->logger = $DIC->logger()->webr();
38 }
39
43 public function importXmlRepresentation(
44 string $a_entity,
45 string $a_id,
46 string $a_xml,
47 ilImportMapping $a_mapping
48 ): void {
49 if ($new_id = $a_mapping->getMapping(
50 'Services/Container',
51 'objs',
52 $a_id
53 )) {
54 $this->link = ilObjectFactory::getInstanceByObjId((int) $new_id, false);
55 if (!$this->link instanceof ilObjLinkResource) {
57 'Invalid id given ' . $a_id
58 );
59 }
60 } else {
61 $this->link = new ilObjLinkResource();
62 $this->link->setType('webr');
63 $this->link->create(true);
64 }
65
66 try {
67 $parser = new ilWebLinkXmlParser($this->link, $a_xml);
68 $parser->setMode(ilWebLinkXmlParser::MODE_CREATE);
69 $parser->start();
70 $a_mapping->addMapping(
71 'Modules/WebResource',
72 'webr',
73 $a_id,
74 (string) $this->link->getId()
75 );
76 } catch (ilSaxParserException $e) {
77 $this->logger->error(
78 ': Parsing failed with message, "' . $e->getMessage() . '".'
79 );
80 } catch (ilWebLinkXMLParserException $e) {
81 $this->logger->error(
82 ': Parsing failed with message, "' . $e->getMessage() . '".'
83 );
84 }
85 }
86}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Component logger with individual log levels by component id.
Class ilObjLinkResource.
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...
SaxParserException thrown by ilSaxParser if property throwException is set.
XML parser for weblink xml.
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc