Skip to content

Commit e98d401

Browse files
committed
Add all public non-internal static functions to contracts.
Add test to ensure this.
1 parent 5252fe3 commit e98d401

File tree

5 files changed

+410
-119
lines changed

5 files changed

+410
-119
lines changed
Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Models\DataObject;
5+
6+
use Exception;
7+
use Pimcore\Model\Asset;
8+
use Pimcore\Model\DataObject\AbstractObject;
9+
use Pimcore\Model\DataObject\ClassDefinition;
10+
use Pimcore\Model\DataObject\ClassDefinition\Data;
11+
use Pimcore\Model\DataObject\ClassDefinition\Layout;
12+
use Pimcore\Model\DataObject\Concrete;
13+
use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData as FieldCollectionData;
14+
use Pimcore\Model\DataObject\Folder;
15+
use Pimcore\Model\DataObject\Objectbrick\Data\AbstractData as ObjectBrickData;
16+
use Pimcore\Model\DataObject\Service;
17+
use Pimcore\Model\Document;
18+
use Pimcore\Model\Element\ElementInterface;
19+
use Pimcore\Model\UserInterface;
20+
use Pimcore\Model\DataObject\Fieldcollection;
21+
use Pimcore\Model\DataObject\Objectbrick;
22+
use Pimcore\Model;
23+
24+
class DataObjectServiceResolverContract implements DataObjectServiceResolverContractInterface
25+
{
26+
27+
public function useInheritedValues(bool $inheritValues, callable $fn, array $fnArgs = []): mixed
28+
{
29+
return Service::useInheritedValues($inheritValues, $fn, $fnArgs);
30+
}
31+
32+
public function rewriteIds(AbstractObject $object, array $rewriteConfig, array $params = []): AbstractObject
33+
{
34+
return Service::rewriteIds($object, $rewriteConfig, $params);
35+
}
36+
37+
/**
38+
* @throws Exception
39+
*/
40+
public function createFolderByPath(string $path, array $options = []): Folder
41+
{
42+
return Service::createFolderByPath($path, $options);
43+
}
44+
45+
public function pathExists(string $path, ?string $type = null): bool
46+
{
47+
return Service::pathExists($path, $type);
48+
}
49+
50+
/**
51+
* @param Data[] $targetList
52+
*/
53+
public function extractFieldDefinitions(
54+
Data|Layout $layout,
55+
string $targetClass,
56+
array $targetList,
57+
bool $insideDataType
58+
): array
59+
{
60+
61+
return Service::extractFieldDefinitions($layout, $targetClass, $targetList, $insideDataType);
62+
}
63+
64+
public function getSuperLayoutDefinition(Concrete $object): mixed
65+
{
66+
67+
return Service::getSuperLayoutDefinition($object);
68+
}
69+
70+
public function createSuperLayout(Data|Layout $layout): void
71+
{
72+
Service::createSuperLayout($layout);
73+
}
74+
75+
/**
76+
* @return Concrete[]
77+
*/
78+
public function getObjectsReferencingUser(int $userId): array
79+
{
80+
return Service::getObjectsReferencingUser($userId);
81+
}
82+
83+
public function getLanguagePermissions(
84+
FieldCollectionData|ObjectBrickData|AbstractObject $object,
85+
UserInterface $user,
86+
string $type
87+
): ?array
88+
{
89+
return Service::getLanguagePermissions($object, $user, $type);
90+
}
91+
92+
public function calculateCellValue(
93+
AbstractObject $object,
94+
array $helperDefinitions,
95+
string $key,
96+
array $context = []
97+
): mixed
98+
{
99+
return Service::calculateCellValue($object, $helperDefinitions, $key, $context);
100+
}
101+
102+
public function getLayoutPermissions(string $classId, ?array $permissionSet = null): ?array
103+
{
104+
return Service::getLayoutPermissions($classId, $permissionSet);
105+
}
106+
107+
public function getFieldForBrickType(ClassDefinition $class, string $bricktype): int|string|null
108+
{
109+
return Service::getFieldForBrickType($class, $bricktype);
110+
}
111+
112+
public function hasInheritableParentObject(Concrete $object): ?Concrete
113+
{
114+
return Service::hasInheritableParentObject($object);
115+
}
116+
117+
public function loadAllObjectFields(AbstractObject $object): void
118+
{
119+
Service::loadAllObjectFields($object);
120+
}
121+
122+
public function getOptionsForSelectField(
123+
string|Concrete $object,
124+
ClassDefinition\Data\Multiselect|ClassDefinition\Data\Select|string $definition
125+
): array
126+
{
127+
return Service::getOptionsForSelectField($object, $definition);
128+
}
129+
130+
public function getOptionsForMultiSelectField(
131+
string|Concrete $object,
132+
ClassDefinition\Data\Multiselect|ClassDefinition\Data\Select|string $fieldname
133+
): array
134+
{
135+
return Service::getOptionsForMultiSelectField($object, $fieldname);
136+
}
137+
138+
public function getValidLayouts(Concrete $object): array
139+
{
140+
return Service::getValidLayouts($object);
141+
}
142+
143+
public function synchronizeCustomLayout(ClassDefinition\CustomLayout $customLayout): void
144+
{
145+
Service::synchronizeCustomLayout($customLayout);
146+
}
147+
148+
public function cloneDefinition(mixed $definition): mixed
149+
{
150+
return Service::cloneDefinition($definition);
151+
}
152+
153+
public function getUniqueKey(ElementInterface $element, int $nr = 0): string
154+
{
155+
return Service::getUniqueKey($element, $nr);
156+
}
157+
158+
public function getCalculatedFieldValue(
159+
Fieldcollection\Data\AbstractData|Objectbrick\Data\AbstractData|Concrete $object,
160+
?Data\CalculatedValue $data
161+
): mixed
162+
{
163+
return Service::getCalculatedFieldValue($object, $data);
164+
}
165+
166+
public function getSystemFields(): array
167+
{
168+
return Service::getSystemFields();
169+
}
170+
171+
public function doResetDirtyMap(Model\AbstractModel $container, ClassDefinition|ClassDefinition\Data $fd): void
172+
{
173+
Service::doResetDirtyMap($container, $fd);
174+
}
175+
176+
public function recursiveResetDirtyMap(
177+
Model\AbstractModel $container,
178+
ClassDefinition|ClassDefinition\Data $fd
179+
): void
180+
{
181+
Service::doResetDirtyMap($container, $fd);
182+
}
183+
184+
public function getVersionDependentDatabaseColumnName(string $fieldName): string
185+
{
186+
return Service::getVersionDependentDatabaseColumnName($fieldName);
187+
}
188+
189+
public function doHideUnpublished(?ElementInterface $element): bool
190+
{
191+
return Service::doHideUnpublished($element);
192+
}
193+
194+
public function getElementByPath(string $type, string $path): ?ElementInterface
195+
{
196+
return Service::getElementByPath($type, $path);
197+
}
198+
199+
public function getSafeCopyName(string $sourceKey, ElementInterface $target): string
200+
{
201+
return Service::getSafeCopyName($sourceKey, $target);
202+
}
203+
204+
public function getElementById(string $type, int|string $id, array $params = []): Asset|Document|AbstractObject|null
205+
{
206+
return Service::getElementById($type, $id, $params);
207+
}
208+
209+
public function getElementType(ElementInterface $element): ?string
210+
{
211+
return Service::getElementType($element);
212+
}
213+
214+
public function getValidKey(string $key, string $type): string
215+
{
216+
return Service::getValidKey($key, $type);
217+
}
218+
219+
public function isValidKey(string $key, string $type): bool
220+
{
221+
return Service::isValidKey($key, $type);
222+
}
223+
224+
public function isValidPath(string $path, string $type): bool
225+
{
226+
return Service::isValidPath($path, $type);
227+
}
228+
229+
public function cloneMe(ElementInterface $element): ElementInterface
230+
{
231+
return Service::cloneMe($element);
232+
}
233+
234+
public function cloneProperties(mixed $properties): mixed
235+
{
236+
return Service::cloneProperties($properties);
237+
}
238+
239+
public function getElementFromSession(
240+
string $type,
241+
int $elementId,
242+
string $sessionId,
243+
?string $postfix = ''
244+
): Asset|Document|AbstractObject|null
245+
{
246+
return Service::getElementFromSession($type, $elementId, $sessionId, $postfix);
247+
}
248+
249+
public function locateDaoClass(string $modelClass): ?string
250+
{
251+
return Service::locateDaoClass($modelClass);
252+
}
253+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Models\DataObject;
5+
6+
use Exception;
7+
use Pimcore\Model;
8+
use Pimcore\Model\Asset;
9+
use Pimcore\Model\DataObject\AbstractObject;
10+
use Pimcore\Model\DataObject\ClassDefinition;
11+
use Pimcore\Model\DataObject\ClassDefinition\Data;
12+
use Pimcore\Model\DataObject\ClassDefinition\Layout;
13+
use Pimcore\Model\DataObject\Concrete;
14+
use Pimcore\Model\DataObject\Fieldcollection;
15+
use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData as FieldCollectionData;
16+
use Pimcore\Model\DataObject\Folder;
17+
use Pimcore\Model\DataObject\Objectbrick;
18+
use Pimcore\Model\DataObject\Objectbrick\Data\AbstractData as ObjectBrickData;
19+
use Pimcore\Model\Document;
20+
use Pimcore\Model\Element\ElementInterface;
21+
use Pimcore\Model\UserInterface;
22+
23+
interface DataObjectServiceResolverContractInterface
24+
{
25+
public function useInheritedValues(bool $inheritValues, callable $fn, array $fnArgs = []): mixed;
26+
27+
public function rewriteIds(AbstractObject $object, array $rewriteConfig, array $params = []): AbstractObject;
28+
29+
/**
30+
* @throws Exception
31+
*/
32+
public function createFolderByPath(string $path, array $options = []): Folder;
33+
34+
public function pathExists(string $path, ?string $type = null): bool;
35+
36+
/**
37+
* @param Data[] $targetList
38+
*/
39+
public function extractFieldDefinitions(
40+
Data|Layout $layout, string $targetClass, array $targetList, bool $insideDataType
41+
): array;
42+
43+
public function getSuperLayoutDefinition(Concrete $object): mixed;
44+
45+
public function createSuperLayout(Data|Layout $layout): void;
46+
47+
/**
48+
* @return Concrete[]
49+
*/
50+
public function getObjectsReferencingUser(int $userId): array;
51+
52+
public function getLanguagePermissions(
53+
FieldCollectionData|ObjectBrickData|AbstractObject $object,
54+
UserInterface $user,
55+
string $type
56+
): ?array;
57+
58+
public function calculateCellValue(
59+
AbstractObject $object,
60+
array $helperDefinitions,
61+
string $key,
62+
array $context = []
63+
): mixed;
64+
65+
public function getLayoutPermissions(string $classId, ?array $permissionSet = null): ?array;
66+
67+
public function getFieldForBrickType(ClassDefinition $class, string $bricktype): int|string|null;
68+
69+
public function hasInheritableParentObject(Concrete $object): ?Concrete;
70+
71+
public function loadAllObjectFields(AbstractObject $object): void;
72+
73+
public function getOptionsForSelectField(
74+
string|Concrete $object,
75+
ClassDefinition\Data\Multiselect|ClassDefinition\Data\Select|string $definition
76+
): array;
77+
78+
public function getOptionsForMultiSelectField(
79+
string|Concrete $object,
80+
ClassDefinition\Data\Multiselect|ClassDefinition\Data\Select|string $fieldname
81+
): array;
82+
83+
public function getValidLayouts(Concrete $object): array;
84+
85+
public function synchronizeCustomLayout(ClassDefinition\CustomLayout $customLayout): void;
86+
87+
public function cloneDefinition(mixed $definition): mixed;
88+
89+
public function getUniqueKey(ElementInterface $element, int $nr = 0): string;
90+
91+
public function getCalculatedFieldValue(
92+
Fieldcollection\Data\AbstractData|Objectbrick\Data\AbstractData|Concrete $object,
93+
?Data\CalculatedValue $data
94+
): mixed;
95+
96+
public function getSystemFields(): array;
97+
98+
public function doResetDirtyMap(Model\AbstractModel $container, ClassDefinition|ClassDefinition\Data $fd): void;
99+
100+
public function recursiveResetDirtyMap(Model\AbstractModel $container, ClassDefinition|ClassDefinition\Data $fd
101+
): void;
102+
103+
public function getVersionDependentDatabaseColumnName(string $fieldName): string;
104+
105+
public function doHideUnpublished(?ElementInterface $element): bool;
106+
107+
public function getElementByPath(string $type, string $path): ?ElementInterface;
108+
109+
public function getSafeCopyName(string $sourceKey, ElementInterface $target): string;
110+
111+
public function getElementById(string $type, int|string $id, array $params = []
112+
): Asset|Document|AbstractObject|null;
113+
114+
public function getElementType(ElementInterface $element): ?string;
115+
116+
public function getValidKey(string $key, string $type): string;
117+
118+
public function isValidKey(string $key, string $type): bool;
119+
120+
public function isValidPath(string $path, string $type): bool;
121+
122+
public function cloneMe(ElementInterface $element): ElementInterface;
123+
124+
public function cloneProperties(mixed $properties): mixed;
125+
126+
public function getElementFromSession(string $type, int $elementId, string $sessionId, ?string $postfix = ''
127+
): Asset|Document|AbstractObject|null;
128+
129+
public function locateDaoClass(string $modelClass): ?string;
130+
}

0 commit comments

Comments
 (0)