ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ResourceToComponent.php
Go to the documentation of this file.
1<?php
2
19declare(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
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(
67 );
68 };
69 }
70
71
72 public function getAsItem(bool $with_image): Standard
73 {
74 $properties = array_merge(
75 $this->getCommonProperties(),
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)
This describes a Standard Dropdown.
Definition: Standard.php:27
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)
@inheritDoc