ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Component\Resource\NodeModule Class Reference

Some distributable file created by npm. More...

+ Inheritance diagram for ILIAS\Component\Resource\NodeModule:
+ Collaboration diagram for ILIAS\Component\Resource\NodeModule:

Public Member Functions

 __construct (protected string $source)
 
 getSource ()
 The path of asset relative to the ILIAS base directory. More...
 
 getTarget ()
 The new path of relative to the ILIAS public directory. More...
 

Data Fields

const REGEXP_SOURCE = '%^(((\w|.)+(/(\w|.)+)*\.\w{2,4}))$%'
 

Detailed Description

Some distributable file created by npm.

Definition at line 26 of file NodeModule.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Component\Resource\NodeModule::__construct ( protected string  $source)
Parameters
$componentthis belongs to
$targetpath relative to the ILIAS public directory, filename of resource will be appended. Use one dot for toplevel.

Definition at line 34 of file NodeModule.php.

36  {
37  if (!preg_match(self::REGEXP_SOURCE, $this->source)) {
38  throw new \InvalidArgumentException(
39  "'{$this->source}' is not a valid source path for a public asset."
40  );
41  }
42  }

Member Function Documentation

◆ getSource()

ILIAS\Component\Resource\NodeModule::getSource ( )

The path of asset relative to the ILIAS base directory.

Implements ILIAS\Component\Resource\PublicAsset.

Definition at line 44 of file NodeModule.php.

44  : string
45  {
46  return "node_modules/{$this->source}";
47  }

◆ getTarget()

ILIAS\Component\Resource\NodeModule::getTarget ( )

The new path of relative to the ILIAS public directory.

Implements ILIAS\Component\Resource\PublicAsset.

Definition at line 49 of file NodeModule.php.

References ILIAS\Component\Resource\ComponentJS\TARGET, and ILIAS\Component\Resource\ComponentCSS\TARGET.

49  : string
50  {
51  $source = explode("/", $this->source);
52  if (str_ends_with($this->source, ".js")) {
53  return ComponentJS::TARGET . "/" . array_pop($source);
54  }
55  if (str_ends_with($this->source, ".css")) {
56  return ComponentCSS::TARGET . "/" . array_pop($source);
57  }
58  throw new \LogicException("Don't know where to put {$this->source}");
59  }

Field Documentation

◆ REGEXP_SOURCE

const ILIAS\Component\Resource\NodeModule::REGEXP_SOURCE = '%^(((\w|.)+(/(\w|.)+)*\.\w{2,4}))$%'

Definition at line 28 of file NodeModule.php.


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