ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\MetaData\Presentation\Elements Class Reference
+ Inheritance diagram for ILIAS\MetaData\Presentation\Elements:
+ Collaboration diagram for ILIAS\MetaData\Presentation\Elements:

Public Member Functions

 __construct (UtilitiesInterface $utilities,)
 
 name (BaseElementInterface $element, bool $plural=false)
 
 nameWithParents (BaseElementInterface $element, ?BaseElementInterface $cut_off=null, bool $plural=false, bool $skip_initial=false)
 

Protected Member Functions

 camelCaseToSnakeCase (string $string)
 

Protected Attributes

const string SEPARATOR = ': '
 
UtilitiesInterface $utilities
 

Detailed Description

Definition at line 30 of file Elements.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\Presentation\Elements::__construct ( UtilitiesInterface  $utilities)

Definition at line 36 of file Elements.php.

References ILIAS\MetaData\Presentation\Elements\$utilities.

38  {
39  $this->utilities = $utilities;
40  }

Member Function Documentation

◆ camelCaseToSnakeCase()

ILIAS\MetaData\Presentation\Elements::camelCaseToSnakeCase ( string  $string)
protected

Definition at line 89 of file Elements.php.

Referenced by ILIAS\MetaData\Presentation\Elements\name().

89  : string
90  {
91  $string = preg_replace('/(?<=[a-z])(?=[A-Z])/', '_', $string);
92  return strtolower($string);
93  }
+ Here is the caller graph for this function:

◆ name()

ILIAS\MetaData\Presentation\Elements::name ( BaseElementInterface  $element,
bool  $plural = false 
)

Implements ILIAS\MetaData\Presentation\ElementsInterface.

Definition at line 42 of file Elements.php.

References ILIAS\MetaData\Presentation\Elements\camelCaseToSnakeCase(), and ILIAS\MetaData\Elements\Base\BaseElementInterface\getDefinition().

Referenced by ILIAS\MetaData\Presentation\Elements\nameWithParents().

45  : string {
46  $name = $element->getDefinition()->name();
47  $exceptions = [
48  'metadataSchema' => 'metadatascheme', 'lifeCycle' => 'lifecycle',
49  'otherPlatformRequirements' => 'otherPlattformRequirements'
50  ];
51  $name = $exceptions[$name] ?? $name;
52 
53  $lang_key = 'meta_' . $this->camelCaseToSnakeCase($name);
54  if ($plural) {
55  $lang_key .= '_plural';
56  }
57  return $this->utilities->txt($lang_key);
58  }
camelCaseToSnakeCase(string $string)
Definition: Elements.php:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nameWithParents()

ILIAS\MetaData\Presentation\Elements::nameWithParents ( BaseElementInterface  $element,
?BaseElementInterface  $cut_off = null,
bool  $plural = false,
bool  $skip_initial = false 
)

Implements ILIAS\MetaData\Presentation\ElementsInterface.

Definition at line 60 of file Elements.php.

References ILIAS\MetaData\Elements\Base\BaseElementInterface\getSuperElement(), and ILIAS\MetaData\Presentation\Elements\name().

65  : string {
66  $names = [];
67  $el = $element;
68 
69  $initial = true;
70  while (!$el->isRoot()) {
71  if ($el === $cut_off) {
72  break;
73  }
74  if ($initial && $skip_initial) {
75  $el = $el->getSuperElement();
76  $initial = false;
77  continue;
78  }
79  array_unshift($names, $this->name($el, $initial && $plural));
80  $el = $el->getSuperElement();
81  $initial = false;
82  }
83  if (empty($names)) {
84  return $this->name($element, $plural);
85  }
86  return implode(self::SEPARATOR, $names);
87  }
name(BaseElementInterface $element, bool $plural=false)
Definition: Elements.php:42
+ Here is the call graph for this function:

Field Documentation

◆ $utilities

UtilitiesInterface ILIAS\MetaData\Presentation\Elements::$utilities
protected

Definition at line 34 of file Elements.php.

Referenced by ILIAS\MetaData\Presentation\Elements\__construct().

◆ SEPARATOR

const string ILIAS\MetaData\Presentation\Elements::SEPARATOR = ': '
protected

Definition at line 32 of file Elements.php.


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