ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Component\Resource\OfComponent Class Reference

An public asset that is a resource of some component. More...

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

Public Member Functions

 __construct (protected \ILIAS\Component\Component $component, protected string $source, protected string $target,)
 
 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})?)|(\.htaccess))$%'
 
const REGEXP_TARGET = '%^(((\w|.)+(/(\w|.)+)*)|[.])$%'
 

Detailed Description

An public asset that is a resource of some component.

Definition at line 26 of file OfComponent.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 36 of file OfComponent.php.

40  {
41  if (!preg_match(self::REGEXP_SOURCE, $this->source)) {
42  throw new \InvalidArgumentException(
43  "'{$this->source}' is not a valid source path for a public asset."
44  );
45  }
46  if (!preg_match(self::REGEXP_TARGET, $this->target)) {
47  throw new \InvalidArgumentException(
48  "'{$this->target}' is not a valid target path for a public asset."
49  );
50  }
51  }

Member Function Documentation

◆ getSource()

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

The path of asset relative to the ILIAS base directory.

Implements ILIAS\Component\Resource\PublicAsset.

Definition at line 53 of file OfComponent.php.

53  : string
54  {
55  list($vendor, $component) = explode("\\", get_class($this->component));
56 
57  return "components/$vendor/$component/resources/{$this->source}";
58  }

◆ getTarget()

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

The new path of relative to the ILIAS public directory.

Implements ILIAS\Component\Resource\PublicAsset.

Definition at line 60 of file OfComponent.php.

60  : string
61  {
62  $source = explode("/", $this->source);
63  if ($this->target === ".") {
64  return array_pop($source);
65  }
66  return $this->target . "/" . array_pop($source);
67  }

Field Documentation

◆ REGEXP_SOURCE

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

Definition at line 28 of file OfComponent.php.

◆ REGEXP_TARGET

const ILIAS\Component\Resource\OfComponent::REGEXP_TARGET = '%^(((\w|.)+(/(\w|.)+)*)|[.])$%'

Definition at line 29 of file OfComponent.php.


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