From 3aeec4c1839d51ef4a0b5f2813195b0741ffbb71 Mon Sep 17 00:00:00 2001 From: Christoph Ludolf Date: Wed, 23 Oct 2024 13:43:25 +0200 Subject: [PATCH] Export: import validation refactoring --- .../class.ilDidacticTemplateImport.php | 13 +- components/ILIAS/Export/README-technical.md | 16 +- .../Export/classes/ImportHandler/Factory.php | 99 ++++++++++ .../classes/ImportHandler/File/Factory.php | 78 ++++++++ .../File/{class.ilHandler.php => Handler.php} | 29 ++- ...{class.ilCollection.php => Collection.php} | 8 +- .../{class.ilFactory.php => Factory.php} | 12 +- .../{class.ilHandler.php => Handler.php} | 4 +- .../File/Path/Comparison/class.ilFactory.php | 36 ---- .../File/Path/Node/class.ilFactory.php | 83 -------- .../File/Path/class.ilFactory.php | 56 ------ .../File/Validation/class.ilFactory.php | 57 ------ ...{class.ilCollection.php => Collection.php} | 6 +- ...{class.ilCollection.php => Collection.php} | 6 +- .../File/XML/Export/Component/Factory.php | 61 ++++++ .../{class.ilHandler.php => Handler.php} | 34 ++-- .../XML/Export/Component/class.ilFactory.php | 71 ------- .../File/XML/Export/DataSet/Factory.php | 61 ++++++ .../XML/Export/DataSet/class.ilFactory.php | 71 ------- .../{class.ilHandler.php => ilHandler.php} | 36 ++-- .../{class.ilFactory.php => Factory.php} | 36 ++-- .../{class.ilHandler.php => Handler.php} | 48 ++--- .../ImportHandler/File/XML/Factory.php | 100 ++++++++++ .../XML/{class.ilHandler.php => Handler.php} | 34 ++-- ...ilHandlerCollection.php => Collection.php} | 36 ++-- ...ortObjectType.php => ExportObjectType.php} | 12 +- .../File/XML/Manifest/Factory.php | 68 +++++++ .../File/XML/Manifest/Handler.php | 178 +++++++++++++++++ .../File/XML/Manifest/class.ilFactory.php | 83 -------- .../File/XML/Manifest/class.ilHandler.php | 175 ----------------- .../Node/Info/Attribute/class.ilFactory.php | 48 ----- .../XML/Node/Info/DOM/class.ilFactory.php | 45 ----- .../File/XML/Node/Info/class.ilFactory.php | 68 ------- .../File/XML/Node/class.ilFactory.php | 42 ---- .../File/XML/Schema/class.ilFactory.php | 124 ------------ .../File/XML/Schema/class.ilHandler.php | 161 ---------------- .../File/XML/class.ilFactory.php | 103 ---------- .../XSD/{class.ilFactory.php => Factory.php} | 10 +- .../XSD/{class.ilHandler.php => Handler.php} | 10 +- .../ImportHandler/File/class.ilFactory.php | 86 --------- .../ImportHandler/I/FactoryInterface.php | 40 ++++ ...toryInterface.php => FactoryInterface.php} | 14 +- ...dlerInterface.php => HandlerInterface.php} | 14 +- ...nInterface.php => CollectionInterface.php} | 8 +- ...toryInterface.php => FactoryInterface.php} | 6 +- ...dlerInterface.php => HandlerInterface.php} | 6 +- .../interface.ilFactoryInterface.php | 32 ---- .../Node/interface.ilAttributeInterface.php | 33 ---- .../Node/interface.ilFactoryInterface.php | 46 ----- .../Path/Node/interface.ilIndexInterface.php | 33 ---- .../interface.ilOpenRoundBrackedInterface.php | 27 --- .../Path/Node/interface.ilSimpleInterface.php | 28 --- .../Path/interface.ilFactoryInterface.php | 38 ---- .../Set/interface.ilHandlerInterface.php | 40 ---- ...nInterface.php => CollectionInterface.php} | 10 +- ...nInterface.php => CollectionInterface.php} | 8 +- ...toryInterface.php => FactoryInterface.php} | 4 +- ...dlerInterface.php => HandlerInterface.php} | 6 +- ...toryInterface.php => FactoryInterface.php} | 4 +- ...dlerInterface.php => HandlerInterface.php} | 6 +- ...toryInterface.php => FactoryInterface.php} | 10 +- ...dlerInterface.php => HandlerInterface.php} | 16 +- .../I/File/XML/FactoryInterface.php | 37 ++++ ...dlerInterface.php => HandlerInterface.php} | 6 +- ...toryInterface.php => FactoryInterface.php} | 11 +- ...ace.php => HandlerCollectionInterface.php} | 14 +- ...dlerInterface.php => HandlerInterface.php} | 14 +- .../Info/DOM/interface.ilFactoryInterface.php | 11 -- .../Info/interface.ilFactoryInterface.php | 37 ---- .../XML/Node/interface.ilFactoryInterface.php | 28 --- .../Schema/interface.ilFactoryInterface.php | 36 ---- .../File/XML/interface.ilFactoryInterface.php | 44 ----- ...toryInterface.php => FactoryInterface.php} | 4 +- .../HandlerInterface.php} | 7 +- .../I/Parser/DOM/FactoryInterface.php | 28 +++ ...toryInterface.php => HandlerInterface.php} | 8 +- .../DOM/interface.ilHandlerInterface.php | 29 --- ...toryInterface.php => FactoryInterface.php} | 9 +- ...dlerInterface.php => HandlerInterface.php} | 12 +- .../Attribute/CollectionInterface.php} | 10 +- .../NodeInfo/Attribute/FactoryInterface.php} | 10 +- .../NodeInfo/Attribute/HandlerInterface.php} | 8 +- .../NodeInfo/CollectionInterface.php} | 12 +- .../Parser/NodeInfo/DOM/FactoryInterface.php | 11 ++ .../NodeInfo/DOM/HandlerInterface.php} | 10 +- .../I/Parser/NodeInfo/FactoryInterface.php | 37 ++++ .../NodeInfo/HandlerInterface.php} | 8 +- .../Parser/NodeInfo/Tree/FactoryInterface.php | 28 +++ .../NodeInfo/Tree/HandlerInterface.php} | 20 +- .../Comparison/FactoryInterface.php} | 9 +- .../I/Path/Comparison/HandlerInterface.php | 32 ++++ .../ImportHandler/I/Path/FactoryInterface.php | 34 ++++ .../HandlerInterface.php} | 22 ++- .../Node/AnyElementInterface.php} | 6 +- .../Node/AnyNodeInterface.php} | 6 +- .../I/Path/Node/AttributeInterface.php | 33 ++++ .../Path/Node/CloseRoundBrackedInterface.php | 27 +++ .../I/Path/Node/FactoryInterface.php | 46 +++++ .../Path/Node/IndexInterface.php} | 21 +- .../Node/NodeInterface.php} | 4 +- .../Node/OpenRoundBrackedInterface.php} | 6 +- .../I/Path/Node/SimpleInterface.php | 28 +++ .../CollectionInterface.php} | 14 +- .../I/Schema/FactoryInterface.php | 44 +++++ .../Schema/Folder/FactoryInterface.php} | 11 +- .../I/Schema/Folder/HandlerInterface.php | 33 ++++ .../HandlerInterface.php} | 25 ++- .../I/Schema/Info/CollectionInterface.php | 46 +++++ .../I/Schema/Info/FactoryInterface.php | 31 +++ .../I/Schema/Info/HandlerInterface.php | 51 +++++ .../FactoryInterface.php} | 8 +- .../HandlerInterface.php} | 14 +- .../Set/CollectionInterface.php} | 10 +- .../Set/FactoryInterface.php} | 8 +- .../I/Validation/Set/HandlerInterface.php | 46 +++++ .../I/interface.ilFactoryInterface.php | 31 --- .../ImportHandler/Parser/DOM/Factory.php | 49 +++++ .../DOM/{class.ilHandler.php => Handler.php} | 16 +- .../Parser/DOM/class.ilFactory.php | 48 ----- .../classes/ImportHandler/Parser/Factory.php | 59 ++++++ .../NodeInfo/Attribute/Collection.php} | 20 +- .../Parser/NodeInfo/Attribute/Factory.php | 50 +++++ .../NodeInfo/Attribute/Handler.php} | 16 +- .../NodeInfo/Collection.php} | 28 +-- .../Parser/NodeInfo/DOM/Factory.php | 45 +++++ .../NodeInfo/DOM/Handler.php} | 24 +-- .../ImportHandler/Parser/NodeInfo/Factory.php | 74 +++++++ .../Parser/NodeInfo/Tree/Factory.php | 50 +++++ .../NodeInfo/Tree/Handler.php} | 58 +++--- .../ImportHandler/Parser/class.ilFactory.php | 44 ----- .../ImportHandler/Path/Comparison/Factory.php | 33 ++++ .../ImportHandler/Path/Comparison/Handler.php | 51 +++++ .../Comparison/Operator.php} | 2 +- .../classes/ImportHandler/Path/Factory.php | 58 ++++++ .../class.ilHandler.php => Path/Handler.php} | 10 +- .../Node/AnyElement.php} | 6 +- .../Node/AnyNode.php} | 6 +- .../Node/Attribute.php} | 16 +- .../Node/CloseRoundBracked.php} | 6 +- .../ImportHandler/Path/Node/Factory.php | 83 ++++++++ .../class.ilIndex.php => Path/Node/Index.php} | 18 +- .../Node/OpenRoundBracked.php} | 6 +- .../Node/Simple.php} | 6 +- .../Collection.php} | 24 +-- .../classes/ImportHandler/Schema/Factory.php | 109 +++++++++++ .../ImportHandler/Schema/Folder/Factory.php | 49 +++++ .../Schema/Folder/Handler.php} | 91 ++++----- .../classes/ImportHandler/Schema/Handler.php | 180 ++++++++++++++++++ .../ImportHandler/Schema/Info/Collection.php | 110 +++++++++++ .../ImportHandler/Schema/Info/Factory.php | 51 +++++ .../Schema/Info/Handler.php} | 43 ++++- .../ImportHandler/Validation/Factory.php | 62 ++++++ .../Handler.php} | 34 ++-- .../Set/Collection.php} | 20 +- .../Set/Factory.php} | 14 +- .../Set/Handler.php} | 27 +-- .../classes/ImportHandler/class.ilFactory.php | 61 ------ .../class.ilXmlSchemaInfoCollection.php | 36 ---- .../ILIAS/Export/classes/class.ilImport.php | 26 +-- .../File/Namespace/ilCollectionTest.php | 6 +- .../File/Namespace/ilHandlerTest.php | 2 +- .../File/Path/Comparison/ilHandlerTest.php | 17 +- .../File/Path/Node/ilAnyElementTest.php | 2 +- .../File/Path/Node/ilAnyNodeTest.php | 2 +- .../File/Path/Node/ilAttributeTest.php | 4 +- .../Path/Node/ilCloseRoundBrackedTest.php | 2 +- .../File/Path/Node/ilIndexTest.php | 4 +- .../File/Path/Node/ilOpenRoundBrackedTest.php | 2 +- .../File/Path/Node/ilSimpleTest.php | 2 +- .../ImportHandler/File/Path/ilHandlerTest.php | 4 +- .../File/Validation/Set/ilCollectionTest.php | 4 +- .../File/Validation/Set/ilHandlerTest.php | 8 +- .../Node/Info/Attribute/ilCollectionTest.php | 6 +- .../XML/Node/Info/Attribute/ilPairTest.php | 2 +- .../File/XML/Node/Info/ilCollectionTest.php | 12 +- .../ImportHandler/File/ilHandlerTest.php | 6 +- 176 files changed, 3093 insertions(+), 2679 deletions(-) create mode 100755 components/ILIAS/Export/classes/ImportHandler/Factory.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/File/Factory.php rename components/ILIAS/Export/classes/ImportHandler/File/{class.ilHandler.php => Handler.php} (77%) rename components/ILIAS/Export/classes/ImportHandler/File/Namespace/{class.ilCollection.php => Collection.php} (83%) rename components/ILIAS/Export/classes/ImportHandler/File/Namespace/{class.ilFactory.php => Factory.php} (61%) rename components/ILIAS/Export/classes/ImportHandler/File/Namespace/{class.ilHandler.php => Handler.php} (88%) delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/Path/Comparison/class.ilFactory.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilFactory.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/Path/class.ilFactory.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/Validation/class.ilFactory.php rename components/ILIAS/Export/classes/ImportHandler/File/XML/{class.ilCollection.php => Collection.php} (88%) rename components/ILIAS/Export/classes/ImportHandler/File/XML/Export/{class.ilCollection.php => Collection.php} (87%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/Factory.php rename components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/{class.ilHandler.php => Handler.php} (79%) delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/class.ilFactory.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/Factory.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/class.ilFactory.php rename components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/{class.ilHandler.php => ilHandler.php} (81%) rename components/ILIAS/Export/classes/ImportHandler/File/XML/Export/{class.ilFactory.php => Factory.php} (57%) rename components/ILIAS/Export/classes/ImportHandler/File/XML/Export/{class.ilHandler.php => Handler.php} (66%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Factory.php rename components/ILIAS/Export/classes/ImportHandler/File/XML/{class.ilHandler.php => Handler.php} (65%) rename components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/{class.ilHandlerCollection.php => Collection.php} (72%) rename components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/{enum.ilExportObjectType.php => ExportObjectType.php} (70%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Factory.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Handler.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilFactory.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilHandler.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/Attribute/class.ilFactory.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/DOM/class.ilFactory.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/class.ilFactory.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/Node/class.ilFactory.php delete mode 100644 components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilFactory.php delete mode 100644 components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilHandler.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/XML/class.ilFactory.php rename components/ILIAS/Export/classes/ImportHandler/File/XSD/{class.ilFactory.php => Factory.php} (67%) rename components/ILIAS/Export/classes/ImportHandler/File/XSD/{class.ilHandler.php => Handler.php} (64%) delete mode 100755 components/ILIAS/Export/classes/ImportHandler/File/class.ilFactory.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/FactoryInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/File/{interface.ilFactoryInterface.php => FactoryInterface.php} (55%) rename components/ILIAS/Export/classes/ImportHandler/I/File/{interface.ilHandlerInterface.php => HandlerInterface.php} (73%) rename components/ILIAS/Export/classes/ImportHandler/I/File/Namespace/{interface.ilCollectionInterface.php => CollectionInterface.php} (78%) rename components/ILIAS/Export/classes/ImportHandler/I/File/Namespace/{interface.ilFactoryInterface.php => FactoryInterface.php} (75%) rename components/ILIAS/Export/classes/ImportHandler/I/File/Namespace/{interface.ilHandlerInterface.php => HandlerInterface.php} (80%) delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/Path/Comparison/interface.ilFactoryInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilAttributeInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilFactoryInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilIndexInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilOpenRoundBrackedInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilSimpleInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/Path/interface.ilFactoryInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/Validation/Set/interface.ilHandlerInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/{interface.ilCollectionInterface.php => CollectionInterface.php} (72%) rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/Export/{interface.ilCollectionInterface.php => CollectionInterface.php} (78%) rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/Export/Component/{interface.ilFactoryInterface.php => FactoryInterface.php} (82%) rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/Export/Component/{interface.ilHandlerInterface.php => HandlerInterface.php} (72%) rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/Export/DataSet/{interface.ilFactoryInterface.php => FactoryInterface.php} (82%) rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/Export/DataSet/{interface.ilHandlerInterface.php => HandlerInterface.php} (71%) rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/Export/{interface.ilFactoryInterface.php => FactoryInterface.php} (65%) rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/Export/{interface.ilHandlerInterface.php => HandlerInterface.php} (57%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/XML/FactoryInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/{interface.ilHandlerInterface.php => HandlerInterface.php} (75%) rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/Manifest/{interface.ilFactoryInterface.php => FactoryInterface.php} (57%) rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/Manifest/{interface.ilHandlerCollectionInterface.php => HandlerCollectionInterface.php} (69%) rename components/ILIAS/Export/classes/ImportHandler/I/File/XML/Manifest/{interface.ilHandlerInterface.php => HandlerInterface.php} (62%) delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/XML/Node/Info/DOM/interface.ilFactoryInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/XML/Node/Info/interface.ilFactoryInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/XML/Node/interface.ilFactoryInterface.php delete mode 100644 components/ILIAS/Export/classes/ImportHandler/I/File/XML/Schema/interface.ilFactoryInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/File/XML/interface.ilFactoryInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/File/XSD/{interface.ilFactoryInterface.php => FactoryInterface.php} (85%) rename components/ILIAS/Export/classes/ImportHandler/I/File/{Path/Comparison/interface.ilHandlerInterface.php => XSD/HandlerInterface.php} (74%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Parser/DOM/FactoryInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/Parser/DOM/{interface.ilFactoryInterface.php => HandlerInterface.php} (71%) delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Parser/DOM/interface.ilHandlerInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/Parser/{interface.ilFactoryInterface.php => FactoryInterface.php} (60%) rename components/ILIAS/Export/classes/ImportHandler/I/Parser/{interface.ilHandlerInterface.php => HandlerInterface.php} (62%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/XML/Node/Info/Attribute/interface.ilCollectionInterface.php => Parser/NodeInfo/Attribute/CollectionInterface.php} (72%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/XML/Node/Info/Attribute/interface.ilFactoryInterface.php => Parser/NodeInfo/Attribute/FactoryInterface.php} (60%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/XML/Node/Info/Attribute/interface.ilPairInterface.php => Parser/NodeInfo/Attribute/HandlerInterface.php} (74%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/XML/Node/Info/interface.ilCollectionInterface.php => Parser/NodeInfo/CollectionInterface.php} (72%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Parser/NodeInfo/DOM/FactoryInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/{File/XML/Node/Info/DOM/interface.ilHandlerInterface.php => Parser/NodeInfo/DOM/HandlerInterface.php} (61%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Parser/NodeInfo/FactoryInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/{File/XML/Node/Info/interface.ilHandlerInterface.php => Parser/NodeInfo/HandlerInterface.php} (77%) create mode 100644 components/ILIAS/Export/classes/ImportHandler/I/Parser/NodeInfo/Tree/FactoryInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/{File/XML/Node/Info/interface.ilTreeInterface.php => Parser/NodeInfo/Tree/HandlerInterface.php} (63%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/XSD/interface.ilHandlerInterface.php => Path/Comparison/FactoryInterface.php} (67%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Path/Comparison/HandlerInterface.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Path/FactoryInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/{File/Path/interface.ilHandlerInterface.php => Path/HandlerInterface.php} (55%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/Path/Node/interface.ilCloseRoundBrackedInterface.php => Path/Node/AnyElementInterface.php} (73%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/Path/Node/interface.ilAnyElementInterface.php => Path/Node/AnyNodeInterface.php} (72%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Path/Node/AttributeInterface.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Path/Node/CloseRoundBrackedInterface.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Path/Node/FactoryInterface.php rename components/ILIAS/Export/classes/ImportHandler/{File/Path/Comparison/class.ilHandler.php => I/Path/Node/IndexInterface.php} (50%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/Path/Node/interface.ilNodeInterface.php => Path/Node/NodeInterface.php} (88%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/Path/Node/interface.ilAnyNodeInterface.php => Path/Node/OpenRoundBrackedInterface.php} (71%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Path/Node/SimpleInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/{File/XML/Schema/interface.ilCollectionInterface.php => Schema/CollectionInterface.php} (60%) create mode 100644 components/ILIAS/Export/classes/ImportHandler/I/Schema/FactoryInterface.php rename components/ILIAS/Export/classes/ImportHandler/{File/Path/Comparison/class.ilHandlerDummy.php => I/Schema/Folder/FactoryInterface.php} (68%) mode change 100755 => 100644 create mode 100644 components/ILIAS/Export/classes/ImportHandler/I/Schema/Folder/HandlerInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/{File/XML/Schema/interface.ilHandlerInterface.php => Schema/HandlerInterface.php} (56%) create mode 100644 components/ILIAS/Export/classes/ImportHandler/I/Schema/Info/CollectionInterface.php create mode 100644 components/ILIAS/Export/classes/ImportHandler/I/Schema/Info/FactoryInterface.php create mode 100644 components/ILIAS/Export/classes/ImportHandler/I/Schema/Info/HandlerInterface.php rename components/ILIAS/Export/classes/ImportHandler/I/{File/Validation/interface.ilFactoryInterface.php => Validation/FactoryInterface.php} (69%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/Validation/interface.ilHandlerInterface.php => Validation/HandlerInterface.php} (69%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/Validation/Set/interface.ilCollectionInterface.php => Validation/Set/CollectionInterface.php} (73%) rename components/ILIAS/Export/classes/ImportHandler/I/{File/Validation/Set/interface.ilFactoryInterface.php => Validation/Set/FactoryInterface.php} (69%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/I/Validation/Set/HandlerInterface.php delete mode 100755 components/ILIAS/Export/classes/ImportHandler/I/interface.ilFactoryInterface.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/Parser/DOM/Factory.php rename components/ILIAS/Export/classes/ImportHandler/Parser/DOM/{class.ilHandler.php => Handler.php} (75%) delete mode 100755 components/ILIAS/Export/classes/ImportHandler/Parser/DOM/class.ilFactory.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/Parser/Factory.php rename components/ILIAS/Export/classes/ImportHandler/{File/XML/Node/Info/Attribute/class.ilCollection.php => Parser/NodeInfo/Attribute/Collection.php} (67%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Attribute/Factory.php rename components/ILIAS/Export/classes/ImportHandler/{File/XML/Node/Info/Attribute/class.ilPair.php => Parser/NodeInfo/Attribute/Handler.php} (68%) rename components/ILIAS/Export/classes/ImportHandler/{File/XML/Node/Info/class.ilCollection.php => Parser/NodeInfo/Collection.php} (53%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/DOM/Factory.php rename components/ILIAS/Export/classes/ImportHandler/{File/XML/Node/Info/DOM/class.ilHandler.php => Parser/NodeInfo/DOM/Handler.php} (72%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Factory.php create mode 100644 components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Tree/Factory.php rename components/ILIAS/Export/classes/ImportHandler/{File/XML/Node/Info/class.ilTree.php => Parser/NodeInfo/Tree/Handler.php} (54%) delete mode 100755 components/ILIAS/Export/classes/ImportHandler/Parser/class.ilFactory.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/Path/Comparison/Factory.php create mode 100755 components/ILIAS/Export/classes/ImportHandler/Path/Comparison/Handler.php rename components/ILIAS/Export/classes/ImportHandler/{File/Path/Comparison/enum.Operator.php => Path/Comparison/Operator.php} (94%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/Path/Factory.php rename components/ILIAS/Export/classes/ImportHandler/{File/Path/class.ilHandler.php => Path/Handler.php} (90%) rename components/ILIAS/Export/classes/ImportHandler/{File/Path/Node/class.ilAnyElement.php => Path/Node/AnyElement.php} (76%) rename components/ILIAS/Export/classes/ImportHandler/{File/Path/Node/class.ilAnyNode.php => Path/Node/AnyNode.php} (77%) rename components/ILIAS/Export/classes/ImportHandler/{File/Path/Node/class.ilAttribute.php => Path/Node/Attribute.php} (70%) rename components/ILIAS/Export/classes/ImportHandler/{File/Path/Node/class.ilCloseRoundBracked.php => Path/Node/CloseRoundBracked.php} (73%) create mode 100755 components/ILIAS/Export/classes/ImportHandler/Path/Node/Factory.php rename components/ILIAS/Export/classes/ImportHandler/{File/Path/Node/class.ilIndex.php => Path/Node/Index.php} (73%) rename components/ILIAS/Export/classes/ImportHandler/{File/Path/Node/class.ilOpenRoundBracked.php => Path/Node/OpenRoundBracked.php} (74%) rename components/ILIAS/Export/classes/ImportHandler/{File/Path/Node/class.ilSimple.php => Path/Node/Simple.php} (83%) rename components/ILIAS/Export/classes/ImportHandler/{File/XML/Schema/class.ilCollection.php => Schema/Collection.php} (66%) create mode 100644 components/ILIAS/Export/classes/ImportHandler/Schema/Factory.php create mode 100644 components/ILIAS/Export/classes/ImportHandler/Schema/Folder/Factory.php rename components/ILIAS/Export/classes/{Schema/class.ilXmlSchemaFactory.php => ImportHandler/Schema/Folder/Handler.php} (54%) mode change 100755 => 100644 create mode 100644 components/ILIAS/Export/classes/ImportHandler/Schema/Handler.php create mode 100644 components/ILIAS/Export/classes/ImportHandler/Schema/Info/Collection.php create mode 100644 components/ILIAS/Export/classes/ImportHandler/Schema/Info/Factory.php rename components/ILIAS/Export/classes/{Schema/class.ilXmlSchemaInfo.php => ImportHandler/Schema/Info/Handler.php} (50%) mode change 100755 => 100644 create mode 100755 components/ILIAS/Export/classes/ImportHandler/Validation/Factory.php rename components/ILIAS/Export/classes/ImportHandler/{File/Validation/class.ilHandler.php => Validation/Handler.php} (86%) rename components/ILIAS/Export/classes/ImportHandler/{File/Validation/Set/class.ilCollection.php => Validation/Set/Collection.php} (70%) rename components/ILIAS/Export/classes/ImportHandler/{File/Validation/Set/class.ilFactory.php => Validation/Set/Factory.php} (56%) rename components/ILIAS/Export/classes/ImportHandler/{File/Validation/Set/class.ilHandler.php => Validation/Set/Handler.php} (61%) delete mode 100755 components/ILIAS/Export/classes/ImportHandler/class.ilFactory.php delete mode 100755 components/ILIAS/Export/classes/Schema/class.ilXmlSchemaInfoCollection.php diff --git a/components/ILIAS/DidacticTemplate/classes/class.ilDidacticTemplateImport.php b/components/ILIAS/DidacticTemplate/classes/class.ilDidacticTemplateImport.php index d72e247cffb8..961489250876 100755 --- a/components/ILIAS/DidacticTemplate/classes/class.ilDidacticTemplateImport.php +++ b/components/ILIAS/DidacticTemplate/classes/class.ilDidacticTemplateImport.php @@ -18,10 +18,10 @@ declare(strict_types=1); -use ILIAS\Export\ImportHandler\ilFactory as ilImportHandlerFactory; +use ILIAS\Export\ImportHandler\Factory as ilImportHandlerFactory; use ILIAS\Export\ImportStatus\ilFactory as ilImportStatusFactory; +use ILIAS\Export\ImportStatus\StatusType; use ILIAS\Export\ImportStatus\I\ilCollectionInterface as ilImportStatusCollectionInterface; -use ILIAS\Export\Schema\ilXmlSchemaFactory as ilXMLSchemaFactory; /** * Description of ilDidacticTemplateImport @@ -94,17 +94,16 @@ public function validateImportFile(): ilImportStatusCollectionInterface $status = new ilImportStatusFactory(); if ($this->getInputType() !== self::IMPORT_FILE) { return $status->collection()->withAddedStatus($status->handler() - ->withType(ImportStatus\StatusType::FAILED) + ->withType(StatusType::FAILED) ->withContent($status->content()->builder()->string() ->withString("Invalid import status, import status 'IMPORT_FILE' expected."))); } - $schema = new ilXMLSchemaFactory(); $import = new ilImportHandlerFactory(); $xml_spl_info = new SplFileInfo($this->getInputFile()); - $xsd_spl_info = $schema->getLatest(self::SCHEMA_TYPE); - $xml_file_handler = $import->file()->xml()->withFileInfo($xml_spl_info); + $xsd_spl_info = $import->schema()->folder()->handler()->getLatest(self::SCHEMA_TYPE); + $xml_file_handler = $import->file()->xml()->handler()->withFileInfo($xml_spl_info); $xsd_file_handler = $import->file()->xsd()->withFileInfo($xsd_spl_info); - return $import->file()->validation()->handler()->validateXMLFile($xml_file_handler, $xsd_file_handler); + return $import->validation()->handler()->validateXMLFile($xml_file_handler, $xsd_file_handler); } /** diff --git a/components/ILIAS/Export/README-technical.md b/components/ILIAS/Export/README-technical.md index 18c7c4e8adda..1136ce643546 100755 --- a/components/ILIAS/Export/README-technical.md +++ b/components/ILIAS/Export/README-technical.md @@ -248,8 +248,8 @@ $xml_file_spl = new SplFileInfo('path to my xml file') $xsd_file_spl = new SplFileInfo('path to my xsd file') // Initialize a xml/xsd file handler -$import = new \ILIAS\Export\ImportHandler\ilFactory(); -$xml_file_handler = $import->file()->xml()->withFileInfo($xml_file_spl); +$import = new \ILIAS\Export\ImportHandler\Factory(); +$xml_file_handler = $import->file()->xml()->handler()->withFileInfo($xml_file_spl); $xsd_file_handler = $import->file()->xsd()->withFileInfo($xsd_file_spl); /** @var \ILIAS\Export\ImportStatus\ilCollection $validation_results */ @@ -274,17 +274,17 @@ $xml_file_spl = new SplFileInfo('path to my xml file') $xsd_file_spl = new SplFileInfo('path to my xsd file') // Initialize a xml/xsd file handler -$import = new \ILIAS\Export\ImportHandler\ilFactory(); -$xml_file_handler = $import->file()->xml()->withFileInfo($xml_file_spl); +$import = new \ILIAS\Export\ImportHandler\Factory(); +$xml_file_handler = $import->file()->xml()->handler()->withFileInfo($xml_file_spl); $xsd_file_handler = $import->file()->xsd()->withFileInfo($xsd_file_spl); // Build xPath to xml node // $path->toString() = '/RootElement/namespace:TargetElement' -/** @var \ILIAS\Export\ImportHandler\File\Path\ilHandler $path */ -$path = $import->file()->path()->handler() +/** @var \ILIAS\Export\ImportHandler\Path\Handler $path */ +$path = $import->path()->handler() ->withStartAtRoot(true) - ->withNode($import->file()->path()->node()->simple()->withName('RootElement')) - ->withNode($import->file()->path()->node()->simple()->withName('namespace:TargetElement')); + ->withNode($import->path()->node()->simple()->withName('RootElement')) + ->withNode($import->path()->node()->simple()->withName('namespace:TargetElement')); // Because the path contains the namespace 'namespace' we have to add the namespace // info to the xml file handler diff --git a/components/ILIAS/Export/classes/ImportHandler/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Factory.php new file mode 100755 index 000000000000..4f46889908db --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Factory.php @@ -0,0 +1,99 @@ +logger = $DIC->logger()->root(); + $this->lng = $DIC->language(); + $this->lng->loadLanguageModule("exp"); + $this->import_status_factory = new ilImportStatusFactory(); + $this->data_factory = new ilDataFactory(); + } + + public function parser(): ilImportHandlerParserFactoryInterface + { + return new ilImportHandlerParserFactory( + $this, + $this->logger + ); + } + + public function file(): ilImportHandlerFileFactoryInterface + { + return new ilImportHandlerFileFactory( + $this, + $this->import_status_factory, + $this->logger, + $this->lng, + $this->data_factory + ); + } + + public function schema(): ilImportHandlerSchemaFactoryInterface + { + return new ilImportHandlerSchemaFactory( + $this, + $this->data_factory, + $this->logger + ); + } + + public function path(): ilImportHandlerPathFactoryInterface + { + return new ilImportHandlerPathFactory( + $this->logger + ); + } + + public function validation(): ilImportHandlerValidationFactoryInterface + { + return new ilImportHandlerValidationFactory( + $this->import_status_factory, + $this, + $this->logger + ); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Factory.php b/components/ILIAS/Export/classes/ImportHandler/File/Factory.php new file mode 100755 index 000000000000..6cea31e0af38 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/File/Factory.php @@ -0,0 +1,78 @@ +import_handler = $import_handler; + $this->import_status_factory = $import_status_factory; + $this->logger = $logger; + $this->lng = $lng; + $this->data_factory = $data_factory; + } + + public function xml(): ilXMLFileFactoryInterface + { + return new ilXMLFileFactory( + $this->import_handler, + $this->import_status_factory, + $this->logger, + $this->lng, + $this->data_factory + ); + } + + public function xsd(): ilXSDFileFactoryInterface + { + return new ilXSDFileFactory(); + } + + public function namespace(): ilFileNamespaceFactoryInterface + { + return new ilFileNamespaceFactory(); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/File/Handler.php similarity index 77% rename from components/ILIAS/Export/classes/ImportHandler/File/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/File/Handler.php index a3675dd2adb5..0b4640c3f661 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/Handler.php @@ -20,16 +20,15 @@ namespace ILIAS\Export\ImportHandler\File; -use ilImportException; -use ILIAS\Export\ImportHandler\I\File\ilHandlerInterface as ilFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilCollectionInterface as ilFileNamespaceCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilFactoryInterface as ilFileNamespaceFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilHandlerInterface as ilFileNamespaceHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\HandlerInterface as ilFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\Namespace\CollectionInterface as ilFileNamespaceCollectionInterface; +use ILIAS\Export\ImportHandler\I\File\Namespace\FactoryInterface as ilFileNamespaceFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\Namespace\HandlerInterface as ilFileNamespaceHandlerInterface; use SplFileInfo; -class ilHandler implements ilFileHandlerInterface +class Handler implements ilFileHandlerInterface { - protected SplFileInfo $xml_file_info; + protected SplFileInfo $spl_file_info; protected ilFileNamespaceFactoryInterface $namespace; protected ilFileNamespaceCollectionInterface $namespaces; @@ -55,20 +54,20 @@ public function getNamespaces(): ilFileNamespaceCollectionInterface public function withFileInfo(SplFileInfo $file_info): ilFileHandlerInterface { $clone = clone $this; - $clone->xml_file_info = $file_info; + $clone->spl_file_info = $file_info; return $clone; } public function getFileName(): string { - return $this->xml_file_info->getFilename(); + return $this->spl_file_info->getFilename(); } public function getFilePath(): string { return $this->fileExists() - ? $this->xml_file_info->getRealPath() - : $this->xml_file_info->getPath() . DIRECTORY_SEPARATOR . $this->xml_file_info->getFilename(); + ? $this->spl_file_info->getRealPath() + : $this->spl_file_info->getPath() . DIRECTORY_SEPARATOR . $this->spl_file_info->getFilename(); } public function getSubPathToDirBeginningAtPathEnd(string $dir_name): ilFileHandlerInterface @@ -84,7 +83,7 @@ public function getSubPathToDirBeginningAtPathEnd(string $dir_name): ilFileHandl } } $clone = clone $this; - $clone->xml_file_info = new SplFileInfo($trimmed_str); + $clone->spl_file_info = new SplFileInfo($trimmed_str); return $clone; } @@ -101,18 +100,18 @@ public function getSubPathToDirBeginningAtPathStart(string $dir_name): ilFileHan } } $clone = clone $this; - $clone->xml_file_info = new SplFileInfo($trimmed_str); + $clone->spl_file_info = new SplFileInfo($trimmed_str); return $clone; } public function getPathToFileLocation(): string { - return $this->xml_file_info->getPath(); + return $this->spl_file_info->getPath(); } public function fileExists(): bool { - return $this->xml_file_info->getRealPath() !== false; + return $this->spl_file_info->getRealPath() !== false; } public function getPathPart(string $pattern): string|null diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Namespace/class.ilCollection.php b/components/ILIAS/Export/classes/ImportHandler/File/Namespace/Collection.php similarity index 83% rename from components/ILIAS/Export/classes/ImportHandler/File/Namespace/class.ilCollection.php rename to components/ILIAS/Export/classes/ImportHandler/File/Namespace/Collection.php index 2221944a30c0..701febb7b975 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Namespace/class.ilCollection.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/Namespace/Collection.php @@ -20,10 +20,10 @@ namespace ILIAS\Export\ImportHandler\File\Namespace; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilCollectionInterface as ilParserNamespaceCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilHandlerInterface as ilParserNamespaceHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\Namespace\CollectionInterface as ilParserNamespaceCollectionInterface; +use ILIAS\Export\ImportHandler\I\File\Namespace\HandlerInterface as ilParserNamespaceHandlerInterface; -class ilCollection implements ilParserNamespaceCollectionInterface +class Collection implements ilParserNamespaceCollectionInterface { protected array $elements; protected int $index; @@ -75,7 +75,7 @@ public function key(): int public function valid(): bool { - return 0 <= $this->index && $this->index < $this->count(); + return isset($this->elements[$this->index]); } public function rewind(): void diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Namespace/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/Namespace/Factory.php similarity index 61% rename from components/ILIAS/Export/classes/ImportHandler/File/Namespace/class.ilFactory.php rename to components/ILIAS/Export/classes/ImportHandler/File/Namespace/Factory.php index c230b1eaa57a..cdbeffac042d 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Namespace/class.ilFactory.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/Namespace/Factory.php @@ -20,13 +20,13 @@ namespace ILIAS\Export\ImportHandler\File\Namespace; -use ILIAS\Export\ImportHandler\File\Namespace\ilCollection as ilParserNamespaceCollection; -use ILIAS\Export\ImportHandler\File\Namespace\ilHandler as ilParserNamespaceHandler; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilCollectionInterface as ilParserNamespaceCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilFactoryInterface as ilParserNamespaceFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilHandlerInterface as ilParserNamespaceHandlerInterface; +use ILIAS\Export\ImportHandler\File\Namespace\Collection as ilParserNamespaceCollection; +use ILIAS\Export\ImportHandler\File\Namespace\Handler as ilParserNamespaceHandler; +use ILIAS\Export\ImportHandler\I\File\Namespace\CollectionInterface as ilParserNamespaceCollectionInterface; +use ILIAS\Export\ImportHandler\I\File\Namespace\FactoryInterface as ilParserNamespaceFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\Namespace\HandlerInterface as ilParserNamespaceHandlerInterface; -class ilFactory implements ilParserNamespaceFactoryInterface +class Factory implements ilParserNamespaceFactoryInterface { public function handler(): ilParserNamespaceHandlerInterface { diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Namespace/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/File/Namespace/Handler.php similarity index 88% rename from components/ILIAS/Export/classes/ImportHandler/File/Namespace/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/File/Namespace/Handler.php index 10a856df18f8..2470a35134be 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Namespace/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/Namespace/Handler.php @@ -20,9 +20,9 @@ namespace ILIAS\Export\ImportHandler\File\Namespace; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilHandlerInterface as ilParserNamespaceHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\Namespace\HandlerInterface as ilParserNamespaceHandlerInterface; -class ilHandler implements ilParserNamespaceHandlerInterface +class Handler implements ilParserNamespaceHandlerInterface { protected string $prefix; protected string $namespace; diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/Comparison/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/Path/Comparison/class.ilFactory.php deleted file mode 100755 index 06a727b6be4c..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/Comparison/class.ilFactory.php +++ /dev/null @@ -1,36 +0,0 @@ -logger = $logger; - } - - public function anyElement(): ilAnyElementFilePathNodeInterface - { - return new ilAnyElementFilePathNode(); - } - - public function anyNode(): ilAnyNodeFilePathNodeInterface - { - return new ilAnyNodeFilePathNode(); - } - - public function attribute(): ilAttributeFilePathNodeInterface - { - return new ilAttributeFilePathNode(); - } - - public function index(): ilIndexFilePathNodeInterface - { - return new ilIndexFilePathNode(); - } - - public function simple(): ilSimpleFilePathNodeInterface - { - return new ilSimpleFilePathNode(); - } - - public function openRoundBracked(): ilOpenRoundBrackedFilePathNodeInterface - { - return new ilOpenRoundBrackedFilePathNode(); - } - - public function closeRoundBracked(): ilCloseRoundBrackedFilePathNodeInterface - { - return new ilCloseRoundBrackedFilePathNode(); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/Path/class.ilFactory.php deleted file mode 100755 index 6c9d6d692b85..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/class.ilFactory.php +++ /dev/null @@ -1,56 +0,0 @@ -logger = $logger; - } - - public function handler(): ilFilePathHandlerInterface - { - return new ilFilePathHandler(); - } - - public function node(): ilFilePathNodeFactoryInterface - { - return new ilFilePathNodeFactory($this->logger); - } - - public function comparison(ilFilePathComparisonOperator $operator, string $value): ilFilePathComparisonInterface - { - return new ilFilePathComparison($operator, $value); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Validation/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/Validation/class.ilFactory.php deleted file mode 100755 index 32814e465455..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/Validation/class.ilFactory.php +++ /dev/null @@ -1,57 +0,0 @@ -logger = $logger; - } - - public function handler(): ilFileValidationHandlerInterface - { - return new ilFileValidationHandler( - $this->logger, - new ilParserFactory($this->logger), - new ilImportStatusFactory(), - new ilFilePathFactory($this->logger) - ); - } - - public function set(): ilFileValidationSetFactoryInterface - { - return new ilFileValidationSetFactory(); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/class.ilCollection.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Collection.php similarity index 88% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/class.ilCollection.php rename to components/ILIAS/Export/classes/ImportHandler/File/XML/Collection.php index fe43b8bb77b3..4c149844befb 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/class.ilCollection.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Collection.php @@ -20,10 +20,10 @@ namespace ILIAS\Export\ImportHandler\File\XML; -use ILIAS\Export\ImportHandler\I\File\XML\ilCollectionInterface as ilXMLFileHandlerCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\ilHandlerInterface as ilXMLFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XML\CollectionInterface as ilXMLFileHandlerCollectionInterface; +use ILIAS\Export\ImportHandler\I\File\XML\HandlerInterface as ilXMLFileHandlerInterface; -class ilCollection implements ilXMLFileHandlerCollectionInterface +class Collection implements ilXMLFileHandlerCollectionInterface { /** * @var ilXMLFileHandlerInterface[]; diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/class.ilCollection.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Collection.php similarity index 87% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Export/class.ilCollection.php rename to components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Collection.php index 76ea4c2a5967..1ecfa07a9b8a 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/class.ilCollection.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Collection.php @@ -20,10 +20,10 @@ namespace ILIAS\Export\ImportHandler\File\XML\Export; -use ILIAS\Export\ImportHandler\I\File\XML\Export\ilCollectionInterface as ilXMLExportFileCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Export\ilHandlerInterface as ilXMLExportFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Export\CollectionInterface as ilXMLExportFileCollectionInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Export\HandlerInterface as ilXMLExportFileHandlerInterface; -class ilCollection implements ilXMLExportFileCollectionInterface +class Collection implements ilXMLExportFileCollectionInterface { /** * @var ilXMLExportFileHandlerInterface[] diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/Factory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/Factory.php new file mode 100755 index 000000000000..0d148818e994 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/Factory.php @@ -0,0 +1,61 @@ +logger = $logger; + $this->lng = $lng; + $this->import_handler = $import_handler; + } + + public function handler(): ilComponentXMLExportFileHandlerInterface + { + return new ilComponentXMLExportFileHandler( + $this->import_handler->file()->namespace(), + new ilImportStatusFactory(), + $this->import_handler->schema(), + $this->import_handler->parser(), + $this->import_handler->path(), + $this->logger, + $this->import_handler->parser()->nodeInfo()->attribute(), + $this->import_handler->validation()->set(), + $this->lng + ); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/Handler.php similarity index 79% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/Handler.php index e8787e29c138..7a26f7fce31c 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/Handler.php @@ -21,16 +21,16 @@ namespace ILIAS\Export\ImportHandler\File\XML\Export\Component; use ILIAS\Data\Version; -use ILIAS\Export\ImportHandler\File\XML\Export\ilHandler as ilXMLExportFileHandler; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilFactoryInterface as ilFileNamespaceHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Path\ilFactoryInterface as ilFilePathFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\Path\ilHandlerInterface as ilFilePathHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilCollectionInterface as ilFileValidationSetCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilFactoryInterface as ilFileValidationSetFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Export\Component\ilHandlerInterface as ilComponentXMLExportFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\Attribute\ilFactoryInterface as ilXMlFileInfoNodeAttributeFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Schema\ilFactoryInterface as ilXMLFileSchemaFactory; -use ILIAS\Export\ImportHandler\I\Parser\ilFactoryInterface as ilParserFactoryInterface; +use ILIAS\Export\ImportHandler\File\XML\Export\Handler as ilXMLExportFileHandler; +use ILIAS\Export\ImportHandler\I\File\Namespace\FactoryInterface as ilFileNamespaceHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Export\Component\HandlerInterface as ilComponentXMLExportFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\Parser\FactoryInterface as ilParserFactoryInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\Attribute\FactoryInterface as ilXMlFileInfoNodeAttributeFactoryInterface; +use ILIAS\Export\ImportHandler\I\Path\FactoryInterface as ilImportHandlerPathFactoryInterface; +use ILIAS\Export\ImportHandler\I\Path\HandlerInterface as ilImportHandlerPathInterface; +use ILIAS\Export\ImportHandler\I\Schema\FactoryInterface as ilImportHandlerSchemaFactory; +use ILIAS\Export\ImportHandler\I\Validation\Set\CollectionInterface as ilFileValidationSetCollectionInterface; +use ILIAS\Export\ImportHandler\I\Validation\Set\FactoryInterface as ilFileValidationSetFactoryInterface; use ILIAS\Export\ImportStatus\Exception\ilException as ilImportStatusException; use ILIAS\Export\ImportStatus\I\ilCollectionInterface as ilImportStatusCollectionInterface; use ILIAS\Export\ImportStatus\I\ilFactoryInterface as ilImportStatusFactoryInterface; @@ -39,16 +39,16 @@ use ilLogger; use SplFileInfo; -class ilHandler extends ilXMLExportFileHandler implements ilComponentXMLExportFileHandlerInterface +class Handler extends ilXMLExportFileHandler implements ilComponentXMLExportFileHandlerInterface { protected ilFileValidationSetCollectionInterface $sets; public function __construct( ilFileNamespaceHandlerInterface $namespace, ilImportStatusFactoryInterface $status, - ilXMLFileSchemaFactory $schema, + ilImportHandlerSchemaFactory $schema, ilParserFactoryInterface $parser, - ilFilePathFactoryInterface $path, + ilImportHandlerPathFactoryInterface $path, ilLogger $logger, ilXMlFileInfoNodeAttributeFactoryInterface $attribute, ilFileValidationSetFactoryInterface $set, @@ -58,10 +58,10 @@ public function __construct( $this->sets = $this->set->collection(); } - public function withFileInfo(SplFileInfo $file_info): ilHandler + public function withFileInfo(SplFileInfo $file_info): Handler { $clone = clone $this; - $clone->xml_file_info = $file_info; + $clone->spl_file_info = $file_info; return $clone; } @@ -78,7 +78,7 @@ public function buildValidationSets(): ilImportStatusCollectionInterface $path_to_export_node = $this->path->handler() ->withStartAtRoot(true) ->withNode($this->path->node()->simple()->withName('exp:Export')); - $export_schema_handler = $this->schema->handlersFromXMLFileHandlerAtPath($this, $path_to_export_node) + $export_schema_handler = $this->schema->collectionFrom($this, $path_to_export_node) ->current(); $major_version_str = $export_schema_handler->getVersion()->getMajor() . ".0.0"; $major_structure_schema_version = new Version($major_version_str); @@ -149,7 +149,7 @@ public function buildValidationSets(): ilImportStatusCollectionInterface return $statuses; } - public function getPathToComponentRootNodes(): ilFilePathHandlerInterface + public function getPathToComponentRootNodes(): ilImportHandlerPathInterface { return $this->path->handler()->withStartAtRoot(true) ->withNode($this->path->node()->simple()->withName('exp:Export')) diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/class.ilFactory.php deleted file mode 100755 index d57258252d87..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Component/class.ilFactory.php +++ /dev/null @@ -1,71 +0,0 @@ -logger = $logger; - $this->lng = $lng; - $this->schema_factory = $schema_factory; - } - - public function handler(): ilComponentXMLExportFileHandlerInterface - { - return new ilComponentXMLExportFileHandler( - new ilFileNamespaceFactory(), - new ilImportStatusFactory(), - new ilXMLFileSchemaFactory( - $this->logger, - $this->lng, - $this->schema_factory - ), - new ilParserFactory($this->logger), - new ilFilePathFactory($this->logger), - $this->logger, - new ilXMLNodeInfoAttributeFactory($this->logger), - new ilFileValidationSetFactory(), - $this->lng - ); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/Factory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/Factory.php new file mode 100755 index 000000000000..c10b5119aedf --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/Factory.php @@ -0,0 +1,61 @@ +logger = $logger; + $this->lng = $lng; + $this->import_handler = $import_handler; + } + + public function handler(): ilDatasetXMLExportFileHandlerInterface + { + return new ilDatasetXMLExportFileHandler( + $this->import_handler->file()->namespace(), + new ilImportStatusFactory(), + $this->import_handler->schema(), + $this->import_handler->parser(), + $this->import_handler->path(), + $this->logger, + $this->import_handler->parser()->nodeInfo()->attribute(), + $this->import_handler->validation()->set(), + $this->lng + ); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/class.ilFactory.php deleted file mode 100755 index fd3f311bd2ef..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/class.ilFactory.php +++ /dev/null @@ -1,71 +0,0 @@ -logger = $logger; - $this->lng = $lng; - $this->schema_factory = $schema_factory; - } - - public function handler(): ilDatasetXMLExportFileHandlerInterface - { - return new ilDatasetXMLExportFileHandler( - new ilFileNamespaceFactory(), - new ilImportStatusFactory(), - new ilXMLFileSchemaFactory( - $this->logger, - $this->lng, - $this->schema_factory - ), - new ilParserFactory($this->logger), - new ilFilePathFactory($this->logger), - $this->logger, - new ilXMLNodeInfoAttributeFactory($this->logger), - new ilFileValidationSetFactory(), - $this->lng - ); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/ilHandler.php similarity index 81% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/ilHandler.php index 7536684c5aa0..c6c140042d36 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/DataSet/ilHandler.php @@ -21,16 +21,16 @@ namespace ILIAS\Export\ImportHandler\File\XML\Export\DataSet; use ILIAS\Data\Version; -use ILIAS\Export\ImportHandler\File\XML\Export\ilHandler as ilXMLExportFileHandler; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilFactoryInterface as ilFileNamespaceFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\Path\ilFactoryInterface as ilFilePathFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\Path\ilHandlerInterface as ilFilePathHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilCollectionInterface as ilFileValidationSetCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilFactoryInterface as ilFileValidationSetFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Export\DataSet\ilHandlerInterface as ilDataSetXMLExportFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\Attribute\ilFactoryInterface as ilXMlFileInfoNodeAttributeFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Schema\ilFactoryInterface as ilXMLFileSchemaFactory; -use ILIAS\Export\ImportHandler\I\Parser\ilFactoryInterface as ilParserFactoryInterface; +use ILIAS\Export\ImportHandler\File\XML\Export\Handler as ilXMLExportFileHandler; +use ILIAS\Export\ImportHandler\I\File\Namespace\FactoryInterface as ilFileNamespaceFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Export\DataSet\HandlerInterface as ilDataSetXMLExportFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\Parser\FactoryInterface as ilParserFactoryInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\Attribute\FactoryInterface as ilXMlFileInfoNodeAttributeFactoryInterface; +use ILIAS\Export\ImportHandler\I\Path\FactoryInterface as ilImportHandlerPathFactoryInterface; +use ILIAS\Export\ImportHandler\I\Path\HandlerInterface as ilImportHandlerPathInterface; +use ILIAS\Export\ImportHandler\I\Schema\FactoryInterface as ilImportHandlerSchemaFactory; +use ILIAS\Export\ImportHandler\I\Validation\Set\CollectionInterface as ilFileValidationSetCollectionInterface; +use ILIAS\Export\ImportHandler\I\Validation\Set\FactoryInterface as ilFileValidationSetFactoryInterface; use ILIAS\Export\ImportStatus\Exception\ilException as ilImportStatusException; use ILIAS\Export\ImportStatus\I\ilCollectionInterface as ilImportStatusCollectionInterface; use ILIAS\Export\ImportStatus\I\ilFactoryInterface as ilImportStatusFactoryInterface; @@ -39,16 +39,16 @@ use ilLogger; use SplFileInfo; -class ilHandler extends ilXMLExportFileHandler implements ilDataSetXMLExportFileHandlerInterface +class Handler extends ilXMLExportFileHandler implements ilDataSetXMLExportFileHandlerInterface { protected ilFileValidationSetCollectionInterface $sets; public function __construct( ilFileNamespaceFactoryInterface $namespace, ilImportStatusFactoryInterface $status, - ilXMLFileSchemaFactory $schema, + ilImportHandlerSchemaFactory $schema, ilParserFactoryInterface $parser, - ilFilePathFactoryInterface $path, + ilImportHandlerPathFactoryInterface $path, ilLogger $logger, ilXMlFileInfoNodeAttributeFactoryInterface $attribute, ilFileValidationSetFactoryInterface $set, @@ -58,10 +58,10 @@ public function __construct( $this->sets = $this->set->collection(); } - public function withFileInfo(SplFileInfo $file_info): ilHandler + public function withFileInfo(SplFileInfo $file_info): Handler { $clone = clone $this; - $clone->xml_file_info = $file_info; + $clone->spl_file_info = $file_info; return $clone; } @@ -84,7 +84,7 @@ public function buildValidationSets(): ilImportStatusCollectionInterface ->withNode($this->path->node()->simple()->withName('exp:ExportItem')) ->withNode($this->path->node()->simple()->withName('ds:DataSet')) ->withNode($this->path->node()->simple()->withName('ds:Rec')); - $export_schema_handler = $this->schema->handlersFromXMLFileHandlerAtPath($this, $path_to_export_node) + $export_schema_handler = $this->schema->collectionFrom($this, $path_to_export_node) ->current(); $major_version_str = $export_schema_handler->getVersion()->getMajor() . ".0.0"; $major_structure_schema_version = new Version($major_version_str); @@ -119,7 +119,7 @@ public function buildValidationSets(): ilImportStatusCollectionInterface ))); } // Content validation set - $content_schemas = $this->schema->handlersFromXMLFileHandlerAtPath($this, $path_to_dataset_child_nodes); + $content_schemas = $this->schema->collectionFrom($this, $path_to_dataset_child_nodes); for ($i = 0; $i < $content_schemas->count(); $i++) { $content_schema = $content_schemas->toArray()[$i]; $content_schema = $content_schema->withVersion($export_schema_handler->getVersion()); @@ -166,7 +166,7 @@ public function buildValidationSets(): ilImportStatusCollectionInterface return $statuses; } - public function getPathToComponentRootNodes(): ilFilePathHandlerInterface + public function getPathToComponentRootNodes(): ilImportHandlerPathInterface { return $this->path->handler() ->withStartAtRoot(true) diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Factory.php similarity index 57% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Export/class.ilFactory.php rename to components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Factory.php index 7cd91dee2216..66fd42dfef8d 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/class.ilFactory.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Factory.php @@ -20,33 +20,33 @@ namespace ILIAS\Export\ImportHandler\File\XML\Export; -use ILIAS\Export\ImportHandler\File\XML\Export\Component\ilFactory as ilComponentXMLExportFileFactory; -use ILIAS\Export\ImportHandler\File\XML\Export\DataSet\ilFactory as ilDataSetXMLExportFileFactory; -use ILIAS\Export\ImportHandler\File\XML\Export\ilCollection as ilXMLExportFileHandlerCollection; -use ILIAS\Export\ImportHandler\I\File\XML\Export\Component\ilFactoryInterface as ilComponentXMLExportFileHandlerFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Export\DataSet\ilFactoryInterface as ilDataSetXMLExportFileHandlerFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Export\ilCollectionInterface as ilXMLExportFileCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Export\ilFactoryInterface as ilXMLExportFileFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Export\ilHandlerInterface as ilXMLExportFileHandlerInterface; -use ILIAS\Export\Schema\ilXmlSchemaFactory; +use ILIAS\Export\ImportHandler\File\XML\Export\Collection as ilXMLExportFileHandlerCollection; +use ILIAS\Export\ImportHandler\File\XML\Export\Component\Factory as ilComponentXMLExportFileFactory; +use ILIAS\Export\ImportHandler\File\XML\Export\DataSet\Factory as ilDataSetXMLExportFileFactory; +use ILIAS\Export\ImportHandler\I\FactoryInterface as ilImportHandlerFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Export\CollectionInterface as ilXMLExportFileCollectionInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Export\Component\FactoryInterface as ilComponentXMLExportFileHandlerFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Export\DataSet\FactoryInterface as ilDataSetXMLExportFileHandlerFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Export\FactoryInterface as ilXMLExportFileFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Export\HandlerInterface as ilXMLExportFileHandlerInterface; use ilLanguage; use ilLogger; use SplFileInfo; -class ilFactory implements ilXMLExportFileFactoryInterface +class Factory implements ilXMLExportFileFactoryInterface { + protected ilImportHandlerFactoryInterface $import_handler; protected ilLogger $logger; protected ilLanguage $lng; - protected ilXmlSchemaFactory $schema_factory; public function __construct( + ilImportHandlerFactoryInterface $import_handler, ilLogger $logger, - ilLanguage $lng, - ilXmlSchemaFactory $schema_factory + ilLanguage $lng ) { $this->logger = $logger; $this->lng = $lng; - $this->schema_factory = $schema_factory; + $this->import_handler = $import_handler; } public function withFileInfo(SplFileInfo $file_info): ilXMLExportFileHandlerInterface @@ -67,18 +67,18 @@ public function collection(): ilXMLExportFileCollectionInterface public function component(): ilComponentXMLExportFileHandlerFactoryInterface { return new ilComponentXMLExportFileFactory( + $this->import_handler, $this->logger, - $this->lng, - $this->schema_factory + $this->lng ); } public function dataSet(): ilDataSetXMLExportFileHandlerFactoryInterface { return new ilDataSetXMLExportFileFactory( + $this->import_handler, $this->logger, - $this->lng, - $this->schema_factory + $this->lng ); } } diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Handler.php similarity index 66% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Export/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Handler.php index 8cb26d227daf..27c4e31e05c5 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Export/Handler.php @@ -21,18 +21,18 @@ namespace ILIAS\Export\ImportHandler\File\XML\Export; use ilDataSet; -use ILIAS\Export\ImportHandler\File\Validation\ilHandler as ilFileValidationHandler; -use ILIAS\Export\ImportHandler\File\XML\ilHandler as ilXMLFileHandler; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilFactoryInterface as ilFileNamespaceHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Path\ilFactoryInterface as ilFilePathFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilFactoryInterface as ilFileValidationSetFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Export\ilHandlerInterface as ilXMLExportFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\ilHandlerInterface as ilXMLFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\Attribute\ilFactoryInterface as ilXMlFileInfoNodeAttributeFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilTreeInterface as ilXMLFileNodeInfoTreeInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Schema\ilFactoryInterface as ilXMLFileSchemaFactory; -use ILIAS\Export\ImportHandler\I\File\XSD\ilHandlerInterface as ilXSDFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\Parser\ilFactoryInterface as ilParserFactoryInterface; +use ILIAS\Export\ImportHandler\File\XML\Handler as ilXMLFileHandler; +use ILIAS\Export\ImportHandler\I\File\Namespace\FactoryInterface as ilFileNamespaceHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Export\HandlerInterface as ilXMLExportFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XML\HandlerInterface as ilXMLFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XSD\HandlerInterface as ilXSDFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\Parser\FactoryInterface as ilParserFactoryInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\Attribute\FactoryInterface as ilXMlFileInfoNodeAttributeFactoryInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\Tree\HandlerInterface as ilImportHandlerParserNodeInfoTreeInterface; +use ILIAS\Export\ImportHandler\I\Path\FactoryInterface as ilImportHandlerPathFactoryInterface; +use ILIAS\Export\ImportHandler\I\Schema\FactoryInterface as ilImportHandlerSchemaFactory; +use ILIAS\Export\ImportHandler\I\Validation\Set\FactoryInterface as ilFileValidationSetFactoryInterface; +use ILIAS\Export\ImportHandler\Validation\Handler as ilFileValidationHandler; use ILIAS\Export\ImportStatus\Exception\ilException as ilImportStatusException; use ILIAS\Export\ImportStatus\I\ilFactoryInterface as ilImportStatusFactoryInterface; use ILIAS\Export\ImportStatus\I\ilHandlerInterface as ilImportStatusHandlerInterface; @@ -41,11 +41,11 @@ use ilLogger; use SplFileInfo; -abstract class ilHandler extends ilXMLFileHandler implements ilXMLExportFileHandlerInterface +abstract class Handler extends ilXMLFileHandler implements ilXMLExportFileHandlerInterface { - protected ilXMLFileSchemaFactory $schema; + protected ilImportHandlerSchemaFactory $schema; protected ilParserFactoryInterface $parser; - protected ilFilePathFactoryInterface $path; + protected ilImportHandlerPathFactoryInterface $path; protected ilXMlFileInfoNodeAttributeFactoryInterface $attribute; protected ilFileValidationSetFactoryInterface $set; protected ilLogger $logger; @@ -54,9 +54,9 @@ abstract class ilHandler extends ilXMLFileHandler implements ilXMLExportFileHand public function __construct( ilFileNamespaceHandlerInterface $namespace, ilImportStatusFactoryInterface $status, - ilXMLFileSchemaFactory $schema, + ilImportHandlerSchemaFactory $schema, ilParserFactoryInterface $parser, - ilFilePathFactoryInterface $path, + ilImportHandlerPathFactoryInterface $path, ilLogger $logger, ilXMlFileInfoNodeAttributeFactoryInterface $attribute, ilFileValidationSetFactoryInterface $set, @@ -75,14 +75,14 @@ public function __construct( /** * @throws ilImportStatusException */ - public function withFileInfo(SplFileInfo $file_info): ilHandler + public function withFileInfo(SplFileInfo $file_info): Handler { $clone = clone $this; - $clone->xml_file_info = $file_info; + $clone->spl_file_info = $file_info; return $clone; } - public function getILIASPath(ilXMLFileNodeInfoTreeInterface $component_tree): string + public function getILIASPath(ilImportHandlerParserNodeInfoTreeInterface $component_tree): string { $matches = []; $pattern = '/([0-9]+)__([0-9]+)__([a-z_]+)_([0-9]+)/'; @@ -95,8 +95,8 @@ public function getILIASPath(ilXMLFileNodeInfoTreeInterface $component_tree): st }; $node = $component_tree->getFirstNodeWith( $this->attribute->collection() - ->withElement($this->attribute->pair()->withValue($matches[4])->withKey('Id')) - ->withElement($this->attribute->pair()->withValue($matches[3])->withKey('Type')) + ->withElement($this->attribute->handler()->withValue($matches[4])->withKey('Id')) + ->withElement($this->attribute->handler()->withValue($matches[3])->withKey('Type')) ); return is_null($node) ? '' @@ -116,7 +116,9 @@ public function hasComponentRootNode(): bool ->withPrefix(ilDataSet::DATASET_NS_PREFIX) ); try { - $nodes = $this->parser->DOM()->withFileHandler($xml)->getNodeInfoAt($this->getPathToComponentRootNodes()); + $nodes = $this->parser->DOM()->handler() + ->withFileHandler($xml) + ->getNodeInfoAt($this->getPathToComponentRootNodes()); } catch (ilImportStatusException $e) { return false; } diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Factory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Factory.php new file mode 100755 index 000000000000..ee0c4fbd36d9 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Factory.php @@ -0,0 +1,100 @@ +import_handler = $import_handler; + $this->logger = $logger; + $this->lng = $lng; + $this->data_factory = $data_factory; + } + + public function handler(): ilImportHandlerXMLFileInterface + { + return new ilImportHandlerXMLFile( + $this->import_handler->file()->namespace(), + $this->import_status_factory + ); + } + + public function collection(): ilImportHandlerXMLFileCollectionInterface + { + return new ilImportHandlerXMLFileCollection(); + } + + public function manifest(): ilImportHandlerManifestFileFactoryInterface + { + return new ilImportHandlerManifestFileFactory( + $this->import_handler, + $this->logger, + $this->import_status_factory + ); + } + + public function export(): ilImportHandlerXMLExportFileFactoryInterface + { + return new ilImportHandlerXMLExportFileFactory( + $this->import_handler, + $this->logger, + $this->lng + ); + } + + public function schema(): ilImportHandlerSchemaFactoryInterface + { + return new ilImportHandlerSchemaFactory( + $this->import_handler, + $this->data_factory, + $this->logger + ); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Handler.php similarity index 65% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/File/XML/Handler.php index 85a7f8bbfa27..a2b898bb7de3 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Handler.php @@ -21,36 +21,38 @@ namespace ILIAS\Export\ImportHandler\File\XML; use DOMDocument; -use ILIAS\Export\ImportHandler\File\ilHandler as ilFileHandler; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilFactoryInterface as ilFileNamespaceFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilHandlerInterface as ilFileNamespaceHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\ilHandlerInterface as ilXMLFileHandlerInterface; +use ILIAS\Export\ImportHandler\File\Handler as ilImportHandlerFile; +use ILIAS\Export\ImportHandler\I\File\Namespace\FactoryInterface as ilImportHandlerFileNamespaceFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\Namespace\HandlerInterface as ilImportHandlerFileNamespaceInterface; +use ILIAS\Export\ImportHandler\I\File\XML\HandlerInterface as ilImportHandlerXMLFileInterface; use ILIAS\Export\ImportStatus\Exception\ilException as ilImportStatusException; use ILIAS\Export\ImportStatus\I\ilFactoryInterface as ilImportStatusFactoryInterface; -use ILIAS\Export\ImportStatus\StatusType; +use ILIAS\Export\ImportStatus\StatusType as ilImportHandlerStatusType; use SplFileInfo; -class ilHandler extends ilFileHandler implements ilXMLFileHandlerInterface +class Handler extends ilImportHandlerFile implements ilImportHandlerXMLFileInterface { protected ilImportStatusFactoryInterface $status; public function __construct( - ilFileNamespaceFactoryInterface $namespace, + ilImportHandlerFileNamespaceFactoryInterface $namespace_factory, ilImportStatusFactoryInterface $status ) { - parent::__construct($namespace); + parent::__construct($namespace_factory); $this->status = $status; } - public function withFileInfo(SplFileInfo $file_info): ilHandler - { + public function withFileInfo( + SplFileInfo $file_info + ): ilImportHandlerXMLFileInterface { $clone = clone $this; - $clone->xml_file_info = $file_info; + $clone->spl_file_info = $file_info; return $clone; } - public function withAdditionalNamespace(ilFileNamespaceHandlerInterface $namespace_handler): ilHandler - { + public function withAdditionalNamespace( + ilImportHandlerFileNamespaceInterface $namespace_handler + ): ilImportHandlerXMLFileInterface { $clone = clone $this; $clone->namespaces = $clone->namespaces->withElement($namespace_handler); return $clone; @@ -69,7 +71,7 @@ public function loadDomDocument(): DOMDocument libxml_clear_errors(); foreach ($errors as $error) { $status_collection = $status_collection->withAddedStatus( - $this->status->handler()->withType(StatusType::FAILED)->withContent( + $this->status->handler()->withType(ilImportHandlerStatusType::FAILED)->withContent( $this->status->content()->builder()->string()->withString( "Error loading dom document:" . "
XML: " . $this->getSubPathToDirBeginningAtPathEnd('temp')->getFilePath() . @@ -78,8 +80,8 @@ public function loadDomDocument(): DOMDocument ) ); } - if ($status_collection->hasStatusType(StatusType::FAILED)) { - $exception = $this->status->exception($status_collection->toString(StatusType::FAILED)); + if ($status_collection->hasStatusType(ilImportHandlerStatusType::FAILED)) { + $exception = $this->status->exception($status_collection->toString(ilImportHandlerStatusType::FAILED)); $exception->setStatuses($status_collection); throw $exception; } diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilHandlerCollection.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Collection.php similarity index 72% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilHandlerCollection.php rename to components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Collection.php index 0cb7616fae01..26c82d4e9bd3 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilHandlerCollection.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Collection.php @@ -20,30 +20,26 @@ namespace ILIAS\Export\ImportHandler\File\XML\Manifest; -use ILIAS\Export\ImportHandler\I\File\XML\Manifest\ilHandlerCollectionInterface as ilManifestXMLFileHandlerCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Manifest\ilHandlerInterface as ilManifestXMLFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Manifest\HandlerCollectionInterface as ilImportHandlerManifestXMLFileCollectionInterface; +use ILIAS\Export\ImportHandler\I\File\XML\Manifest\HandlerInterface as ilImportHandlerManifestXMLFileInterface; use ILIAS\Export\ImportStatus\Exception\ilException as ilImportStatusException; use ILIAS\Export\ImportStatus\I\ilCollectionInterface as ilImportStatusHandlerCollectionInterface; use ILIAS\Export\ImportStatus\I\ilFactoryInterface as ilImportStatusFactoryInterface; -class ilHandlerCollection implements ilManifestXMLFileHandlerCollectionInterface +class Collection implements ilImportHandlerManifestXMLFileCollectionInterface { /** - * @var ilManifestXMLFileHandlerInterface[]; + * @var ilImportHandlerManifestXMLFileInterface[]; */ protected array $elements; protected ilImportStatusFactoryInterface $import_status; protected int $index; - /** - * @param ilManifestXMLFileHandlerInterface[] $initial_elements - */ public function __construct( ilImportStatusFactoryInterface $import_status, - array $initial_elements = [] ) { $this->import_status = $import_status; - $this->elements = $initial_elements; + $this->elements = []; $this->index = 0; } @@ -52,7 +48,7 @@ public function count(): int return count($this->elements); } - public function current(): ilManifestXMLFileHandlerInterface + public function current(): ilImportHandlerManifestXMLFileInterface { return $this->elements[$this->index]; } @@ -69,7 +65,7 @@ public function key(): int public function valid(): bool { - return 0 <= $this->index && $this->index < $this->count(); + return isset($this->elements[$this->index]); } public function rewind(): void @@ -78,22 +74,24 @@ public function rewind(): void } public function withMerged( - ilManifestXMLFileHandlerCollectionInterface $other - ): ilManifestXMLFileHandlerCollectionInterface { + ilImportHandlerManifestXMLFileCollectionInterface $other + ): ilImportHandlerManifestXMLFileCollectionInterface { $clone = clone $this; $clone->elements = array_merge($clone->toArray(), $other->toArray()); return $clone; } - public function withElement(ilManifestXMLFileHandlerInterface $element): ilManifestXMLFileHandlerCollectionInterface - { + public function withElement( + ilImportHandlerManifestXMLFileInterface $element + ): ilImportHandlerManifestXMLFileCollectionInterface { $clone = clone $this; $clone->elements[] = $element; return $clone; } - public function containsExportObjectType(ilExportObjectType $type): bool - { + public function containsExportObjectType( + ExportObjectType $type + ): bool { foreach ($this->toArray() as $manifest_file_handler) { if ($manifest_file_handler->getExportObjectType() === $type) { return true; @@ -116,7 +114,7 @@ public function validateElements(): ilImportStatusHandlerCollectionInterface /** * @throws ilImportStatusException */ - public function findNextFiles(): ilManifestXMLFileHandlerCollectionInterface + public function findNextFiles(): ilImportHandlerManifestXMLFileCollectionInterface { $collection = clone $this; $collection->rewind(); @@ -128,7 +126,7 @@ public function findNextFiles(): ilManifestXMLFileHandlerCollectionInterface } /** - * @return ilManifestXMLFileHandlerInterface[] + * @return ilImportHandlerManifestXMLFileInterface[] */ public function toArray(): array { diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/enum.ilExportObjectType.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/ExportObjectType.php similarity index 70% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/enum.ilExportObjectType.php rename to components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/ExportObjectType.php index 88c32f082240..815f7bc2a274 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/enum.ilExportObjectType.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/ExportObjectType.php @@ -20,20 +20,20 @@ namespace ILIAS\Export\ImportHandler\File\XML\Manifest; -enum ilExportObjectType +enum ExportObjectType { case MIXED; case EXPORT_SET; case EXPORT_FILE; case NONE; - public static function toString(ilExportObjectType $type): string + public static function toString(ExportObjectType $type): string { return match ($type) { - ilExportObjectType::MIXED => 'Mixed', - ilExportObjectType::EXPORT_FILE => 'ExportFile', - ilExportObjectType::EXPORT_SET => 'ExportSet', - ilExportObjectType::NONE => '' + ExportObjectType::MIXED => 'Mixed', + ExportObjectType::EXPORT_FILE => 'ExportFile', + ExportObjectType::EXPORT_SET => 'ExportSet', + ExportObjectType::NONE => '' }; } } diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Factory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Factory.php new file mode 100755 index 000000000000..2a8e725b28e1 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Factory.php @@ -0,0 +1,68 @@ +import_handler = $import_handler; + $this->logger = $logger; + $this->import_status_factory = $import_status_factory; + } + + public function handler(): ilImportHandlerManifestXMLFileInterface + { + return new ilImportHandlerManifestXMLFile( + $this->import_handler->file()->namespace(), + $this->import_status_factory, + $this->import_handler->validation()->handler(), + $this->import_handler->parser(), + $this->import_handler->path(), + $this->import_handler->file()->xml(), + $this->import_handler->file()->xsd(), + $this->import_handler->schema()->folder()->handler() + ); + } + + public function collection(): ilImportHandlerManifestXMLFileCollectionInterface + { + return new ilImportHandlerManifestXMLFileCollection( + $this->import_status_factory + ); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Handler.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Handler.php new file mode 100755 index 000000000000..45243a829979 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/Handler.php @@ -0,0 +1,178 @@ +manifest_xsd_handler = $xsd_file_factory->withFileInfo($schema_folder->getLatest( + self::XSD_TYPE, + self::XSD_SUB_TYPE + )); + $this->file_path_factory = $file_path_factory; + $this->xml_file_factory = $xml_file_factory; + $this->parser_factory = $parser_factory; + $this->validation = $validation; + } + + /** + * @throws ilImportStatusException + */ + public function withFileInfo(SplFileInfo $file_info): Handler + { + $clone = clone $this; + $clone->spl_file_info = $file_info; + $clone->parser_handler = $clone->parser_factory->DOM()->handler() + ->withFileHandler($clone); + return $clone; + } + + /** + * @throws ilImportStatusException + */ + public function getExportObjectType(): ExportObjectType + { + $exp_file_file_path = $this->file_path_factory->handler() + ->withNode($this->file_path_factory->node()->simple()->withName(self::MANIFEST_NODE_NAME)) + ->withNode($this->file_path_factory->node()->simple()->withName(self::EXPORT_FILE_NODE_NAME)); + $exp_set_file_path = $this->file_path_factory->handler() + ->withNode($this->file_path_factory->node()->simple()->withName(self::MANIFEST_NODE_NAME)) + ->withNode($this->file_path_factory->node()->simple()->withName(self::EXPORT_SET_NODE_NAME)); + $export_file_node_info = $this->parser_handler->getNodeInfoAt($exp_file_file_path); + $export_set_node_info = $this->parser_handler->getNodeInfoAt($exp_set_file_path); + if ( + $export_file_node_info->count() > 0 && + $export_set_node_info->count() > 0 + ) { + return ExportObjectType::MIXED; + } + if ($export_file_node_info->count() > 0) { + return ExportObjectType::EXPORT_FILE; + } + if ($export_set_node_info->count() > 0) { + return ExportObjectType::EXPORT_SET; + } + return ExportObjectType::NONE; + } + + public function validateManifestXML(): ilImportStatusHandlerCollectionInterface + { + return $this->validation->validateXMLFile($this, $this->manifest_xsd_handler); + } + + /** + * @throws ilImportStatusException + */ + public function findXMLFileHandlers(): ilImportHandlerXMLExportFileCollectionInterface + { + $type_name = ExportObjectType::toString($this->getExportObjectType()); + $path = $this->file_path_factory->handler() + ->withStartAtRoot(true) + ->withNode($this->file_path_factory->node()->simple()->withName(self::MANIFEST_NODE_NAME)) + ->withNode($this->file_path_factory->node()->simple()->withName($type_name)); + $file_handlers = $this->xml_file_factory->export()->collection(); + foreach ($this->parser_handler->getNodeInfoAt($path) as $node_info) { + $file_name = $node_info->getNodeName() === ExportObjectType::toString(ExportObjectType::EXPORT_SET) + ? DIRECTORY_SEPARATOR . self::MANIFEST_FILE_NAME + : ''; + $file_handlers = $file_handlers->withElement($this->xml_file_factory->export() + ->withFileInfo(new SplFileInfo( + $this->getPathToFileLocation() + . DIRECTORY_SEPARATOR + . $node_info->getValueOfAttribute(self::FILE_PATH_ATTRIBUTE_NAME) + . $file_name + ))); + } + return $file_handlers; + } + + /** + * @throws ilImportStatusException + */ + public function findManifestXMLFileHandlers(): ilImportHandlerManifestXMLFileCollectionInterface + { + $export_obj_type = $this->getExportObjectType(); + $type_name = ExportObjectType::toString($export_obj_type); + $path = $this->file_path_factory->handler() + ->withStartAtRoot(true) + ->withNode($this->file_path_factory->node()->simple()->withName(self::MANIFEST_NODE_NAME)) + ->withNode($this->file_path_factory->node()->simple()->withName($type_name)); + $xml_file_infos = $this->xml_file_factory->manifest()->collection(); + foreach ($this->parser_handler->getNodeInfoAt($path) as $node_info) { + $file_name = $node_info->getNodeName() === ExportObjectType::toString(ExportObjectType::EXPORT_SET) + ? DIRECTORY_SEPARATOR . self::MANIFEST_FILE_NAME + : ''; + $xml_file_infos = $xml_file_infos->withElement($this->xml_file_factory->manifest()->handler() + ->withFileInfo(new SplFileInfo( + $this->getPathToFileLocation() + . DIRECTORY_SEPARATOR + . $node_info->getValueOfAttribute(self::FILE_PATH_ATTRIBUTE_NAME) + . $file_name + ))); + } + return $xml_file_infos; + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilFactory.php deleted file mode 100755 index ebdd016c684f..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilFactory.php +++ /dev/null @@ -1,83 +0,0 @@ -logger = $logger; - $this->lng = $lng; - $this->schema_factory = $schema_factory; - } - - public function handler(): ilManifestXMLFileHandlerInterface - { - return new ilManifestXMLFileHandler( - new ilFileNamespaceFactory(), - $this->schema_factory, - new ilImportStatusFactory(), - new ilFileFactory($this->logger, $this->lng, $this->schema_factory), - new ilParserFactory($this->logger), - $this->logger, - ); - } - - public function withFileInfo(SplFileInfo $file_info): ilManifestXMLFileHandlerInterface - { - return (new ilManifestXMLFileHandler( - new ilFileNamespaceFactory(), - $this->schema_factory, - new ilImportStatusFactory(), - new ilFileFactory($this->logger, $this->lng, $this->schema_factory), - new ilParserFactory($this->logger), - $this->logger, - ))->withFileInfo($file_info); - } - - public function handlerCollection(): ilManifestXMLFileHandlerCollectionInterface - { - return new ilManifestXMLFileHandlerCollection( - new ilImportStatusFactory() - ); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilHandler.php deleted file mode 100755 index aed38ce5aa2a..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Manifest/class.ilHandler.php +++ /dev/null @@ -1,175 +0,0 @@ -status = $status; - $this->manifest_xsd_handler = $file->xsd()->withFileInfo($schema->getLatest( - self::XSD_TYPE, - self::XSD_SUB_TYPE - )); - $this->logger = $logger; - $this->parser = $parser; - $this->file = $file; - $this->schema = $schema; - } - - /** - * @throws ilImportStatusException - */ - public function withFileInfo(SplFileInfo $file_info): ilHandler - { - $clone = clone $this; - $clone->xml_file_info = $file_info; - $clone->parser_handler = $clone->parser->DOM()->withFileHandler($clone); - return $clone; - } - - /** - * @throws ilImportStatusException - */ - public function getExportObjectType(): ilExportObjectType - { - $exp_file_file_path = $this->file->path()->handler() - ->withNode($this->file->path()->node()->simple()->withName(self::MANIFEST_NODE_NAME)) - ->withNode($this->file->path()->node()->simple()->withName(self::EXPORT_FILE_NODE_NAME)); - $exp_set_file_path = $this->file->path()->handler() - ->withNode($this->file->path()->node()->simple()->withName(self::MANIFEST_NODE_NAME)) - ->withNode($this->file->path()->node()->simple()->withName(self::EXPORT_SET_NODE_NAME)); - $export_file_node_info = $this->parser_handler->getNodeInfoAt($exp_file_file_path); - $export_set_node_info = $this->parser_handler->getNodeInfoAt($exp_set_file_path); - if ( - $export_file_node_info->count() > 0 && - $export_set_node_info->count() > 0 - ) { - return ilExportObjectType::MIXED; - } - if ($export_file_node_info->count() > 0) { - return ilExportObjectType::EXPORT_FILE; - } - if ($export_set_node_info->count() > 0) { - return ilExportObjectType::EXPORT_SET; - } - return ilExportObjectType::NONE; - } - - public function validateManifestXML(): ilImportStatusHandlerCollectionInterface - { - return $this->file->validation()->handler()->validateXMLFile($this, $this->manifest_xsd_handler); - } - - /** - * @throws ilImportStatusException - */ - public function findXMLFileHandlers(): ilXMLExportFileCollectionInterface - { - $type_name = ilExportObjectType::toString($this->getExportObjectType()); - $path = $this->file->path()->handler() - ->withStartAtRoot(true) - ->withNode($this->file->path()->node()->simple()->withName(self::MANIFEST_NODE_NAME)) - ->withNode($this->file->path()->node()->simple()->withName($type_name)); - $file_handlers = $this->file->xml()->export()->collection(); - foreach ($this->parser_handler->getNodeInfoAt($path) as $node_info) { - $file_name = $node_info->getNodeName() === ilExportObjectType::toString(ilExportObjectType::EXPORT_SET) - ? DIRECTORY_SEPARATOR . self::MANIFEST_FILE_NAME - : ''; - $file_handlers = $file_handlers->withElement($this->file->xml()->export() - ->withFileInfo(new SplFileInfo( - $this->getPathToFileLocation() - . DIRECTORY_SEPARATOR - . $node_info->getValueOfAttribute(self::FILE_PATH_ATTRIBUTE_NAME) - . $file_name - ))); - } - return $file_handlers; - } - - /** - * @throws ilImportStatusException - */ - public function findManifestXMLFileHandlers(): ilManifestXMLFileHandlerCollectionInterface - { - $export_obj_type = $this->getExportObjectType(); - $type_name = ilExportObjectType::toString($export_obj_type); - $path = $this->file->path()->handler() - ->withStartAtRoot(true) - ->withNode($this->file->path()->node()->simple()->withName(self::MANIFEST_NODE_NAME)) - ->withNode($this->file->path()->node()->simple()->withName($type_name)); - $xml_file_infos = $this->file->xml()->manifest()->handlerCollection(); - foreach ($this->parser_handler->getNodeInfoAt($path) as $node_info) { - $file_name = $node_info->getNodeName() === ilExportObjectType::toString(ilExportObjectType::EXPORT_SET) - ? DIRECTORY_SEPARATOR . self::MANIFEST_FILE_NAME - : ''; - $xml_file_infos = $xml_file_infos->withElement($this->file->xml()->manifest()->handler() - ->withFileInfo(new SplFileInfo( - $this->getPathToFileLocation() - . DIRECTORY_SEPARATOR - . $node_info->getValueOfAttribute(self::FILE_PATH_ATTRIBUTE_NAME) - . $file_name - ))); - } - return $xml_file_infos; - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/Attribute/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/Attribute/class.ilFactory.php deleted file mode 100755 index d335c5f83c50..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/Attribute/class.ilFactory.php +++ /dev/null @@ -1,48 +0,0 @@ -logger = $logger; - } - - public function pair(): ilXMLFileNodeInfoAttributePairInterface - { - return new ilXMLFileNodeInfoAttributePair(); - } - - public function collection(): ilXMLFileNodeInfoAttributeCollectionInterface - { - return new ilXMLFileNodeInfoAttribureCollection($this->logger); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/DOM/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/DOM/class.ilFactory.php deleted file mode 100755 index cfa242e48ba9..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/DOM/class.ilFactory.php +++ /dev/null @@ -1,45 +0,0 @@ -info = $info; - } - - public function withDOMNode(DOMNode $node): ilXMLFileNodeInfoDOMNodeHandlerInterface - { - return (new ilXMLFileDOMNodeInfoHandler( - $this->info - ))->withDOMNode($node); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/class.ilFactory.php deleted file mode 100755 index 483559e52f77..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/class.ilFactory.php +++ /dev/null @@ -1,68 +0,0 @@ -logger = $logger; - } - - public function collection(): ilXMLFileNodeInfoCollectionInterface - { - return new ilFileNodeInfoCollection(); - } - - public function tree(): ilXMLFileNodeInfoTreeInterface - { - return new ilXMLFileNodeInfoTree( - new ilFactory($this->logger), - new ilParserFactory($this->logger), - $this->logger - ); - } - - public function attribute(): ilXMLFileNodeInfoAttributeFactoryInterface - { - return new ilXMLFileNodeInfoAttributeFactory($this->logger); - } - - public function DOM(): ilXMLFileDOMNodeInfoFactoryInterface - { - return new ilXMLFileDOMNodeInfoFactory($this); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/class.ilFactory.php deleted file mode 100755 index a7beb065c112..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/class.ilFactory.php +++ /dev/null @@ -1,42 +0,0 @@ -logger = $logger; - } - - public function info(): ilXMLFileNodeInfoInterface - { - return new ilXMLFileNodeInfo($this->logger); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilFactory.php deleted file mode 100644 index a7077c6f4008..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilFactory.php +++ /dev/null @@ -1,124 +0,0 @@ -logger = $logger; - $this->lng = $lng; - $this->schema_factory = $schema_factory; - } - - public function handler(): ilXMLFileSchemaHandlerInterface - { - return new ilXMLFileSchemaHandler( - new ilFilePathFactory($this->logger), - $this->schema_factory, - new ilParserFactory($this->logger), - new ilXSDFileFactory() - ); - } - - public function handlersFromXMLFileHandlerAtPath( - ilXMLFileHandlerInterface $xml_file_handler, - ilXMLFilePathHandlerInterface $path_to_entities - ): ilXMLFileSchemaCollectionInterface { - $parser = new ilParserFactory($this->logger); - $path = new ilFilePathFactory($this->logger); - $xml_file_node_info = $parser->DOM()->withFileHandler($xml_file_handler) - ->getNodeInfoAt($this->getPathToExportNode($path)) - ->current(); - $nodes = $parser->DOM()->withFileHandler($xml_file_handler)->getNodeInfoAt($path_to_entities); - $collection = new ilXMLFileSchemaCollection(); - foreach ($nodes as $node) { - $collection = $collection->withElement($this->initSchemaFileFromXMLNodeInfoHandler($node)); - } - return $collection; - } - - protected function initSchemaFileFromXMLNodeInfoHandler( - ilXMLFileNodeInfoHandlerInterface $xml_file_node_info - ): ilXMLFileSchemaHandler { - $types = $this->getTypesArray($xml_file_node_info); - $version_str = $this->getVersionString($xml_file_node_info); - if ($version_str === '') { - return $this->handler() - ->withType($types[0]) - ->withSubType($types[1]); - } - return $this->handler() - ->withType($types[0]) - ->withSubType($types[1]) - ->withVersion(new Version($version_str)); - } - - /** - * @return string[] - */ - protected function getTypesArray(ilXMLFileNodeInfoHandlerInterface $xml_file_node_info): array - { - $type_str = $xml_file_node_info->getValueOfAttribute('Entity'); - return str_contains($type_str, '_') - ? explode('_', $type_str) - : [$type_str, '']; - } - - protected function getVersionString(ilXMLFileNodeInfoHandlerInterface $xml_file_node_info): string - { - return $xml_file_node_info->hasAttribute('SchemaVersion') - ? $xml_file_node_info->getValueOfAttribute('SchemaVersion') - : ''; - } - - protected function getPathToExportNode(ilFilePathFactoryInterface $path): ilFilePathHandlerInterface - { - return $path->handler() - ->withStartAtRoot(true) - ->withNode($path->node()->simple()->withName('exp:Export')); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilHandler.php deleted file mode 100644 index 219679fc5378..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilHandler.php +++ /dev/null @@ -1,161 +0,0 @@ -path = $path; - $this->schema = $schema; - $this->parser = $parser; - $this->xsd = $xsd; - $this->type = null; - $this->subtype = null; - $this->version = null; - $this->xml_file_handler = null; - $this->xml_file_node_info = null; - } - - public function getXSDFileHandlerByVersionOrLatest(): null|ilXSDFileHandlerInterface - { - if ( - is_null($this->getVersion()) || - is_null($this->getPrimaryType()) || - is_null($this->getSecondaryType()) - ) { - return null; - } - $latest_file_info = $this->schema->getByVersionOrLatest( - $this->getVersion(), - $this->getPrimaryType(), - $this->getSecondaryType() - ); - return is_null($latest_file_info) - ? null - : $this->xsd->withFileInfo($latest_file_info); - } - - public function getXSDFileHandlerLatest(): null|ilXSDFileHandlerInterface - { - if ( - is_null($this->getPrimaryType()) || - is_null($this->getSecondaryType()) - ) { - return null; - } - $latest_file_info = $this->schema->getLatest( - $this->getPrimaryType(), - $this->getSecondaryType() - ); - return is_null($latest_file_info) - ? null - : $this->xsd->withFileInfo($latest_file_info); - } - - public function doesXSDFileWithMatchingVersionExist(): bool - { - if ( - is_null($this->getVersion()) || - is_null($this->getPrimaryType()) || - is_null($this->getSecondaryType()) - ) { - return false; - } - $file_info_with_version = $this->schema->getByVersion( - $this->getVersion(), - $this->getPrimaryType(), - $this->getSecondaryType() - ); - return !is_null($file_info_with_version); - } - - public function withType(string $type): ilXMLFileSchemaHandlerInterface - { - $clone = clone $this; - $clone->type = $type; - return $clone; - } - - public function withSubType(string $subtype): ilXMLFileSchemaHandlerInterface - { - $clone = clone $this; - $clone->subtype = $subtype; - return $clone; - } - - public function withVersion(Version $version): ilXMLFileSchemaHandlerInterface - { - $clone = clone $this; - $clone->version = $version; - return $clone; - } - - public function getVersion(): null|Version - { - return $this->version; - } - - public function getPrimaryType(): null|string - { - return $this->type; - } - - public function getSecondaryType(): null|string - { - return $this->subtype; - } - - public function getTypeString(): string - { - if (is_null($this->getPrimaryType())) { - return ''; - } - if (is_null($this->getSecondaryType())) { - return $this->getPrimaryType(); - } - return $this->getPrimaryType() . '_' . $this->getSecondaryType(); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XML/class.ilFactory.php deleted file mode 100755 index 3975f95b4a85..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/class.ilFactory.php +++ /dev/null @@ -1,103 +0,0 @@ -logger = $logger; - $this->lng = $lng; - $this->schema_factory = $schema_factory; - } - - public function withFileInfo(SplFileInfo $file_info): ilXMLFileHanlderInterface - { - return (new ilXMLFileHanlder( - new ilFileNamespaceFactory(), - new ilStatusFactory() - ))->withFileInfo($file_info); - } - - public function collection(): ilXMLFileHanlderCollectionInterface - { - return new ilXMLFileHanlderCollection(); - } - - public function manifest(): ilManifestFileFactoryInterface - { - return new ilManifestFileFactory( - $this->logger, - $this->lng, - $this->schema_factory - ); - } - - public function node(): ilXMLFileNodeFactoryInterface - { - return new ilXMLFileNodeFactory($this->logger); - } - - public function export(): ilXMLExportFileFactoryInterface - { - return new ilXMLExportFileFactory( - $this->logger, - $this->lng, - $this->schema_factory - ); - } - - public function schema(): ilXMLFileSchemaFactoryInterface - { - return new ilXMLFileSchemaFactory( - $this->logger, - $this->lng, - $this->schema_factory - ); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XSD/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/XSD/Factory.php similarity index 67% rename from components/ILIAS/Export/classes/ImportHandler/File/XSD/class.ilFactory.php rename to components/ILIAS/Export/classes/ImportHandler/File/XSD/Factory.php index 9cb02a49f264..be775357e16d 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XSD/class.ilFactory.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XSD/Factory.php @@ -20,13 +20,13 @@ namespace ILIAS\Export\ImportHandler\File\XSD; -use ILIAS\Export\ImportHandler\File\Namespace\ilFactory as ilFileNamespaceFactory; -use ILIAS\Export\ImportHandler\File\XSD\ilHandler as ilXSDFileHandler; -use ILIAS\Export\ImportHandler\I\File\XSD\ilFactoryInterface as ilXSDFileHandlerFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XSD\ilHandlerInterface as ilXSDFileHandlerInterface; +use ILIAS\Export\ImportHandler\File\Namespace\Factory as ilFileNamespaceFactory; +use ILIAS\Export\ImportHandler\File\XSD\Handler as ilXSDFileHandler; +use ILIAS\Export\ImportHandler\I\File\XSD\FactoryInterface as ilXSDFileHandlerFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\XSD\HandlerInterface as ilXSDFileHandlerInterface; use SplFileInfo; -class ilFactory implements ilXSDFileHandlerFactoryInterface +class Factory implements ilXSDFileHandlerFactoryInterface { public function withFileInfo(SplFileInfo $file_info): ilXSDFileHandlerInterface { diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XSD/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/File/XSD/Handler.php similarity index 64% rename from components/ILIAS/Export/classes/ImportHandler/File/XSD/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/File/XSD/Handler.php index e93ab9335dc6..cbb74b49b8c7 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XSD/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/File/XSD/Handler.php @@ -20,16 +20,16 @@ namespace ILIAS\Export\ImportHandler\File\XSD; -use ILIAS\Export\ImportHandler\File\ilHandler as ilFileHandler; -use ILIAS\Export\ImportHandler\I\File\XSD\ilHandlerInterface as ilXSDFileHandlerInterface; +use ILIAS\Export\ImportHandler\File\Handler as ilImportHandlerFile; +use ILIAS\Export\ImportHandler\I\File\XSD\HandlerInterface as ilImportHandlerXSDFileInterface; use SplFileInfo; -class ilHandler extends ilFileHandler implements ilXSDFileHandlerInterface +class Handler extends ilImportHandlerFile implements ilImportHandlerXSDFileInterface { - public function withFileInfo(SplFileInfo $file_info): ilHandler + public function withFileInfo(SplFileInfo $file_info): ilImportHandlerXSDFileInterface { $clone = clone $this; - $clone->xml_file_info = $file_info; + $clone->spl_file_info = $file_info; return $clone; } } diff --git a/components/ILIAS/Export/classes/ImportHandler/File/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/File/class.ilFactory.php deleted file mode 100755 index c8b9a9622d59..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/File/class.ilFactory.php +++ /dev/null @@ -1,86 +0,0 @@ -logger = $logger; - $this->lng = $lng; - $this->schema_factory = $schema_factory; - } - - public function xml(): ilXMLFileFactoryInterface - { - return new ilXMLFileFactory( - $this->logger, - $this->lng, - $this->schema_factory - ); - } - - public function xsd(): ilXSDFileFactoryInterface - { - return new ilXSDFileFactory(); - } - - public function validation(): ilFileValidationFactoryInterface - { - return new ilFileValidationFactory($this->logger); - } - - public function path(): ilFilePathFactoryInterface - { - return new ilFilePathFactory($this->logger); - } - - public function namespace(): ilFileNamespaceFactoryInterface - { - return new ilFileNamespaceFactory(); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/I/FactoryInterface.php b/components/ILIAS/Export/classes/ImportHandler/I/FactoryInterface.php new file mode 100755 index 000000000000..3147900e3171 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/I/FactoryInterface.php @@ -0,0 +1,40 @@ +operator = $operator; - $this->value = $value; - } + public function withComparison(ilImportHandlerPathComparisonInterface $comparison): IndexInterface; - public function toString() - { - return Operator::toString($this->operator) . $this->value; - } + public function withIndexingFromEndEnabled(bool $enabled): IndexInterface; } diff --git a/components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilNodeInterface.php b/components/ILIAS/Export/classes/ImportHandler/I/Path/Node/NodeInterface.php similarity index 88% rename from components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilNodeInterface.php rename to components/ILIAS/Export/classes/ImportHandler/I/Path/Node/NodeInterface.php index 50e0ddb1fda0..0d0e4242355b 100755 --- a/components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilNodeInterface.php +++ b/components/ILIAS/Export/classes/ImportHandler/I/Path/Node/NodeInterface.php @@ -18,9 +18,9 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\I\File\Path\Node; +namespace ILIAS\Export\ImportHandler\I\Path\Node; -interface ilNodeInterface +interface NodeInterface { public function toString(): string; diff --git a/components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilAnyNodeInterface.php b/components/ILIAS/Export/classes/ImportHandler/I/Path/Node/OpenRoundBrackedInterface.php similarity index 71% rename from components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilAnyNodeInterface.php rename to components/ILIAS/Export/classes/ImportHandler/I/Path/Node/OpenRoundBrackedInterface.php index f63d0fef0f73..8256b24be1b8 100755 --- a/components/ILIAS/Export/classes/ImportHandler/I/File/Path/Node/interface.ilAnyNodeInterface.php +++ b/components/ILIAS/Export/classes/ImportHandler/I/Path/Node/OpenRoundBrackedInterface.php @@ -18,10 +18,10 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\I\File\Path\Node; +namespace ILIAS\Export\ImportHandler\I\Path\Node; -use ILIAS\Export\ImportHandler\I\File\Path\Node\ilNodeInterface as ilFilePathNodeInterface; +use ILIAS\Export\ImportHandler\I\Path\Node\NodeInterface as ilImportHandlerPathNodeInterface; -interface ilAnyNodeInterface extends ilFilePathNodeInterface +interface OpenRoundBrackedInterface extends ilImportHandlerPathNodeInterface { } diff --git a/components/ILIAS/Export/classes/ImportHandler/I/Path/Node/SimpleInterface.php b/components/ILIAS/Export/classes/ImportHandler/I/Path/Node/SimpleInterface.php new file mode 100755 index 000000000000..1d98c7cdcf51 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/I/Path/Node/SimpleInterface.php @@ -0,0 +1,28 @@ +import_handler = $import_handler; + $this->logger = $logger; + } + + public function handler(): ilImportHandlerDOMParserInterface + { + return new ilImportHandlerDOMParser( + $this->logger, + $this->import_handler->parser()->nodeInfo() + ); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/Parser/DOM/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/Parser/DOM/Handler.php similarity index 75% rename from components/ILIAS/Export/classes/ImportHandler/Parser/DOM/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/Parser/DOM/Handler.php index 6f5760076cdc..6515f0411b77 100755 --- a/components/ILIAS/Export/classes/ImportHandler/Parser/DOM/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/DOM/Handler.php @@ -23,15 +23,15 @@ use DOMDocument; use DOMNode; use DOMXPath; -use ilLogger; -use ILIAS\Export\ImportHandler\I\File\Path\ilHandlerInterface as ilFilePathHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\ilHandlerInterface as ilXMLFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilCollectionInterface as ilXMLFileNodeInfoCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilFactoryInterface as ilXMLFileNodeInfoFactoryInterface; -use ILIAS\Export\ImportHandler\I\Parser\DOM\ilHandlerInterface as ilDOMParserHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XML\HandlerInterface as ilXMLFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\Parser\DOM\HandlerInterface as ilDOMParserHandlerInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\CollectionInterface as ilXMLFileNodeInfoCollectionInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\FactoryInterface as ilXMLFileNodeInfoFactoryInterface; +use ILIAS\Export\ImportHandler\I\Path\HandlerInterface as ilImportHandlerPathInterface; use ILIAS\Export\ImportStatus\Exception\ilException as ilImportStatusException; +use ilLogger; -class ilHandler implements ilDOMParserHandlerInterface +class Handler implements ilDOMParserHandlerInterface { protected ilXMLFileHandlerInterface $xml_file_handler; protected ilXMLFileNodeInfoFactoryInterface $info; @@ -57,7 +57,7 @@ public function withFileHandler(ilXMLFileHandlerInterface $file_handler): ilDOMP return $clone; } - public function getNodeInfoAt(ilFilePathHandlerInterface $path): ilXMLFileNodeInfoCollectionInterface + public function getNodeInfoAt(ilImportHandlerPathInterface $path): ilXMLFileNodeInfoCollectionInterface { $dom_xpath = new DOMXPath($this->dom_doc); foreach ($this->xml_file_handler->getNamespaces() as $namespace) { diff --git a/components/ILIAS/Export/classes/ImportHandler/Parser/DOM/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/Parser/DOM/class.ilFactory.php deleted file mode 100755 index 1d46052ea4d3..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/Parser/DOM/class.ilFactory.php +++ /dev/null @@ -1,48 +0,0 @@ -logger = $logger; - } - - public function withFileHandler(ilXMLFileHandlerInterface $file_handler): ilDOMParserHandlerInterface - { - return (new ilDOMParser( - $this->logger, - new ilXMLFileNodeInfoFactory($this->logger) - ))->withFileHandler($file_handler); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/Parser/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Parser/Factory.php new file mode 100755 index 000000000000..afe1220ff34b --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/Factory.php @@ -0,0 +1,59 @@ +import_handler = $import_handler; + $this->logger = $logger; + } + + public function DOM(): ilDOMParserFactoryInterface + { + return new ilDOMParserFactory( + $this->import_handler, + $this->logger + ); + } + + public function nodeInfo(): ilImportHandlerParserNodeInfoFactoryInterface + { + return new ilImportHandlerParserNodeInfoFactory( + $this->import_handler, + $this->logger + ); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/Attribute/class.ilCollection.php b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Attribute/Collection.php similarity index 67% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/Attribute/class.ilCollection.php rename to components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Attribute/Collection.php index 88330c9a2113..e098924bd00f 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/Attribute/class.ilCollection.php +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Attribute/Collection.php @@ -18,17 +18,17 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\XML\Node\Info\Attribute; +namespace ILIAS\Export\ImportHandler\Parser\NodeInfo\Attribute; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\Attribute\ilCollectionInterface as ilXMLFileNodeInfoAttributeCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\Attribute\ilPairInterface as ilXMLFileNodeInfoAttributePairInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilHandlerInterface as ilXMLFileNodeInfoInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\Attribute\CollectionInterface as ilImportHandlerParserNodeInfoAttributeCollectionInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\Attribute\HandlerInterface as ilImportHandlerParserNodeInfoAttributeInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\HandlerInterface as ilImportHandlerParserNodeInfoInterface; use ilLogger; -class ilCollection implements ilXMLFileNodeInfoAttributeCollectionInterface +class Collection implements ilImportHandlerParserNodeInfoAttributeCollectionInterface { /** - * @var ilXMLFileNodeInfoAttributePairInterface[] + * @var ilImportHandlerParserNodeInfoAttributeInterface[] */ protected array $elements; protected int $index; @@ -42,7 +42,7 @@ public function __construct( $this->logger = $logger; } - public function matches(ilXMLFileNodeInfoInterface $node_info): bool + public function matches(ilImportHandlerParserNodeInfoInterface $node_info): bool { foreach ($this->elements as $element) { if ( @@ -57,8 +57,8 @@ public function matches(ilXMLFileNodeInfoInterface $node_info): bool } public function withElement( - ilXMLFileNodeInfoAttributePairInterface $element - ): ilXMLFileNodeInfoAttributeCollectionInterface { + ilImportHandlerParserNodeInfoAttributeInterface $element + ): ilImportHandlerParserNodeInfoAttributeCollectionInterface { $clone = clone $this; $clone->elements[] = $element; return $clone; @@ -69,7 +69,7 @@ public function toArray(): array return $this->elements; } - public function current(): ilXMLFileNodeInfoAttributePairInterface + public function current(): ilImportHandlerParserNodeInfoAttributeInterface { return $this->elements[$this->index]; } diff --git a/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Attribute/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Attribute/Factory.php new file mode 100755 index 000000000000..5c50544e327f --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Attribute/Factory.php @@ -0,0 +1,50 @@ +logger = $logger; + } + + public function handler(): ilImportHandlerParserNodeInfoAttributeInterface + { + return new ilImportHandlerParserNodeInfoAttribute(); + } + + public function collection(): ilImportHandlerParserNodeInfoAttributeCollectionInterface + { + return new ilImportHandlerParserNodeInfoAttribureCollection( + $this->logger + ); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/Attribute/class.ilPair.php b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Attribute/Handler.php similarity index 68% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/Attribute/class.ilPair.php rename to components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Attribute/Handler.php index babeafa22485..18f194145885 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/Attribute/class.ilPair.php +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Attribute/Handler.php @@ -18,11 +18,11 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\XML\Node\Info\Attribute; +namespace ILIAS\Export\ImportHandler\Parser\NodeInfo\Attribute; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\Attribute\ilPairInterface as ilXMLFileNodeInfoAttributePairInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\Attribute\HandlerInterface as ilImportHandlerParserNodeInfoAttributeInterface; -class ilPair implements ilXMLFileNodeInfoAttributePairInterface +class Handler implements ilImportHandlerParserNodeInfoAttributeInterface { protected string $key; protected string $value; @@ -33,15 +33,17 @@ public function __construct() $this->value = ''; } - public function withValue(string $value): ilXMLFileNodeInfoAttributePairInterface - { + public function withValue( + string $value + ): ilImportHandlerParserNodeInfoAttributeInterface { $clone = clone $this; $clone->value = $value; return $clone; } - public function withKey(string $key): ilXMLFileNodeInfoAttributePairInterface - { + public function withKey( + string $key + ): ilImportHandlerParserNodeInfoAttributeInterface { $clone = clone $this; $clone->key = $key; return $clone; diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/class.ilCollection.php b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Collection.php similarity index 53% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/class.ilCollection.php rename to components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Collection.php index a4393f1c4f0b..bf6c24f6db1e 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/class.ilCollection.php +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Collection.php @@ -1,14 +1,14 @@ index = 0; } - public function getFirst(): ilXMLFileNodeInfoInterface + public function getFirst(): ilImportHandlerParserNodeInfoInterface { return $this->elements[0]; } - public function removeFirst(): ilXMLFileNodeInfoCollectionInterface + public function removeFirst(): ilImportHandlerParserNodeInfoCollectionInterface { $clone = clone $this; $clone->index = $this->index; @@ -37,15 +37,17 @@ public function count(): int return count($this->elements); } - public function withMerged(ilXMLFileNodeInfoCollectionInterface $other): ilXMLFileNodeInfoCollectionInterface - { + public function withMerged( + ilImportHandlerParserNodeInfoCollectionInterface $other + ): ilImportHandlerParserNodeInfoCollectionInterface { $clone = clone $this; $clone->elements = array_merge($this->toArray(), $other->toArray()); return $clone; } - public function withElement(ilXMLFileNodeInfoInterface $element): ilXMLFileNodeInfoCollectionInterface - { + public function withElement( + ilImportHandlerParserNodeInfoInterface $element + ): ilImportHandlerParserNodeInfoCollectionInterface { $clone = clone $this; $clone->elements[] = $element; return $clone; @@ -56,7 +58,7 @@ public function toArray(): array return $this->elements; } - public function current(): ilXMLFileNodeInfoInterface + public function current(): ilImportHandlerParserNodeInfoInterface { return $this->elements[$this->index]; } @@ -73,7 +75,7 @@ public function key(): int public function valid(): bool { - return 0 <= $this->index && $this->index < $this->count(); + return isset($this->elements[$this->index]); } public function rewind(): void diff --git a/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/DOM/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/DOM/Factory.php new file mode 100755 index 000000000000..0105f681fa2e --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/DOM/Factory.php @@ -0,0 +1,45 @@ +info = $info; + } + + public function withDOMNode(DOMNode $node): ilImportHandlerParserNodeInfoDOMNodeInterface + { + return (new ilImportHandlerParserDOMNodeInfo( + $this->info + ))->withDOMNode($node); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/DOM/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/DOM/Handler.php similarity index 72% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/DOM/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/DOM/Handler.php index 5c452fc990a1..bd8fbc15794d 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/DOM/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/DOM/Handler.php @@ -18,26 +18,26 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\XML\Node\Info\DOM; +namespace ILIAS\Export\ImportHandler\Parser\NodeInfo\DOM; use DOMAttr; use DOMNode; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\DOM\ilHandlerInterface as ilXMLFileNodeInfoilDOMNodeHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilCollectionInterface as ilXMLFileNodeInfoCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilFactoryInterface as ilXMLFileNodeInfoFactoryInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\CollectionInterface as ilImportHandlerParserNodeInfoCollectionInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\DOM\HandlerInterface as ilImportHandlerParserNodeInfoilDOMNodeInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\FactoryInterface as ilImportHandlerParserNodeInfoFactoryInterface; use ilImportException; -class ilHandler implements ilXMLFileNodeInfoilDOMNodeHandlerInterface +class Handler implements ilImportHandlerParserNodeInfoilDOMNodeInterface { /** * @var array */ protected array $attributes; protected DOMNode $node; - protected ilXMLFileNodeInfoFactoryInterface $info; + protected ilImportHandlerParserNodeInfoFactoryInterface $info; public function __construct( - ilXMLFileNodeInfoFactoryInterface $info + ilImportHandlerParserNodeInfoFactoryInterface $info ) { $this->attributes = []; $this->info = $info; @@ -45,7 +45,7 @@ public function __construct( protected function initAttributes() { - if(is_null($this->node->attributes)) { + if (is_null($this->node->attributes)) { return; } /** @var DOMAttr $attribute **/ @@ -54,7 +54,7 @@ protected function initAttributes() } } - public function withDOMNode(DOMNode $node): ilHandler + public function withDOMNode(DOMNode $node): Handler { $clone = clone $this; $clone->node = $node; @@ -80,7 +80,7 @@ public function getValueOfAttribute(string $attribute_name): string return $this->attributes[$attribute_name]; } - public function getChildren(): ilXMLFileNodeInfoCollectionInterface + public function getChildren(): ilImportHandlerParserNodeInfoCollectionInterface { $collection = $this->info->collection(); $children = $this->node->childNodes; @@ -90,9 +90,9 @@ public function getChildren(): ilXMLFileNodeInfoCollectionInterface return $collection; } - public function getParent(): ilHandler|null + public function getParent(): Handler|null { - if(!is_null($this->node->parentNode)) { + if (!is_null($this->node->parentNode)) { return $this->info->DOM()->withDOMNode($this->node->parentNode); } return null; diff --git a/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Factory.php new file mode 100755 index 000000000000..b87633c7f1fa --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Factory.php @@ -0,0 +1,74 @@ +import_handler = $import_handler; + $this->logger = $logger; + } + + public function collection(): ilImportHandlerParserNodeInfoCollectionInterface + { + return new ilImportHandlerParserNodeInfoCollection(); + } + + public function tree(): ilImportHandlerParserNodeInfoTreeFactoryInterface + { + return new ilImportHandlerParserNodeInfoTreeFactory( + $this->import_handler, + $this->logger + ); + } + + public function attribute(): ilImportHandlerParserNodeInfoAttributeFactoryInterface + { + return new ilImportHandlerParserNodeInfoAttributeFactory( + $this->logger + ); + } + + public function DOM(): ilImportHandlerParserDOMNodeInfoFactoryInterface + { + return new ilImportHandlerParserDOMNodeInfoFactory( + $this + ); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Tree/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Tree/Factory.php new file mode 100644 index 000000000000..8710f5282b59 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Tree/Factory.php @@ -0,0 +1,50 @@ +import_handler = $import_handler; + $this->logger = $logger; + } + + public function handler(): ilImportHandlerParserNodeInfoTreeInterface + { + return new ilImportHandlerParserNodeInfoTree( + $this->import_handler->parser()->nodeInfo(), + $this->import_handler->parser(), + $this->logger + ); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/class.ilTree.php b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Tree/Handler.php similarity index 54% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/class.ilTree.php rename to components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Tree/Handler.php index 0b89d550d14a..a21f52cbc1e5 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Node/Info/class.ilTree.php +++ b/components/ILIAS/Export/classes/ImportHandler/Parser/NodeInfo/Tree/Handler.php @@ -18,30 +18,30 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\XML\Node\Info; +namespace ILIAS\Export\ImportHandler\Parser\NodeInfo\Tree; -use ILIAS\Export\ImportHandler\I\File\Path\ilHandlerInterface as ilXMLFilePathHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\ilHandlerInterface as ilXMLFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\Attribute\ilCollectionInterface as ilXMLFileNodeInfoAttributePairCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilCollectionInterface as ilXMLFileNodeInfoCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilFactoryInterface as ilXMLFileNodeInfoFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilHandlerInterface as ilXMLFileNodeInfoInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilTreeInterface as ilXMLFileNodeInfoTreeInterface; -use ILIAS\Export\ImportHandler\I\Parser\ilFactoryInterface as ilParserFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\XML\HandlerInterface as ilImportHanlderXMLFileInterface; +use ILIAS\Export\ImportHandler\I\Parser\FactoryInterface as ilImportHandlerParserFactoryInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\Attribute\CollectionInterface as ilImportHandlerParserNodeInfoAttributeCollectionInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\CollectionInterface as ilImportHandlerParserNodeInfoCollectionInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\FactoryInterface as ilImportHandlerParserNodeInfoFactoryInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\HandlerInterface as ilImportHandlerParserNodeInfoInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\Tree\HandlerInterface as ilImportHandlerParserNodeInfoTreeInterface; +use ILIAS\Export\ImportHandler\I\Path\HandlerInterface as ilImportHandlerPathInterface; use ILIAS\Export\ImportStatus\Exception\ilException as ilImportStatusException; use ilLogger; -class ilTree implements ilXMLFileNodeInfoTreeInterface +class Handler implements ilImportHandlerParserNodeInfoTreeInterface { - protected ilXMLFileNodeInfoInterface $root; - protected ilXMLFileNodeInfoFactoryInterface $info; - protected ilParserFactoryInterface $parser; - protected ilXMLFileHandlerInterface $xml; + protected ilImportHandlerParserNodeInfoInterface $root; + protected ilImportHandlerParserNodeInfoFactoryInterface $info; + protected ilImportHandlerParserFactoryInterface $parser; + protected ilImportHanlderXMLFileInterface $xml; protected ilLogger $logger; public function __construct( - ilXMLFileNodeInfoFactoryInterface $info, - ilParserFactoryInterface $parser, + ilImportHandlerParserNodeInfoFactoryInterface $info, + ilImportHandlerParserFactoryInterface $parser, ilLogger $logger ) { $this->info = $info; @@ -49,7 +49,7 @@ public function __construct( $this->logger = $logger; } - public function withRoot(ilXMLFileNodeInfoInterface $node_info): ilXMLFileNodeInfoTreeInterface + public function withRoot(ilImportHandlerParserNodeInfoInterface $node_info): ilImportHandlerParserNodeInfoTreeInterface { $clone = clone $this; $clone->root = $node_info; @@ -60,12 +60,14 @@ public function withRoot(ilXMLFileNodeInfoInterface $node_info): ilXMLFileNodeIn * @throws ilImportStatusException */ public function withRootInFile( - ilXMLFileHandlerInterface $xml_handler, - ilXMLFilePathHandlerInterface $path_handler - ): ilXMLFileNodeInfoTreeInterface { + ilImportHanlderXMLFileInterface $xml_handler, + ilImportHandlerPathInterface $path_handler + ): ilImportHandlerParserNodeInfoTreeInterface { $clone = clone $this; $clone->xml = $xml_handler; - $items = $this->parser->DOM()->withFileHandler($xml_handler)->getNodeInfoAt($path_handler); + $items = $this->parser->DOM()->handler() + ->withFileHandler($xml_handler) + ->getNodeInfoAt($path_handler); if ($items->count() === 0) { unset($clone->root); } @@ -76,9 +78,9 @@ public function withRootInFile( } public function getNodesWith( - ilXMLFileNodeInfoAttributePairCollectionInterface $attribute_pairs - ): ilXMLFileNodeInfoCollectionInterface { - if(!isset($this->root)) { + ilImportHandlerParserNodeInfoAttributeCollectionInterface $attribute_pairs + ): ilImportHandlerParserNodeInfoCollectionInterface { + if (!isset($this->root)) { return $this->info->collection(); } $nodes = $this->info->collection()->withMerged($this->root->getChildren()); @@ -95,14 +97,14 @@ public function getNodesWith( } public function getFirstNodeWith( - ilXMLFileNodeInfoAttributePairCollectionInterface $attribute_pairs - ): ilXMLFileNodeInfoInterface|null { + ilImportHandlerParserNodeInfoAttributeCollectionInterface $attribute_pairs + ): ilImportHandlerParserNodeInfoInterface|null { $nodes = $this->getNodesWith($attribute_pairs); return count($nodes) === 0 ? null : $nodes->getFirst(); } public function getAttributePath( - ilXMLFileNodeInfoInterface $startNode, + ilImportHandlerParserNodeInfoInterface $startNode, string $attribute_name, string $path_separator, bool $skip_nodes_without_attribute = true @@ -110,7 +112,7 @@ public function getAttributePath( $path_str = ''; $current_node = $startNode; while (!is_null($current_node)) { - if($skip_nodes_without_attribute && !$current_node->hasAttribute($attribute_name)) { + if ($skip_nodes_without_attribute && !$current_node->hasAttribute($attribute_name)) { break; } $path_str = $current_node->hasAttribute($attribute_name) diff --git a/components/ILIAS/Export/classes/ImportHandler/Parser/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/Parser/class.ilFactory.php deleted file mode 100755 index 4a05c53e993c..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/Parser/class.ilFactory.php +++ /dev/null @@ -1,44 +0,0 @@ -logger = $logger; - } - - public function DOM(): ilDOMParserFactoryInterface - { - return new ilDOMParserFactory($this->logger); - } -} diff --git a/components/ILIAS/Export/classes/ImportHandler/Path/Comparison/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Path/Comparison/Factory.php new file mode 100755 index 000000000000..0a81d3ee6acf --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Comparison/Factory.php @@ -0,0 +1,33 @@ +operator) ?? "") . ($this->value ?? ""); + } + + public function withOperator( + ilImportHandlerPathComparisonOperator $operator + ): ilImportHandlerFilePathComparisonInterface { + $clone = clone $this; + $clone->operator = $operator; + return $clone; + } + + public function withValue( + string $value + ): ilImportHandlerFilePathComparisonInterface { + $clone = clone $this; + $clone->value = $value; + return $clone; + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/Comparison/enum.Operator.php b/components/ILIAS/Export/classes/ImportHandler/Path/Comparison/Operator.php similarity index 94% rename from components/ILIAS/Export/classes/ImportHandler/File/Path/Comparison/enum.Operator.php rename to components/ILIAS/Export/classes/ImportHandler/Path/Comparison/Operator.php index 26dceec0dbd7..59152f7cfc61 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/Comparison/enum.Operator.php +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Comparison/Operator.php @@ -18,7 +18,7 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Path\Comparison; +namespace ILIAS\Export\ImportHandler\Path\Comparison; enum Operator { diff --git a/components/ILIAS/Export/classes/ImportHandler/Path/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Path/Factory.php new file mode 100755 index 000000000000..ca753c189eaf --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Factory.php @@ -0,0 +1,58 @@ +logger = $logger; + } + + public function handler(): ilFilePathHandlerInterface + { + return new ilImportHandlerPath(); + } + + public function node(): ilImportHandlerPathNodeFactoryInterface + { + return new ilImportHandlerPathNodeFactory( + $this->logger + ); + } + + public function comparison(): ilImportHandlerPathComparisonFactoryInterface + { + return new ilImportHandlerPathComparisonFactory(); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/Path/Handler.php similarity index 90% rename from components/ILIAS/Export/classes/ImportHandler/File/Path/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/Path/Handler.php index 241e5e1f46d0..5b650c7f6a31 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Handler.php @@ -18,12 +18,12 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Path; +namespace ILIAS\Export\ImportHandler\Path; -use ILIAS\Export\ImportHandler\I\File\Path\ilHandlerInterface as ilParserPathHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Path\Node\ilNodeInterface as ilFilePathNodeInterface; +use ILIAS\Export\ImportHandler\I\Path\HandlerInterface as ilParserPathHandlerInterface; +use ILIAS\Export\ImportHandler\I\Path\Node\NodeInterface as ilFilePathNodeInterface; -class ilHandler implements ilParserPathHandlerInterface +class Handler implements ilParserPathHandlerInterface { /** * @var ilFilePathNodeInterface[] @@ -123,7 +123,7 @@ public function key(): int public function valid(): bool { - return 0 <= $this->index && $this->index < $this->count(); + return isset($this->nodes[$this->index]); } public function rewind(): void diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilAnyElement.php b/components/ILIAS/Export/classes/ImportHandler/Path/Node/AnyElement.php similarity index 76% rename from components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilAnyElement.php rename to components/ILIAS/Export/classes/ImportHandler/Path/Node/AnyElement.php index 790d91313d26..038df8402b51 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilAnyElement.php +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Node/AnyElement.php @@ -18,11 +18,11 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Path\Node; +namespace ILIAS\Export\ImportHandler\Path\Node; -use ILIAS\Export\ImportHandler\I\File\Path\Node\ilAnyElementInterface as ilAnyElementFilePathNodeInterface; +use ILIAS\Export\ImportHandler\I\Path\Node\AnyElementInterface as ilAnyElementFilePathNodeInterface; -class ilAnyElement implements ilAnyElementFilePathNodeInterface +class AnyElement implements ilAnyElementFilePathNodeInterface { public function toString(): string { diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilAnyNode.php b/components/ILIAS/Export/classes/ImportHandler/Path/Node/AnyNode.php similarity index 77% rename from components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilAnyNode.php rename to components/ILIAS/Export/classes/ImportHandler/Path/Node/AnyNode.php index 8dd08af8a314..7b39f8aac055 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilAnyNode.php +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Node/AnyNode.php @@ -18,11 +18,11 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Path\Node; +namespace ILIAS\Export\ImportHandler\Path\Node; -use ILIAS\Export\ImportHandler\I\File\Path\Node\ilAnyNodeInterface as ilAnyNodeFilePathNodeInterface; +use ILIAS\Export\ImportHandler\I\Path\Node\AnyNodeInterface as ilAnyNodeFilePathNodeInterface; -class ilAnyNode implements ilAnyNodeFilePathNodeInterface +class AnyNode implements ilAnyNodeFilePathNodeInterface { public function toString(): string { diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilAttribute.php b/components/ILIAS/Export/classes/ImportHandler/Path/Node/Attribute.php similarity index 70% rename from components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilAttribute.php rename to components/ILIAS/Export/classes/ImportHandler/Path/Node/Attribute.php index f89d8a13f3a5..665417209f1b 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilAttribute.php +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Node/Attribute.php @@ -18,22 +18,20 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Path\Node; +namespace ILIAS\Export\ImportHandler\Path\Node; -use ILIAS\Export\ImportHandler\File\Path\Comparison\ilHandlerDummy; -use ILIAS\Export\ImportHandler\I\File\Path\Comparison\ilHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Path\Node\ilAttributeInterface as ilAttributeFilePathNodeInterface; +use ILIAS\Export\ImportHandler\I\Path\Comparison\HandlerInterface; +use ILIAS\Export\ImportHandler\I\Path\Node\AttributeInterface as ilAttributeFilePathNodeInterface; -class ilAttribute implements ilAttributeFilePathNodeInterface +class Attribute implements ilAttributeFilePathNodeInterface { - protected ilHandlerInterface $comparison; + protected HandlerInterface $comparison; protected string $attribute; protected bool $any_attribute_enabled; public function __construct() { $this->attribute = ''; - $this->comparison = new ilHandlerDummy(); $this->any_attribute_enabled = false; } @@ -44,7 +42,7 @@ public function withAttribute(string $attribute): ilAttributeFilePathNodeInterfa return $clone; } - public function withComparison(ilHandlerInterface $comparison): ilAttributeFilePathNodeInterface + public function withComparison(HandlerInterface $comparison): ilAttributeFilePathNodeInterface { $clone = clone $this; $clone->comparison = $comparison; @@ -62,7 +60,7 @@ public function toString(): string { $attribute = $this->any_attribute_enabled ? '@*' - : '@' . $this->attribute . $this->comparison->toString(); + : '@' . $this->attribute . (isset($this->comparison) ? $this->comparison->toString() : ""); return '[' . $attribute . ']'; } diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilCloseRoundBracked.php b/components/ILIAS/Export/classes/ImportHandler/Path/Node/CloseRoundBracked.php similarity index 73% rename from components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilCloseRoundBracked.php rename to components/ILIAS/Export/classes/ImportHandler/Path/Node/CloseRoundBracked.php index 2cb2bb9798cc..92b6a0df7c27 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilCloseRoundBracked.php +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Node/CloseRoundBracked.php @@ -18,11 +18,11 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Path\Node; +namespace ILIAS\Export\ImportHandler\Path\Node; -use ILIAS\Export\ImportHandler\I\File\Path\Node\ilCloseRoundBrackedInterface as ilCloseRoundBrackedFilePathNodeInterface; +use ILIAS\Export\ImportHandler\I\Path\Node\CloseRoundBrackedInterface as ilCloseRoundBrackedFilePathNodeInterface; -class ilCloseRoundBracked implements ilCloseRoundBrackedFilePathNodeInterface +class CloseRoundBracked implements ilCloseRoundBrackedFilePathNodeInterface { public function toString(): string { diff --git a/components/ILIAS/Export/classes/ImportHandler/Path/Node/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Path/Node/Factory.php new file mode 100755 index 000000000000..41003f657459 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Node/Factory.php @@ -0,0 +1,83 @@ +logger = $logger; + } + + public function anyElement(): ilImportHandlerPathNodeAnyElementInterface + { + return new ilImportHandlerPathNodeAnyElement(); + } + + public function anyNode(): ilImportHandlerPathNodeAnyNodeInterface + { + return new ilImportHandlerPathNodeAnyNode(); + } + + public function attribute(): ilImportHandlerPathNodeAttributeInterface + { + return new ilImportHandlerPathNodeAttribute(); + } + + public function index(): ilImportHandlerPathNodeIndexInterface + { + return new ilImportHandlerPathNodeIndex(); + } + + public function simple(): ilImportHandlerPathNodeSimpleInterface + { + return new ilImportHandlerPathNodeSimple(); + } + + public function openRoundBracked(): ilImportHandlerPathNodeOpenRoundBrackedInterface + { + return new ilImportHandlerPathNodeOpenRoundBracked(); + } + + public function closeRoundBracked(): ilImportHandlerPathNodeCloseRoundBrackedInterface + { + return new ilImportHandlerPathNodeCloseRoundBracked(); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilIndex.php b/components/ILIAS/Export/classes/ImportHandler/Path/Node/Index.php similarity index 73% rename from components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilIndex.php rename to components/ILIAS/Export/classes/ImportHandler/Path/Node/Index.php index 858ad732d0a4..a57e921adc15 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilIndex.php +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Node/Index.php @@ -18,21 +18,19 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Path\Node; +namespace ILIAS\Export\ImportHandler\Path\Node; -use ILIAS\Export\ImportHandler\File\Path\Comparison\ilHandlerDummy; -use ILIAS\Export\ImportHandler\I\File\Path\Comparison\ilHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Path\Node\ilIndexInterface as ilIndexFilePathNodeInterface; +use ILIAS\Export\ImportHandler\I\Path\Comparison\HandlerInterface; +use ILIAS\Export\ImportHandler\I\Path\Node\IndexInterface as ilIndexFilePathNodeInterface; -class ilIndex implements ilIndexFilePathNodeInterface +class Index implements ilIndexFilePathNodeInterface { - protected ilHandlerInterface $comparison; + protected HandlerInterface $comparison; protected int $index; protected bool $indexing_from_end_enabled; public function __construct() { - $this->comparison = new ilHandlerDummy(); $this->index = 0; $this->indexing_from_end_enabled = false; } @@ -44,7 +42,7 @@ public function withIndex(int $index): ilIndexFilePathNodeInterface return $clone; } - public function withComparison(ilHandlerInterface $comparison): ilIndexFilePathNodeInterface + public function withComparison(HandlerInterface $comparison): ilIndexFilePathNodeInterface { $clone = clone $this; $clone->comparison = $comparison; @@ -61,15 +59,13 @@ public function withIndexingFromEndEnabled(bool $enabled): ilIndexFilePathNodeIn public function toString(): string { $indexing = ''; - - if ($this->comparison instanceof ilHandlerDummy) { + if (!isset($this->comparison)) { $indexing = $this->indexing_from_end_enabled ? '(last)-' . $this->index : $this->index; } else { $indexing = 'position()' . $this->comparison->toString(); } - return '[' . $indexing . ']'; } diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilOpenRoundBracked.php b/components/ILIAS/Export/classes/ImportHandler/Path/Node/OpenRoundBracked.php similarity index 74% rename from components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilOpenRoundBracked.php rename to components/ILIAS/Export/classes/ImportHandler/Path/Node/OpenRoundBracked.php index c8efae1dffbc..e796b5a9669b 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilOpenRoundBracked.php +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Node/OpenRoundBracked.php @@ -18,11 +18,11 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Path\Node; +namespace ILIAS\Export\ImportHandler\Path\Node; -use ILIAS\Export\ImportHandler\I\File\Path\Node\ilOpenRoundBrackedInterface as ilOpenRoundBrackedFilePathNodeInterface; +use ILIAS\Export\ImportHandler\I\Path\Node\OpenRoundBrackedInterface as ilOpenRoundBrackedFilePathNodeInterface; -class ilOpenRoundBracked implements ilOpenRoundBrackedFilePathNodeInterface +class OpenRoundBracked implements ilOpenRoundBrackedFilePathNodeInterface { public function toString(): string { diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilSimple.php b/components/ILIAS/Export/classes/ImportHandler/Path/Node/Simple.php similarity index 83% rename from components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilSimple.php rename to components/ILIAS/Export/classes/ImportHandler/Path/Node/Simple.php index 1e56b0bbdbf8..923310e88438 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Path/Node/class.ilSimple.php +++ b/components/ILIAS/Export/classes/ImportHandler/Path/Node/Simple.php @@ -18,11 +18,11 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Path\Node; +namespace ILIAS\Export\ImportHandler\Path\Node; -use ILIAS\Export\ImportHandler\I\File\Path\Node\ilSimpleInterface as ilSimpleFilePathNodeInterface; +use ILIAS\Export\ImportHandler\I\Path\Node\SimpleInterface as ilSimpleFilePathNodeInterface; -class ilSimple implements ilSimpleFilePathNodeInterface +class Simple implements ilSimpleFilePathNodeInterface { protected string $node_name; diff --git a/components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilCollection.php b/components/ILIAS/Export/classes/ImportHandler/Schema/Collection.php similarity index 66% rename from components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilCollection.php rename to components/ILIAS/Export/classes/ImportHandler/Schema/Collection.php index f22fc0fe3a20..7203977cb3ca 100644 --- a/components/ILIAS/Export/classes/ImportHandler/File/XML/Schema/class.ilCollection.php +++ b/components/ILIAS/Export/classes/ImportHandler/Schema/Collection.php @@ -18,15 +18,15 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\XML\Schema; +namespace ILIAS\Export\ImportHandler\Schema; -use ILIAS\Export\ImportHandler\I\File\XML\Schema\ilCollectionInterface as ilXMLFileSchemaCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Schema\ilHandlerInterface as ilXMLFileSchemaHandlerInterface; +use ILIAS\Export\ImportHandler\I\Schema\CollectionInterface as ilImportHandlerSchemaCollectionInterface; +use ILIAS\Export\ImportHandler\I\Schema\HandlerInterface as ilImportHandlerSchemaInterface; -class ilCollection implements ilXMLFileSchemaCollectionInterface +class Collection implements ilImportHandlerSchemaCollectionInterface { /** - * @var ilXMLFileSchemaHandlerInterface[] + * @var ilImportHandlerSchemaInterface[] */ protected array $elements; protected int $index; @@ -42,15 +42,17 @@ public function count(): int return count($this->elements); } - public function withElement(ilXMLFileSchemaHandlerInterface $element): ilXMLFileSchemaCollectionInterface - { + public function withElement( + ilImportHandlerSchemaInterface $element + ): ilImportHandlerSchemaCollectionInterface { $clone = clone $this; $clone->elements[] = $element; return $clone; } - public function withMerged(ilXMLFileSchemaCollectionInterface $other): ilXMLFileSchemaCollectionInterface - { + public function withMerged( + ilImportHandlerSchemaCollectionInterface $other + ): ilImportHandlerSchemaCollectionInterface { $clone = clone $this; $clone->elements = array_merge($clone->elements, $other->toArray()); return $clone; @@ -61,7 +63,7 @@ public function toArray(): array return $this->elements; } - public function current(): ilXMLFileSchemaHandlerInterface + public function current(): ilImportHandlerSchemaInterface { return $this->elements[$this->index]; } @@ -78,7 +80,7 @@ public function key(): int public function valid(): bool { - return 0 <= $this->index && $this->index < count($this->elements); + return isset($this->elements[$this->index]); } public function rewind(): void diff --git a/components/ILIAS/Export/classes/ImportHandler/Schema/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Schema/Factory.php new file mode 100644 index 000000000000..9f570497a6b3 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Schema/Factory.php @@ -0,0 +1,109 @@ +import_handler = $import_handler; + $this->data_factory = $data_factory; + $this->logger = $logger; + } + + public function handler(): ilImportHandlerSchemaInterface + { + return new ilImportHandlerSchema( + $this->folder()->handler(), + $this->data_factory, + $this->import_handler->parser(), + $this->import_handler->file()->xsd() + ); + } + + public function collection(): ilImportHandlerSchemaCollectionInterface + { + return new ilImportHandlerSchemaCollection(); + } + + public function folder(): ilImportHandlerSchemaFolderFactoryInterface + { + return new ilImportHandlerSchemaFolderFactory( + $this->import_handler, + $this->logger + ); + } + + public function info(): ilImportHandlerSchemaInfoFactoryInterface + { + return new ilImportHandlerSchemaInfoFactory( + $this->logger + ); + } + + public function collectionFrom( + ilImportHandlerXMLFileInterface $xml_file_handler, + ilImportHandlerPathInterface $path_to_entities + ): ilImportHandlerSchemaCollectionInterface { + $parser_factory = $this->import_handler->parser(); + $path_factory = $this->import_handler->path(); + $path_to_export_node = $path_factory->handler() + ->withStartAtRoot(true) + ->withNode($path_factory->node()->simple()->withName('exp:Export')); + $xml_file_node_info = $parser_factory->DOM()->handler() + ->withFileHandler($xml_file_handler) + ->getNodeInfoAt($path_to_export_node) + ->current(); + $nodes = $parser_factory->DOM()->handler() + ->withFileHandler($xml_file_handler) + ->getNodeInfoAt($path_to_entities); + $collection = $this->import_handler->schema()->collection(); + foreach ($nodes as $node) { + $element = $this->handler() + ->withInformationOf($node); + $collection = $collection + ->withElement($element); + } + return $collection; + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/Schema/Folder/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Schema/Folder/Factory.php new file mode 100644 index 000000000000..c0208ada4514 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Schema/Folder/Factory.php @@ -0,0 +1,49 @@ +import_handler = $import_handler; + $this->logger = $logger; + } + + public function handler(): ilImportHanlderSchemaFolderInterface + { + return new ilImportHanlderSchemaFolder( + $this->import_handler, + $this->logger + ); + } +} diff --git a/components/ILIAS/Export/classes/Schema/class.ilXmlSchemaFactory.php b/components/ILIAS/Export/classes/ImportHandler/Schema/Folder/Handler.php old mode 100755 new mode 100644 similarity index 54% rename from components/ILIAS/Export/classes/Schema/class.ilXmlSchemaFactory.php rename to components/ILIAS/Export/classes/ImportHandler/Schema/Folder/Handler.php index 16067f6aa091..78c893362119 --- a/components/ILIAS/Export/classes/Schema/class.ilXmlSchemaFactory.php +++ b/components/ILIAS/Export/classes/ImportHandler/Schema/Folder/Handler.php @@ -18,42 +18,46 @@ declare(strict_types=1); -namespace ILIAS\Export\Schema; +namespace ILIAS\Export\ImportHandler\Schema\Folder; -use SplFileObject; -use SplFileInfo; +use DirectoryIterator; use ILIAS\Data\Version; +use ILIAS\Export\ImportHandler\I\FactoryInterface as ilImportHandlerFactoryInterface; +use ILIAS\Export\ImportHandler\I\Schema\Folder\HandlerInterface as ilImportHanlderSchemaFolderInterface; +use ILIAS\Export\ImportHandler\I\Schema\Info\CollectionInterface as ilImportHandlerSchemaInfoCollectionInterface; +use ilLogger; +use SplFileInfo; -class ilXmlSchemaFactory +class Handler implements ilImportHanlderSchemaFolderInterface { - private const SCHEMA_DEFINITION_LOCATION = '../components/ILIAS/Export/xml/SchemaValidation'; - - private ilXmlSchemaInfoCollection $collection; + protected ilImportHandlerFactoryInterface $import_handler; + protected const SCHEMA_DEFINITION_LOCATION = '../components/ILIAS/Export/xml/SchemaValidation'; + protected ilImportHandlerSchemaInfoCollectionInterface $collection; + protected ilLogger $logger; - private \ilLogger $logger; - - public function __construct() - { - global $DIC; - - $this->logger = $DIC->logger()->exp(); - $this->collection = new ilXmlSchemaInfoCollection(); + public function __construct( + ilImportHandlerFactoryInterface $import_handler, + ilLogger $logger + ) { + $this->import_handler = $import_handler; + $this->logger = $logger; + $this->collection = $import_handler->schema()->info()->collection(); $this->readSchemaFiles(); } public function getLatest(string $type, string $sub_type = ''): ?SplFileInfo { - $collection = $this->getByType($type, $sub_type); - if ($collection->count() === 0) { + if ($this->collection->count() === 0) { return null; } - $latest = $collection->offsetGet($collection->count() - 1); - return $latest->getFile(); + $this->collection->sortByVersion(); + $this->collection->rewind(); + return $this->collection->current()->getFile(); } public function getByVersion(Version $version, string $type, string $sub_type = ''): ?SplFileInfo { - $collection = $this->getByType($type, $sub_type); + $collection = $this->collection->getByType($type, $sub_type); foreach ($collection as $schema_info) { if ($schema_info->getVersion()->equals($version)) { return $schema_info->getFile(); @@ -64,7 +68,7 @@ public function getByVersion(Version $version, string $type, string $sub_type = public function getByVersionOrLatest(Version $version, string $type, string $sub_type = ''): ?SplFileInfo { - $collection = $this->getByType($type, $sub_type); + $collection = $this->collection->getByType($type, $sub_type); foreach ($collection as $schema_info) { if ($schema_info->getVersion()->equals($version)) { return $schema_info->getFile(); @@ -73,39 +77,9 @@ public function getByVersionOrLatest(Version $version, string $type, string $sub return $this->getLatest($type, $sub_type); } - protected function getByType(string $component, string $sub_type = ''): ilXmlSchemaInfoCollection - { - $collection = new ilXmlSchemaInfoCollection(); - foreach ($this->collection as $schema_info) { - if ($schema_info->getComponent() === $component && $schema_info->getSubtype() === $sub_type) { - $collection[] = $schema_info; - $this->logger->info('Found version: ' . $schema_info->getFile()->getFilename()); - } - } - return $this->sortByVersion($collection); - } - - protected function sortByVersion(ilXmlSchemaInfoCollection $collection): ilXmlSchemaInfoCollection - { - $collection->uasort(function (ilXmlSchemaInfo $a, ilXmlSchemaInfo $b): int { - if ($a->getVersion()->equals($b->getVersion())) { - return 0; - } - if ($a->getVersion()->isGreaterThan($b->getVersion())) { - return 1; - } - return -1; - }); - $sorted = new ilXmlSchemaInfoCollection(); - foreach ($collection as $schema_info) { - $sorted[] = $schema_info; - } - return $sorted; - } - private function readSchemaFiles(): void { - foreach (new \DirectoryIterator(self::SCHEMA_DEFINITION_LOCATION) as $file) { + foreach (new DirectoryIterator(self::SCHEMA_DEFINITION_LOCATION) as $file) { if ($file->isDot()) { $this->logger->debug('Ignoring file (dot file): ' . $file->getFilename()); continue; @@ -129,12 +103,13 @@ private function readSchemaFiles(): void $this->logger->dump($matches, \ilLogLevel::DEBUG); continue; } - $this->collection[] = new ilXmlSchemaInfo( - new SplFileInfo($file->getPathname()), - (string) $matches[1], - (string) $matches[3], - new Version((string) $matches[4] . (($matches[6] ?? '') ? '.' . $matches[6] : '')) - ); + $element = $this->import_handler->schema()->info()->handler() + ->withSplFileInfo(new SplFileInfo($file->getPathname())) + ->withComponent((string) $matches[1]) + ->withSubtype((string) $matches[3]) + ->withVersion(new Version($matches[4] . (($matches[6] ?? '') ? '.' . $matches[6] : ''))); + $this->collection = $this->collection + ->withElement($element); $this->logger->debug($file->getFilename() . ' matches'); } } diff --git a/components/ILIAS/Export/classes/ImportHandler/Schema/Handler.php b/components/ILIAS/Export/classes/ImportHandler/Schema/Handler.php new file mode 100644 index 000000000000..bb38ec2d9865 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Schema/Handler.php @@ -0,0 +1,180 @@ +schema_folder = $schema_folder; + $this->parser_factory = $parser_factory; + $this->xsd_file_factory = $xsd_file_factory; + $this->data_factory = $data_factory; + $this->type = null; + $this->subtype = null; + $this->version = null; + } + + public function getXSDFileHandlerByVersionOrLatest(): null|ilImportHandlerXSDFileInterface + { + if ( + is_null($this->getVersion()) || + is_null($this->getPrimaryType()) || + is_null($this->getSecondaryType()) + ) { + return null; + } + $latest_file_info = $this->schema_folder->getByVersionOrLatest( + $this->getVersion(), + $this->getPrimaryType(), + $this->getSecondaryType() + ); + return is_null($latest_file_info) + ? null + : $this->xsd_file_factory->withFileInfo($latest_file_info); + } + + public function getXSDFileHandlerLatest(): null|ilImportHandlerXSDFileInterface + { + if ( + is_null($this->getPrimaryType()) || + is_null($this->getSecondaryType()) + ) { + return null; + } + $latest_file_info = $this->schema_folder->getLatest( + $this->getPrimaryType(), + $this->getSecondaryType() + ); + return is_null($latest_file_info) + ? null + : $this->xsd_file_factory->withFileInfo($latest_file_info); + } + + public function doesXSDFileWithMatchingVersionExist(): bool + { + if ( + is_null($this->getVersion()) || + is_null($this->getPrimaryType()) || + is_null($this->getSecondaryType()) + ) { + return false; + } + $file_info_with_version = $this->schema_folder->getByVersion( + $this->getVersion(), + $this->getPrimaryType(), + $this->getSecondaryType() + ); + return !is_null($file_info_with_version); + } + + public function withInformationOf( + ilImportHandlerXMLFileNodeInfoInterface $xml_file_node_info + ): ilImportHandlerSchemaInterface { + $type_str = $xml_file_node_info->getValueOfAttribute('Entity'); + $types = str_contains($type_str, '_') + ? explode('_', $type_str) + : [$type_str, '']; + $version_str = $xml_file_node_info->hasAttribute('SchemaVersion') + ? $xml_file_node_info->getValueOfAttribute('SchemaVersion') + : ''; + if ($version_str === '') { + return $this + ->withType($types[0]) + ->withSubType($types[1]); + } + return $this + ->withType($types[0]) + ->withSubType($types[1]) + ->withVersion($this->data_factory->version($version_str)); + } + + public function withType( + string $type + ): ilImportHandlerSchemaInterface { + $clone = clone $this; + $clone->type = $type; + return $clone; + } + + public function withSubType( + string $subtype + ): ilImportHandlerSchemaInterface { + $clone = clone $this; + $clone->subtype = $subtype; + return $clone; + } + + public function withVersion( + Version $version + ): ilImportHandlerSchemaInterface { + $clone = clone $this; + $clone->version = $version; + return $clone; + } + + public function getVersion(): null|Version + { + return $this->version; + } + + public function getPrimaryType(): null|string + { + return $this->type; + } + + public function getSecondaryType(): null|string + { + return $this->subtype; + } + + public function getTypeString(): string + { + if (is_null($this->getPrimaryType())) { + return ''; + } + if (is_null($this->getSecondaryType())) { + return $this->getPrimaryType(); + } + return $this->getPrimaryType() . '_' . $this->getSecondaryType(); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/Schema/Info/Collection.php b/components/ILIAS/Export/classes/ImportHandler/Schema/Info/Collection.php new file mode 100644 index 000000000000..6e7bd30bff92 --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Schema/Info/Collection.php @@ -0,0 +1,110 @@ +elements = []; + $this->index = 0; + $this->logger = $logger; + } + + public function withElement( + ilImportHandlerSchemaInfoInterface $element + ): ilImportHandlerSchemaInfoCollectionInterface { + $clone = clone $this; + $clone->elements[] = $element; + return $clone; + } + + public function sortByVersion(): void + { + uasort($this->elements, function (ilImportHandlerSchemaInfoInterface $a, ilImportHandlerSchemaInfoInterface $b): int { + if ($a->getVersion()->equals($b->getVersion())) { + return 0; + } + if ($a->getVersion()->isGreaterThan($b->getVersion())) { + return 1; + } + return -1; + }); + } + + public function getByType( + string $component, + string $sub_type = '' + ): ilImportHandlerSchemaInfoCollectionInterface { + $collection = clone $this; + $new_elements = []; + foreach ($collection->elements as $schema_info) { + if ($schema_info->getComponent() === $component && $schema_info->getSubtype() === $sub_type) { + $new_elements[] = $schema_info; + $this->logger->info('Found version: ' . $schema_info->getFile()->getFilename()); + } + } + $collection->elements = $new_elements; + return $collection; + } + + public function next(): void + { + $this->index++; + } + + public function rewind(): void + { + $this->index = 0; + } + + public function valid(): bool + { + return isset($this->elements[$this->index]); + } + + public function key(): int + { + return $this->index; + } + + public function current(): ilImportHandlerSchemaInfoInterface + { + return $this->elements[$this->index]; + } + + public function count(): int + { + return count($this->elements); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/Schema/Info/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Schema/Info/Factory.php new file mode 100644 index 000000000000..18d262354f9c --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Schema/Info/Factory.php @@ -0,0 +1,51 @@ +logger = $logger; + } + + public function handler(): ilImportHandlerSchemaInfoInterface + { + return new ilImportHandlerSchemaInfo(); + } + + public function collection(): ilImportHandlerSchemaInfoCollectionInterface + { + return new ilImportHandlerSchemaInfoCollection( + $this->logger + ); + } +} diff --git a/components/ILIAS/Export/classes/Schema/class.ilXmlSchemaInfo.php b/components/ILIAS/Export/classes/ImportHandler/Schema/Info/Handler.php old mode 100755 new mode 100644 similarity index 50% rename from components/ILIAS/Export/classes/Schema/class.ilXmlSchemaInfo.php rename to components/ILIAS/Export/classes/ImportHandler/Schema/Info/Handler.php index 1b64939a1531..a2afee53de08 --- a/components/ILIAS/Export/classes/Schema/class.ilXmlSchemaInfo.php +++ b/components/ILIAS/Export/classes/ImportHandler/Schema/Info/Handler.php @@ -18,12 +18,13 @@ declare(strict_types=1); -namespace ILIAS\Export\Schema; +namespace ILIAS\Export\ImportHandler\Schema\Info; use ILIAS\Data\Version; -use SplFileInfo as SplFileInfo; +use ILIAS\Export\ImportHandler\I\Schema\Info\HandlerInterface as ilImportHandlerSchemaInfoInterface; +use SplFileInfo; -class ilXmlSchemaInfo +class Handler implements ilImportHandlerSchemaInfoInterface { private Version $version; @@ -33,12 +34,36 @@ class ilXmlSchemaInfo private SplFileInfo $file; - public function __construct(SplFileInfo $file, string $component, string $sub_type, Version $version) - { - $this->file = $file; - $this->component = $component; - $this->sub_type = $sub_type; - $this->version = $version; + public function withSplFileInfo( + SplFileInfo $spl_file_info + ): ilImportHandlerSchemaInfoInterface { + $clone = clone $this; + $clone->file = $spl_file_info; + return $clone; + } + + public function withComponent( + string $component + ): ilImportHandlerSchemaInfoInterface { + $clone = clone $this; + $clone->component = $component; + return $clone; + } + + public function withSubtype( + string $sub_type + ): ilImportHandlerSchemaInfoInterface { + $clone = clone $this; + $clone->sub_type = $sub_type; + return $clone; + } + + public function withVersion( + Version $version + ): ilImportHandlerSchemaInfoInterface { + $clone = clone $this; + $clone->version = $version; + return $clone; } public function getFile(): SplFileInfo diff --git a/components/ILIAS/Export/classes/ImportHandler/Validation/Factory.php b/components/ILIAS/Export/classes/ImportHandler/Validation/Factory.php new file mode 100755 index 000000000000..d7ea7a5c6a9b --- /dev/null +++ b/components/ILIAS/Export/classes/ImportHandler/Validation/Factory.php @@ -0,0 +1,62 @@ +import_status_factory = $import_status_factory; + $this->import_handler = $import_handler; + $this->logger = $logger; + } + + public function handler(): ilFileValidationHandlerInterface + { + return new ilFileValidationHandler( + $this->logger, + $this->import_handler->parser(), + $this->import_status_factory, + $this->import_handler->path() + ); + } + + public function set(): ilFileValidationSetFactoryInterface + { + return new ilFileValidationSetFactory(); + } +} diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Validation/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/Validation/Handler.php similarity index 86% rename from components/ILIAS/Export/classes/ImportHandler/File/Validation/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/Validation/Handler.php index b0866f2fe811..fbf61f0a8681 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Validation/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/Validation/Handler.php @@ -18,19 +18,19 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Validation; +namespace ILIAS\Export\ImportHandler\Validation; use DOMDocument; use Exception; -use ILIAS\Export\ImportHandler\I\File\ilHandlerInterface as ilFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Path\ilFactoryInterface as ilFilePathFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\Path\ilHandlerInterface as ilFilePathHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\ilHandlerInterface as ilFileValidationHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilCollectionInterface as ilFileValidationSetCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\XML\ilHandlerInterface as ilXMLFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\Node\Info\ilCollectionInterface as ilXMLFileNodeInfoCollection; -use ILIAS\Export\ImportHandler\I\File\XSD\ilHandlerInterface as ilXSDFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\Parser\ilFactoryInterface as ilParserFactoryInterface; +use ILIAS\Export\ImportHandler\I\File\HandlerInterface as ilFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XML\HandlerInterface as ilXMLFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XSD\HandlerInterface as ilXSDFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\Parser\FactoryInterface as ilParserFactoryInterface; +use ILIAS\Export\ImportHandler\I\Parser\NodeInfo\CollectionInterface as ilXMLFileNodeInfoCollection; +use ILIAS\Export\ImportHandler\I\Path\FactoryInterface as ilFilePathFactoryInterface; +use ILIAS\Export\ImportHandler\I\Path\HandlerInterface as ilFilePathHandlerInterface; +use ILIAS\Export\ImportHandler\I\Validation\HandlerInterface as ilFileValidationHandlerInterface; +use ILIAS\Export\ImportHandler\I\Validation\Set\CollectionInterface as ilFileValidationSetCollectionInterface; use ILIAS\Export\ImportStatus\Exception\ilException as ilImportStatusException; use ILIAS\Export\ImportStatus\I\ilCollectionInterface as ilImportStatusHandlerCollectionInterface; use ILIAS\Export\ImportStatus\I\ilFactoryInterface as ilImportStatusFactoryInterface; @@ -39,7 +39,7 @@ use ilLogger; use LibXMLError; -class ilHandler implements ilFileValidationHandlerInterface +class Handler implements ilFileValidationHandlerInterface { public const TMP_DIR_NAME = 'temp'; public const XML_DIR_NAME = 'xml'; @@ -72,7 +72,7 @@ protected function checkIfFilesExist(array $file_handlers): ilImportStatusHandle { $status_collection = $this->import_status->collection()->withNumberingEnabled(true); foreach ($file_handlers as $file_handler) { - if($file_handler->fileExists()) { + if ($file_handler->fileExists()) { continue; } $status_collection->withAddedStatus($this->import_status->handler() @@ -132,10 +132,10 @@ protected function validateXMLAtNodes( ): ilImportStatusHandlerCollectionInterface { // Check if files exist $status_collection = $this->checkIfFilesExist([$xsd_file_handler]); - if($status_collection->hasStatusType(StatusType::FAILED)) { + if ($status_collection->hasStatusType(StatusType::FAILED)) { return $status_collection; } - if(count($nodes) === 0) { + if (count($nodes) === 0) { return $this->validateEmptyXML($xml_file_handler, $xsd_file_handler); } $old_value = libxml_use_internal_errors(true); @@ -148,7 +148,7 @@ protected function validateXMLAtNodes( $doc->createAttributeNS($namespace->getNamespace(), $namespace->getPrefix()); } try { - if($doc->schemaValidate($xsd_file_handler->getFilePath())) { + if ($doc->schemaValidate($xsd_file_handler->getFilePath())) { continue; } } catch (Exception $e) { @@ -208,7 +208,9 @@ public function validateXMLAtPath( return $this->validateXMLAtNodes( $xml_file_handler, $xsd_file_handler, - $this->parser->DOM()->withFileHandler($xml_file_handler)->getNodeInfoAt($path_handler) + $this->parser->DOM()->handler() + ->withFileHandler($xml_file_handler) + ->getNodeInfoAt($path_handler) ); } diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Validation/Set/class.ilCollection.php b/components/ILIAS/Export/classes/ImportHandler/Validation/Set/Collection.php similarity index 70% rename from components/ILIAS/Export/classes/ImportHandler/File/Validation/Set/class.ilCollection.php rename to components/ILIAS/Export/classes/ImportHandler/Validation/Set/Collection.php index 345cde45374a..9c52e80771b6 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Validation/Set/class.ilCollection.php +++ b/components/ILIAS/Export/classes/ImportHandler/Validation/Set/Collection.php @@ -18,12 +18,12 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Validation\Set; +namespace ILIAS\Export\ImportHandler\Validation\Set; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilCollectionInterface as ilFileValidationSetCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilHandlerInterface as ilFileValidationPairHandlerInterface; +use ILIAS\Export\ImportHandler\I\Validation\Set\CollectionInterface as ilFileValidationSetCollectionInterface; +use ILIAS\Export\ImportHandler\I\Validation\Set\HandlerInterface as ilFileValidationPairHandlerInterface; -class ilCollection implements ilFileValidationSetCollectionInterface +class Collection implements ilFileValidationSetCollectionInterface { /** * @var ilFileValidationPairHandlerInterface[] @@ -42,15 +42,17 @@ public function count(): int return count($this->elements); } - public function withElement(ilFileValidationPairHandlerInterface $element): ilFileValidationSetCollectionInterface - { + public function withElement( + ilFileValidationPairHandlerInterface $element + ): ilFileValidationSetCollectionInterface { $clone = clone $this; $clone->elements[] = $element; return $clone; } - public function withMerged(ilFileValidationSetCollectionInterface $other): ilFileValidationSetCollectionInterface - { + public function withMerged( + ilFileValidationSetCollectionInterface $other + ): ilFileValidationSetCollectionInterface { $clone = clone $this; $clone->elements = array_merge($this->toArray(), $other->toArray()); return $clone; @@ -78,7 +80,7 @@ public function key(): int public function valid(): bool { - return 0 <= $this->index && $this->index < $this->count(); + return isset($this->elements[$this->index]); } public function rewind(): void diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Validation/Set/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/Validation/Set/Factory.php similarity index 56% rename from components/ILIAS/Export/classes/ImportHandler/File/Validation/Set/class.ilFactory.php rename to components/ILIAS/Export/classes/ImportHandler/Validation/Set/Factory.php index de706386f7ed..f4157e2344d1 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Validation/Set/class.ilFactory.php +++ b/components/ILIAS/Export/classes/ImportHandler/Validation/Set/Factory.php @@ -18,15 +18,15 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Validation\Set; +namespace ILIAS\Export\ImportHandler\Validation\Set; -use ILIAS\Export\ImportHandler\File\Validation\Set\ilCollection as ilFileValidationSetCollection; -use ILIAS\Export\ImportHandler\File\Validation\Set\ilHandler as ilFileValidationSetHandler; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilCollectionInterface as ilFileValidationSetCollectionInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilFactoryInterface as ilFileValidationSetFactoryInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilHandlerInterface as ilFileValidationSetInterface; +use ILIAS\Export\ImportHandler\I\Validation\Set\CollectionInterface as ilFileValidationSetCollectionInterface; +use ILIAS\Export\ImportHandler\I\Validation\Set\FactoryInterface as ilFileValidationSetFactoryInterface; +use ILIAS\Export\ImportHandler\I\Validation\Set\HandlerInterface as ilFileValidationSetInterface; +use ILIAS\Export\ImportHandler\Validation\Set\Collection as ilFileValidationSetCollection; +use ILIAS\Export\ImportHandler\Validation\Set\Handler as ilFileValidationSetHandler; -class ilFactory implements ilFileValidationSetFactoryInterface +class Factory implements ilFileValidationSetFactoryInterface { public function handler(): ilFileValidationSetInterface { diff --git a/components/ILIAS/Export/classes/ImportHandler/File/Validation/Set/class.ilHandler.php b/components/ILIAS/Export/classes/ImportHandler/Validation/Set/Handler.php similarity index 61% rename from components/ILIAS/Export/classes/ImportHandler/File/Validation/Set/class.ilHandler.php rename to components/ILIAS/Export/classes/ImportHandler/Validation/Set/Handler.php index d6b78ae363ad..905f0c113662 100755 --- a/components/ILIAS/Export/classes/ImportHandler/File/Validation/Set/class.ilHandler.php +++ b/components/ILIAS/Export/classes/ImportHandler/Validation/Set/Handler.php @@ -18,14 +18,14 @@ declare(strict_types=1); -namespace ILIAS\Export\ImportHandler\File\Validation\Set; +namespace ILIAS\Export\ImportHandler\Validation\Set; -use ILIAS\Export\ImportHandler\I\File\Path\ilHandlerInterface as ilFilePathHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\Validation\Set\ilHandlerInterface as ilFileValidationSetHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XML\ilHandlerInterface as ilXMLFileHandlerInterface; -use ILIAS\Export\ImportHandler\I\File\XSD\ilHandlerInterface as ilXSDFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XML\HandlerInterface as ilXMLFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\File\XSD\HandlerInterface as ilXSDFileHandlerInterface; +use ILIAS\Export\ImportHandler\I\Path\HandlerInterface as ilFilePathHandlerInterface; +use ILIAS\Export\ImportHandler\I\Validation\Set\HandlerInterface as ilFileValidationSetHandlerInterface; -class ilHandler implements ilFileValidationSetHandlerInterface +class Handler implements ilFileValidationSetHandlerInterface { protected ilXSDFileHandlerInterface $xsd_file_handler; protected ilFilePathHandlerInterface $path_handler; @@ -46,22 +46,25 @@ public function getXMLFileHandler(): ilXMLFileHandlerInterface return $this->xml_file_handler; } - public function withFilePathHandler(ilFilePathHandlerInterface $path_handler): ilFileValidationSetHandlerInterface - { + public function withFilePathHandler( + ilFilePathHandlerInterface $path_handler + ): ilFileValidationSetHandlerInterface { $clone = clone $this; $clone->path_handler = $path_handler; return $clone; } - public function withXSDFileHanlder(ilXSDFileHandlerInterface $xsd_file_handler): ilFileValidationSetHandlerInterface - { + public function withXSDFileHanlder( + ilXSDFileHandlerInterface $xsd_file_handler + ): ilFileValidationSetHandlerInterface { $clone = clone $this; $clone->xsd_file_handler = $xsd_file_handler; return $clone; } - public function withXMLFileHandler(ilXMLFileHandlerInterface $xml_file_handler): ilFileValidationSetHandlerInterface - { + public function withXMLFileHandler( + ilXMLFileHandlerInterface $xml_file_handler + ): ilFileValidationSetHandlerInterface { $clone = clone $this; $clone->xml_file_handler = $xml_file_handler; return $clone; diff --git a/components/ILIAS/Export/classes/ImportHandler/class.ilFactory.php b/components/ILIAS/Export/classes/ImportHandler/class.ilFactory.php deleted file mode 100755 index dcb1f25e39d6..000000000000 --- a/components/ILIAS/Export/classes/ImportHandler/class.ilFactory.php +++ /dev/null @@ -1,61 +0,0 @@ -logger = $DIC->logger()->root(); - $this->lng = $DIC->language(); - $this->lng->loadLanguageModule("exp"); - $this->schema_factory = new ilXmlSchemaFactory(); - } - - public function parser(): ilParserFactoryInterface - { - return new ilParserFactory($this->logger); - } - - public function file(): ilFileFactoryInterface - { - return new ilFileFactory( - $this->logger, - $this->lng, - $this->schema_factory - ); - } -} diff --git a/components/ILIAS/Export/classes/Schema/class.ilXmlSchemaInfoCollection.php b/components/ILIAS/Export/classes/Schema/class.ilXmlSchemaInfoCollection.php deleted file mode 100755 index 9e8a836f9663..000000000000 --- a/components/ILIAS/Export/classes/Schema/class.ilXmlSchemaInfoCollection.php +++ /dev/null @@ -1,36 +0,0 @@ -import->file()->xml()->export()->collection(); - $manifest_handlers = $this->import->file()->xml()->manifest()->handlerCollection(); + $manifest_handlers = $this->import->file()->xml()->manifest()->collection(); $statuses = $this->import_status->collection(); // Find export xmls try { @@ -184,19 +184,19 @@ protected function validateXMLFiles(SplFileInfo $manifest_spl): ilImportStatusHa ); // VALIDATE 1st manifest file, can be either export-set or export-file $statuses = $manifest_handlers->validateElements(); - if($statuses->hasStatusType(StatusType::FAILED)) { + if ($statuses->hasStatusType(StatusType::FAILED)) { return $statuses; } // If export set look for the export file manifests + VALIDATE - if ($manifest_handlers->containsExportObjectType(ilExportObjectType::EXPORT_SET)) { + if ($manifest_handlers->containsExportObjectType(ExportObjectType::EXPORT_SET)) { $manifest_handlers = $manifest_handlers->findNextFiles(); $statuses = $manifest_handlers->validateElements(); } - if($statuses->hasStatusType(StatusType::FAILED)) { + if ($statuses->hasStatusType(StatusType::FAILED)) { return $statuses; } // If export file look for the export xmls - if ($manifest_handlers->containsExportObjectType(ilExportObjectType::EXPORT_FILE)) { + if ($manifest_handlers->containsExportObjectType(ExportObjectType::EXPORT_FILE)) { foreach ($manifest_handlers as $manfiest_file_handler) { $export_files = $export_files->withMerged($manfiest_file_handler->findXMLFileHandlers()); } @@ -205,12 +205,12 @@ protected function validateXMLFiles(SplFileInfo $manifest_spl): ilImportStatusHa $this->checkStatuses($e->getStatuses()); } // VALIDATE export xmls - $path_to_export_item_child = $this->import->file()->path()->handler() + $path_to_export_item_child = $this->import->path()->handler() ->withStartAtRoot(true) - ->withNode($this->import->file()->path()->node()->simple()->withName('exp:Export')) - ->withNode($this->import->file()->path()->node()->simple()->withName('exp:ExportItem')) - ->withNode($this->import->file()->path()->node()->anyNode()); - $component_tree = $this->import->file()->xml()->node()->info()->tree(); + ->withNode($this->import->path()->node()->simple()->withName('exp:Export')) + ->withNode($this->import->path()->node()->simple()->withName('exp:ExportItem')) + ->withNode($this->import->path()->node()->anyNode()); + $component_tree = $this->import->parser()->nodeInfo()->tree()->handler(); foreach ($export_files as $export_file) { if ($export_file->isContainerExportXML()) { $component_tree = $component_tree->withRootInFile($export_file, $path_to_export_item_child); @@ -220,7 +220,7 @@ protected function validateXMLFiles(SplFileInfo $manifest_spl): ilImportStatusHa foreach ($export_files as $export_file) { $found_statuses = $export_file->buildValidationSets(); if (!$found_statuses->hasStatusType(StatusType::FAILED)) { - $found_statuses = $this->import->file()->validation()->handler()->validateSets( + $found_statuses = $this->import->validation()->handler()->validateSets( $export_file->getValidationSets() ); } diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Namespace/ilCollectionTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Namespace/ilCollectionTest.php index b654ff097aff..1a1fdc2bdff6 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Namespace/ilCollectionTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Namespace/ilCollectionTest.php @@ -20,9 +20,9 @@ namespace Test\ImportHandler\File\Namespace; -use ILIAS\Export\ImportHandler\File\Namespace\ilCollection as ilFileNamespaceCollection; -use ILIAS\Export\ImportHandler\File\Namespace\ilHandler as ilFileNamespaceHandler; -use ILIAS\Export\ImportHandler\I\File\Namespace\ilCollectionInterface as ilFileNamespaceCollectionInterface; +use ILIAS\Export\ImportHandler\File\Namespace\Collection as ilFileNamespaceCollection; +use ILIAS\Export\ImportHandler\File\Namespace\Handler as ilFileNamespaceHandler; +use ILIAS\Export\ImportHandler\I\File\Namespace\CollectionInterface as ilFileNamespaceCollectionInterface; use PHPUnit\Framework\TestCase; class ilCollectionTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Namespace/ilHandlerTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Namespace/ilHandlerTest.php index ea417671b053..d8cd2bb54a1c 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Namespace/ilHandlerTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Namespace/ilHandlerTest.php @@ -20,7 +20,7 @@ namespace Test\ImportHandler\File\Namespace; -use ILIAS\Export\ImportHandler\File\Namespace\ilHandler as ilFileNamespaceHandler; +use ILIAS\Export\ImportHandler\File\Namespace\Handler as ilFileNamespaceHandler; use PHPUnit\Framework\TestCase; class ilHandlerTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Path/Comparison/ilHandlerTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Path/Comparison/ilHandlerTest.php index 273d2fb61056..3cb8279ffb27 100644 --- a/components/ILIAS/Export/tests/ImportHandler/File/Path/Comparison/ilHandlerTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Path/Comparison/ilHandlerTest.php @@ -20,8 +20,8 @@ namespace Test\ImportHandler\File\Path\Comparison; -use ILIAS\Export\ImportHandler\File\Path\Comparison\ilHandler as ilFilePathComparison; -use ILIAS\Export\ImportHandler\File\Path\Comparison\Operator as ilFilePathComparisonOperator; +use ILIAS\Export\ImportHandler\Path\Comparison\Handler as ilFilePathComparison; +use ILIAS\Export\ImportHandler\Path\Comparison\Operator as ilFilePathComparisonOperator; use PHPUnit\Framework\TestCase; class ilHandlerTest extends TestCase @@ -33,9 +33,16 @@ protected function setUp(): void public function testComparison(): void { - $comp1 = new ilFilePathComparison(ilFilePathComparisonOperator::EQUAL, 'Args'); - $comp2 = new ilFilePathComparison(ilFilePathComparisonOperator::LOWER_EQUAL, ''); - $comp3 = new ilFilePathComparison(ilFilePathComparisonOperator::GREATER, '2'); + $comp1 = new ilFilePathComparison(); + $comp1 = $comp1 + ->withValue('Args') + ->withOperator(ilFilePathComparisonOperator::EQUAL); + $comp2 = $comp1 + ->withOperator(ilFilePathComparisonOperator::LOWER_EQUAL) + ->withValue(''); + $comp3 = $comp1 + ->withOperator(ilFilePathComparisonOperator::GREATER) + ->withValue('2'); $this->assertEquals( ilFilePathComparisonOperator::toString(ilFilePathComparisonOperator::EQUAL) . 'Args', diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAnyElementTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAnyElementTest.php index 551f34e5e827..6cd57d00d6d9 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAnyElementTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAnyElementTest.php @@ -20,7 +20,7 @@ namespace Test\ImportHandler\File\Path\Node; -use ILIAS\Export\ImportHandler\File\Path\Node\ilAnyElement as ilAnyElementFilePathNode; +use ILIAS\Export\ImportHandler\Path\Node\AnyElement as ilAnyElementFilePathNode; use PHPUnit\Framework\TestCase; class ilAnyElementTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAnyNodeTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAnyNodeTest.php index 5b293d51af5e..e86885508c79 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAnyNodeTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAnyNodeTest.php @@ -20,7 +20,7 @@ namespace Test\ImportHandler\File\Path\Node; -use ILIAS\Export\ImportHandler\File\Path\Node\ilAnyNode as ilAnyNodeFilePathNode; +use ILIAS\Export\ImportHandler\Path\Node\AnyNode as ilAnyNodeFilePathNode; use PHPUnit\Framework\TestCase; class ilAnyNodeTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAttributeTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAttributeTest.php index e6f422052b76..9acdcd3286e0 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAttributeTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilAttributeTest.php @@ -20,8 +20,8 @@ namespace Test\ImportHandler\File\Path\Node; -use ILIAS\Export\ImportHandler\File\Path\Comparison\ilHandler as ilFilePathComparisonHandler; -use ILIAS\Export\ImportHandler\File\Path\Node\ilAttribute as ilAttributeFilePathNode; +use ILIAS\Export\ImportHandler\Path\Comparison\Handler as ilFilePathComparisonHandler; +use ILIAS\Export\ImportHandler\Path\Node\Attribute as ilAttributeFilePathNode; use PHPUnit\Framework\TestCase; class ilAttributeTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilCloseRoundBrackedTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilCloseRoundBrackedTest.php index 1880cdf409c1..0d97e615c473 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilCloseRoundBrackedTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilCloseRoundBrackedTest.php @@ -20,7 +20,7 @@ namespace Test\ImportHandler\File\Path\Node; -use ILIAS\Export\ImportHandler\File\Path\Node\ilCloseRoundBracked as ilCloseRoundBrackedFilePathNode; +use ILIAS\Export\ImportHandler\Path\Node\CloseRoundBracked as ilCloseRoundBrackedFilePathNode; use PHPUnit\Framework\TestCase; class ilCloseRoundBrackedTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilIndexTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilIndexTest.php index 8b2b620f8eb0..17105d3a3ea5 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilIndexTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilIndexTest.php @@ -20,8 +20,8 @@ namespace Test\ImportHandler\File\Path\Node; -use ILIAS\Export\ImportHandler\File\Path\Comparison\ilHandler as ilFilePathComparisonHandler; -use ILIAS\Export\ImportHandler\File\Path\Node\ilIndex as ilIndexFilePathNode; +use ILIAS\Export\ImportHandler\Path\Comparison\Handler as ilFilePathComparisonHandler; +use ILIAS\Export\ImportHandler\Path\Node\Index as ilIndexFilePathNode; use PHPUnit\Framework\TestCase; class ilIndexTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilOpenRoundBrackedTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilOpenRoundBrackedTest.php index f0fffaf84f7a..6b87fadae67e 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilOpenRoundBrackedTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilOpenRoundBrackedTest.php @@ -20,7 +20,7 @@ namespace Test\ImportHandler\File\Path\Node; -use ILIAS\Export\ImportHandler\File\Path\Node\ilOpenRoundBracked as ilOpenRoundBrackedFilePathNode; +use ILIAS\Export\ImportHandler\Path\Node\OpenRoundBracked as ilOpenRoundBrackedFilePathNode; use PHPUnit\Framework\TestCase; class ilOpenRoundBrackedTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilSimpleTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilSimpleTest.php index 51841b9b7461..f7943faff424 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilSimpleTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Path/Node/ilSimpleTest.php @@ -20,7 +20,7 @@ namespace Test\ImportHandler\File\Path\Node; -use ILIAS\Export\ImportHandler\File\Path\Node\ilSimple as ilSimpleFilePathNode; +use ILIAS\Export\ImportHandler\Path\Node\Simple as ilSimpleFilePathNode; use PHPUnit\Framework\TestCase; class ilSimpleTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Path/ilHandlerTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Path/ilHandlerTest.php index fd6c6295b02b..dbbff6ea54e5 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Path/ilHandlerTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Path/ilHandlerTest.php @@ -20,8 +20,8 @@ namespace Test\ImportHandler\File\Path; -use ILIAS\Export\ImportHandler\File\Path\ilHandler as ilFilePathHandler; -use ILIAS\Export\ImportHandler\File\Path\Node\ilSimple as ilSimpleFilePathNode; +use ILIAS\Export\ImportHandler\Path\Handler as ilFilePathHandler; +use ILIAS\Export\ImportHandler\Path\Node\Simple as ilSimpleFilePathNode; use PHPUnit\Framework\TestCase; class ilHandlerTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Validation/Set/ilCollectionTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Validation/Set/ilCollectionTest.php index d88a571bc1ed..e7457ac0bdec 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Validation/Set/ilCollectionTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Validation/Set/ilCollectionTest.php @@ -20,8 +20,8 @@ namespace Test\ImportHandler\File\Validation\Set; -use ILIAS\Export\ImportHandler\File\Validation\Set\ilCollection as ilFileValidationSetCollection; -use ILIAS\Export\ImportHandler\File\Validation\Set\ilHandler as ilFileValidationSetHandler; +use ILIAS\Export\ImportHandler\Validation\Set\Collection as ilFileValidationSetCollection; +use ILIAS\Export\ImportHandler\Validation\Set\Handler as ilFileValidationSetHandler; use PHPUnit\Framework\TestCase; class ilCollectionTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/Validation/Set/ilHandlerTest.php b/components/ILIAS/Export/tests/ImportHandler/File/Validation/Set/ilHandlerTest.php index 17be76420a60..5a6babe53349 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/Validation/Set/ilHandlerTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/Validation/Set/ilHandlerTest.php @@ -20,10 +20,10 @@ namespace Test\ImportHandler\File\Validation\Set; -use ILIAS\Export\ImportHandler\File\Path\ilHandler as ilFilePathHandler; -use ILIAS\Export\ImportHandler\File\Validation\Set\ilHandler as ilFileValidationSetHandler; -use ILIAS\Export\ImportHandler\File\XML\ilHandler as ilXMLFileHandler; -use ILIAS\Export\ImportHandler\File\XSD\ilHandler as ilXSDFileHandler; +use ILIAS\Export\ImportHandler\Path\Handler as ilFilePathHandler; +use ILIAS\Export\ImportHandler\Validation\Set\Handler as ilFileValidationSetHandler; +use ILIAS\Export\ImportHandler\File\XML\Handler as ilXMLFileHandler; +use ILIAS\Export\ImportHandler\File\XSD\Handler as ilXSDFileHandler; use PHPUnit\Framework\TestCase; class ilHandlerTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/Attribute/ilCollectionTest.php b/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/Attribute/ilCollectionTest.php index aff379819f7b..04ce46dc50be 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/Attribute/ilCollectionTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/Attribute/ilCollectionTest.php @@ -20,9 +20,9 @@ namespace Test\ImportHandler\File\XML\Node\Info\Attribute; -use ILIAS\Export\ImportHandler\File\XML\Node\Info\Attribute\ilCollection as ilXMLFileNodeInfoAttributeCollection; -use ILIAS\Export\ImportHandler\File\XML\Node\Info\Attribute\ilPair as ilXMLFileNodeInfoAttributePair; -use ILIAS\Export\ImportHandler\File\XML\Node\Info\DOM\ilHandler as ilXMLFileNodeInfoDOMNodeHandler; +use ILIAS\Export\ImportHandler\Parser\NodeInfo\Attribute\Collection as ilXMLFileNodeInfoAttributeCollection; +use ILIAS\Export\ImportHandler\Parser\NodeInfo\Attribute\Handler as ilXMLFileNodeInfoAttributePair; +use ILIAS\Export\ImportHandler\Parser\NodeInfo\DOM\Handler as ilXMLFileNodeInfoDOMNodeHandler; use ilLogger; use PHPUnit\Framework\TestCase; diff --git a/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/Attribute/ilPairTest.php b/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/Attribute/ilPairTest.php index f5b136834a5b..ae399d42ceef 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/Attribute/ilPairTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/Attribute/ilPairTest.php @@ -20,7 +20,7 @@ namespace Test\ImportHandler\File\XML\Node\Info\Attribute; -use ILIAS\Export\ImportHandler\File\XML\Node\Info\Attribute\ilPair as ilXMLFileNodeInfoAttributePair; +use ILIAS\Export\ImportHandler\Parser\NodeInfo\Attribute\Handler as ilXMLFileNodeInfoAttributePair; use PHPUnit\Framework\TestCase; class ilPairTest extends TestCase diff --git a/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/ilCollectionTest.php b/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/ilCollectionTest.php index 5ab7be3fc282..be66a48d2699 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/ilCollectionTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/XML/Node/Info/ilCollectionTest.php @@ -20,19 +20,19 @@ namespace Test\ImportHandler\File\XML\Node\Info; -use ILIAS\Export\ImportHandler\File\XML\Node\Info\DOM\ilHandler; -use ILIAS\Export\ImportHandler\File\XML\Node\Info\ilCollection; +use ILIAS\Export\ImportHandler\Parser\NodeInfo\DOM\Handler; +use ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection; use PHPUnit\Framework\TestCase; class ilCollectionTest extends TestCase { public function testNodeInfoCollection(): void { - $node1 = $this->createMock(ilHandler::class); - $node2 = $this->createMock(ilHandler::class); - $node3 = $this->createMock(ilHandler::class); + $node1 = $this->createMock(Handler::class); + $node2 = $this->createMock(Handler::class); + $node3 = $this->createMock(Handler::class); - $collection = new ilCollection(); + $collection = new Collection(); $collection = $collection->withElement($node1); $collection = $collection->withElement($node2); $collection = $collection->withElement($node3); diff --git a/components/ILIAS/Export/tests/ImportHandler/File/ilHandlerTest.php b/components/ILIAS/Export/tests/ImportHandler/File/ilHandlerTest.php index 83d51283933d..2796e2d3b696 100755 --- a/components/ILIAS/Export/tests/ImportHandler/File/ilHandlerTest.php +++ b/components/ILIAS/Export/tests/ImportHandler/File/ilHandlerTest.php @@ -20,9 +20,9 @@ namespace Test\ImportHandler\File; -use ILIAS\Export\ImportHandler\File\ilHandler as ilFileHandler; -use ILIAS\Export\ImportHandler\File\Namespace\ilCollection as ilFileNamespaceCollection; -use ILIAS\Export\ImportHandler\File\Namespace\ilFactory as ilFileNamespaceFactory; +use ILIAS\Export\ImportHandler\File\Handler as ilFileHandler; +use ILIAS\Export\ImportHandler\File\Namespace\Collection as ilFileNamespaceCollection; +use ILIAS\Export\ImportHandler\File\Namespace\Factory as ilFileNamespaceFactory; use PHPUnit\Framework\TestCase; use SplFileInfo;