ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
StyleManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29
31{
32 protected StyleRepo $repo;
33 public function __construct(
34 protected InternalDataService $data,
36 protected InternalDomainService $domain,
37 protected ResourceStakeholder $stakeholder,
38 protected int $style_id
39 ) {
40 $this->repo = $repo->style();
41 }
42
43 public function createRid(): string
44 {
45 return $this->repo->getOrCreateRid(
46 $this->style_id,
47 $this->stakeholder
48 );
49 }
50
51 public function writeCss(): bool
52 {
53 if ($this->isMigrated()) {
54 $builder = $this->domain->cssBuilder(
55 new \ilObjStyleSheet($this->style_id)
56 );
57 $css = $builder->getCss();
58 $this->repo->writeCss(
59 $this->style_id,
60 $css,
61 $this->stakeholder
62 );
63 $this->repo->saveUpToDate(
64 $this->style_id,
65 true
66 );
67 return true;
68 }
69 return false;
70 }
71
72 public function getPath(
73 bool $add_random = true,
74 bool $add_token = true
75 ): string {
76 return $this->repo->getPath(
77 $this->style_id,
78 $add_random,
79 $add_token
80 );
81 }
82
84 {
85 return $this->repo->getResourceIdentification($this->style_id);
86 }
87
89 string $local_zip_path
90 ): string {
91 return $this->repo->createContainerFromLocalZip(
92 $this->style_id,
93 $local_zip_path,
94 $this->stakeholder
95 );
96 }
97
99 string $local_dir_path,
100 string $container_path = "",
101 bool $recursive = true
102 ): string {
103 return $this->repo->createContainerFromLocalDir(
104 $this->style_id,
105 $local_dir_path,
106 $this->stakeholder,
107 $container_path,
108 $recursive
109 );
110 }
111
112 public function importFromUploadResult(
113 UploadResult $result,
114 ): int {
115 $imp = new \ilImport();
116 return $imp->importObject(
117 null,
118 $result->getPath(),
119 $result->getName(),
120 "sty",
121 "",
122 true
123 );
124 }
125
126 public function cloneResourceContainer(
127 int $from_style_id
128 ): void {
129 $this->repo->cloneResourceContainer(
130 $from_style_id,
131 $this->style_id
132 );
133 }
134
135 public function isMigrated(): bool
136 {
137 return ((string) $this->repo->getResourceIdentification($this->style_id)
138 !== "");
139 }
140
141 public function migrateImages(
142 ): void {
143 $this->repo->migrateImages($this->style_id);
144 }
145
146}
getPath(bool $add_random=true, bool $add_token=true)
importFromUploadResult(UploadResult $result,)
createContainerFromLocalZip(string $local_zip_path)
createContainerFromLocalDir(string $local_dir_path, string $container_path="", bool $recursive=true)
cloneResourceContainer(int $from_style_id)
__construct(protected InternalDataService $data, InternalRepoService $repo, protected InternalDomainService $domain, protected ResourceStakeholder $stakeholder, protected int $style_id)
Import class.
importObject(?object $a_new_obj, string $a_tmp_file, string $a_filename, string $a_type, string $a_comp="", bool $a_copy_file=false)
Class ilObjStyleSheet.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...