ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ZipStructureMachine.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
30
36{
37 public function __construct()
38 {
39 }
40
41 public function getId(): string
42 {
43 return 'zip_structure_reader';
44 }
45
46 public function canHandleDefinition(FlavourDefinition $definition): bool
47 {
48 return $definition instanceof ZipStructureDefinition;
49 }
50
51 public function dependsOnEngine(): ?string
52 {
53 return NoEngine::class;
54 }
55
56 public function withEngine(Engine $engine): FlavourMachine
57 {
58 return $this;
59 }
60
61 public function getEngine(): Engine
62 {
63 return new NoEngine();
64 }
65
66 public function processStream(
67 FileInformation $information,
68 FileStream $stream,
69 FlavourDefinition $for_definition
70 ): \Generator {
71 if (!$for_definition instanceof ZipStructureDefinition) {
72 throw new \InvalidArgumentException('Invalid definition');
73 }
74 $reader = new ZipReader($stream);
75
76 $data = $reader->getStructure();
77
78 yield new Result(
79 $for_definition,
80 Streams::ofString($for_definition->sleep($data)),
81 0,
82 $for_definition->persist()
83 );
84 }
85
86}
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Definition: Streams.php:32
withEngine(Engine $engine)
The demanded Engine will be passed here.
canHandleDefinition(FlavourDefinition $definition)
Check if a corresponding configuration can be processed by this Machine.
__construct()
FlavourMachines must be able to be created without further dependencies.
dependsOnEngine()
Return the class name of the Engine that is required for this Machine to work.
processStream(FileInformation $information, FileStream $stream, FlavourDefinition $for_definition)
The base interface for all filesystem streams.
Definition: FileStream.php:32
if(!file_exists('../ilias.ini.php'))