ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ZipStructureMachine Class Reference
+ Inheritance diagram for ZipStructureMachine:
+ Collaboration diagram for ZipStructureMachine:

Public Member Functions

 __construct ()
 FlavourMachines must be able to be created without further dependencies. More...
 
 getId ()
 
 canHandleDefinition (FlavourDefinition $definition)
 Check if a corresponding configuration can be processed by this Machine. More...
 
 dependsOnEngine ()
 Return the class name of the Engine that is required for this Machine to work. More...
 
 withEngine (Engine $engine)
 The demanded Engine will be passed here. More...
 
 getEngine ()
 
 processStream (FileInformation $information, FileStream $stream, FlavourDefinition $for_definition)
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 35 of file ZipStructureMachine.php.

Constructor & Destructor Documentation

◆ __construct()

ZipStructureMachine::__construct ( )

FlavourMachines must be able to be created without further dependencies.

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 37 of file ZipStructureMachine.php.

38  {
39  }

Member Function Documentation

◆ canHandleDefinition()

ZipStructureMachine::canHandleDefinition ( FlavourDefinition  $definition)

Check if a corresponding configuration can be processed by this Machine.

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 46 of file ZipStructureMachine.php.

46  : bool
47  {
48  return $definition instanceof ZipStructureDefinition;
49  }

◆ dependsOnEngine()

ZipStructureMachine::dependsOnEngine ( )

Return the class name of the Engine that is required for this Machine to work.

Returning null will result in a NullEngine passed to the Machine.

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 51 of file ZipStructureMachine.php.

51  : ?string
52  {
53  return NoEngine::class;
54  }

◆ getEngine()

ZipStructureMachine::getEngine ( )

◆ getId()

ZipStructureMachine::getId ( )
Returns
string max. 64 characters, MUST be unique and NOT a class-related magic-constant. E.g. you can generate a random one with $ php -r"echo hash('sha256', uniqid());" | pbcopy in your shell and paste string in your getId() implementation.

If you ever change the ID, FlavourDefinitions may no longer process anything with your machine that previously designated you as the processing machine.

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 41 of file ZipStructureMachine.php.

41  : string
42  {
43  return 'zip_structure_reader';
44  }

◆ processStream()

ZipStructureMachine::processStream ( FileInformation  $information,
FileStream  $stream,
FlavourDefinition  $for_definition 
)
Parameters
FileInformation$informationof the original File.
FileStream$streamof the original File.
FlavourDefinition$for_definitionthe definition for which the stream should be processed.
Returns
Result[]| For each "thing" that the machine generates, a result can be returned. E.g. when extracting 5 images from a PDF, 5 results are returned (Generator).

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 66 of file ZipStructureMachine.php.

References $data, and ILIAS\ResourceStorage\Flavour\Definition\FlavourDefinition\persist().

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  }
persist()
Define whether the generated flavor and the respective streams should be persisted, or whether they should only be generated and used in-memory.
+ Here is the call graph for this function:

◆ withEngine()

ZipStructureMachine::withEngine ( Engine  $engine)

The demanded Engine will be passed here.

If the Machine does not depend on an Engine, a NullEngine

Implements ILIAS\ResourceStorage\Flavour\Machine\FlavourMachine.

Definition at line 56 of file ZipStructureMachine.php.


The documentation for this class was generated from the following file: