ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ResourceToComponent.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
31 
36 {
39 
40  public function __construct(
41  protected StorableResource $resource,
43  ) {
45  $this->current_revision = $this->resource->getCurrentRevision();
46  $this->revision_to_component = new RevisionToComponent(
47  $this->current_revision,
49  );
50  }
51 
52  public function getAsRowMapping(): \Closure
53  {
54  return function (
55  PresentationRow $row,
56  ResourceIdentification $resource_identification
57  ): PresentationRow {
59  $row = $this->revision_to_component->getAsRowMapping()($row, $resource_identification);
60  return $row
62  ->withContent(
63  $this->ui_factory->listing()->descriptive($this->getCommonProperties())
64  )
65  ->withFurtherFields(
66  $this->getDetailedProperties()
67  );
68  };
69  }
70 
71 
72  public function getAsItem(bool $with_image): Standard
73  {
74  $properties = array_merge(
75  $this->getCommonProperties(),
76  $this->getDetailedProperties()
77  );
78  return $this->revision_to_component->getAsItem($with_image)
79  ->withProperties($properties);
80  }
81 
82  public function getAsCard(): Card
83  {
84  return $this->revision_to_component->getAsCard();
85  }
86 
87  public function getImportantProperties(): array
88  {
89  return array_merge(
90  [],
91  $this->revision_to_component->getImportantProperties()
92  );
93  }
94 
95  public function getCommonProperties(): array
96  {
97  $stakeholders = implode(
98  ', ',
99  array_map(fn(ResourceStakeholder $stakeholder): string => $stakeholder->getConsumerNameForPresentation(), $this->resource->getStakeholders())
100  );
101 
102 
103  return array_merge(
104  [
105  $this->language->txt('stakeholders') => $stakeholders,
106  $this->language->txt('full_size') => $this->formatSize($this->resource->getFullSize()),
107  ],
108  $this->revision_to_component->getCommonProperties()
109  );
110  }
111 
112  public function getDetailedProperties(): array
113  {
114  return array_merge(
115  [
116  $this->language->txt('revisions') => (string) count($this->resource->getAllRevisionsIncludingDraft()),
117  ],
118  $this->revision_to_component->getImportantProperties()
119  );
120  }
121 }
__construct(protected StorableResource $resource, ?ActionGenerator $action_generator=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This describes a Row used in Presentation Table.
withImportantFields(array $fields)
Get a row like this with the record-fields and labels to be shown in the collapsed row...
__construct(Container $dic, ilPlugin $plugin)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41