Skip to content

Commit dc1a88b

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

25 files changed

+671
-172
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Models\DataObject;
5+
6+
use Exception;
7+
use Pimcore\Model\DataObject\ClassDefinition;
8+
9+
class ClassDefinitionResolverContract implements ClassDefinitionResolverContractInterface
10+
{
11+
12+
/**
13+
* @throws Exception
14+
*/
15+
public function getById(string $id, bool $force = false): ?ClassDefinition
16+
{
17+
return ClassDefinition::getById($id, $force);
18+
}
19+
20+
/**
21+
* @throws Exception
22+
*/
23+
public function getByName(string $name): ?ClassDefinition
24+
{
25+
return ClassDefinition::getByName($name);
26+
}
27+
28+
public function create(array $values = []): ClassDefinition
29+
{
30+
return ClassDefinition::create($values);
31+
}
32+
33+
public function getByIdIgnoreCase(string $id): ClassDefinition|null
34+
{
35+
return ClassDefinition::getByIdIgnoreCase($id);
36+
}
37+
38+
public function locateDaoClass(string $modelClass): ?string
39+
{
40+
return ClassDefinition::locateDaoClass($modelClass);
41+
}
42+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Models\DataObject;
5+
6+
use Exception;
7+
use Pimcore\Model\DataObject\ClassDefinition;
8+
9+
interface ClassDefinitionResolverContractInterface
10+
{
11+
/**
12+
* @throws Exception
13+
*/
14+
public function getById(string $id, bool $force = false): ?ClassDefinition;
15+
16+
/**
17+
* @throws Exception
18+
*/
19+
public function getByName(string $name): ?ClassDefinition;
20+
21+
public function create(array $values = []): ClassDefinition;
22+
23+
public function getByIdIgnoreCase(string $id): ClassDefinition|null;
24+
25+
public function locateDaoClass(string $modelClass): ?string;
26+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Models\DataObject;
5+
6+
use Pimcore\Model\DataObject\ClassDefinition;
7+
use Pimcore\Model\DataObject\ClassDefinition\CustomLayout;
8+
use Pimcore\Model\DataObject\ClassDefinition\Service;
9+
use Pimcore\Model\DataObject\Fieldcollection\Definition as FCDefinition;
10+
use Pimcore\Model\DataObject\ObjectBrick\Definition as OBDefinition;
11+
12+
class ClassDefinitionServiceResolverContract implements ClassDefinitionServiceResolverContractInterface
13+
{
14+
15+
public function importClassDefinitionFromJson(
16+
ClassDefinition $class,
17+
string $json,
18+
bool $throwException = false,
19+
bool $ignoreId = false
20+
): bool
21+
{
22+
return Service::importClassDefinitionFromJson($class, $json, $throwException, $ignoreId);
23+
}
24+
25+
public function generateClassDefinitionJson(ClassDefinition $class): string
26+
{
27+
return Service::generateClassDefinitionJson($class);
28+
}
29+
30+
public function generateFieldCollectionJson(FCDefinition $fieldCollection): string
31+
{
32+
return Service::generateFieldCollectionJson($fieldCollection);
33+
}
34+
35+
public function generateObjectBrickJson(OBDefinition $objectBrick): string
36+
{
37+
return Service::generateObjectBrickJson($objectBrick);
38+
}
39+
40+
public function generateCustomLayoutJson(CustomLayout $customLayout): string
41+
{
42+
return Service::generateCustomLayoutJson($customLayout);
43+
}
44+
45+
public function importFieldCollectionFromJson(
46+
FCDefinition $fieldCollection,
47+
string $json,
48+
bool $throwException = false
49+
): bool
50+
{
51+
return Service::importFieldCollectionFromJson($fieldCollection, $json, $throwException);
52+
}
53+
54+
public function importObjectBrickFromJson(
55+
OBDefinition $objectBrick,
56+
string $json,
57+
bool $throwException = false
58+
): bool
59+
{
60+
return Service::importObjectBrickFromJson($objectBrick, $json, $throwException);
61+
}
62+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Models\DataObject;
5+
6+
use Pimcore\Model\DataObject\ClassDefinition;
7+
use Pimcore\Model\DataObject\ClassDefinition\CustomLayout;
8+
use Pimcore\Model\DataObject\Fieldcollection\Definition as FCDefinition;
9+
use Pimcore\Model\DataObject\ObjectBrick\Definition as OBDefinition;
10+
11+
interface ClassDefinitionServiceResolverContractInterface
12+
{
13+
public function importClassDefinitionFromJson(
14+
ClassDefinition $class,
15+
string $json,
16+
bool $throwException = false,
17+
bool $ignoreId = false
18+
): bool;
19+
20+
public function generateClassDefinitionJson(ClassDefinition $class): string;
21+
22+
public function generateFieldCollectionJson(FCDefinition $fieldCollection): string;
23+
24+
public function generateObjectBrickJson(OBDefinition $objectBrick): string;
25+
26+
public function generateCustomLayoutJson(CustomLayout $customLayout): string;
27+
28+
public function importFieldCollectionFromJson(
29+
FCDefinition $fieldCollection,
30+
string $json,
31+
bool $throwException = false
32+
): bool;
33+
34+
public function importObjectBrickFromJson(OBDefinition $objectBrick, string $json, bool $throwException = false
35+
): bool;
36+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Models\DataObject;
5+
6+
use Pimcore\Model\DataObject\AbstractObject;
7+
use Pimcore\Model\DataObject\Concrete;
8+
use Pimcore\Model\DataObject\Listing;
9+
10+
class ConcreteObjectResolverContract implements ConcreteObjectResolverContractInterface
11+
{
12+
13+
public function getById(int $id, array $params = []): null|Concrete
14+
{
15+
return Concrete::getById($id, $params);
16+
}
17+
18+
public function classId(): string
19+
{
20+
return Concrete::classId();
21+
}
22+
23+
public function getHideUnpublished(): bool
24+
{
25+
return Concrete::getHideUnpublished();
26+
}
27+
28+
public function setHideUnpublished(bool $hideUnpublished): void
29+
{
30+
Concrete::setHideUnpublished($hideUnpublished);
31+
}
32+
33+
public function doHideUnpublished(): bool
34+
{
35+
return Concrete::doHideUnpublished();
36+
}
37+
38+
public function setGetInheritedValues(bool $getInheritedValues): void
39+
{
40+
Concrete::setGetInheritedValues($getInheritedValues);
41+
}
42+
43+
public function getGetInheritedValues(): ?bool
44+
{
45+
return Concrete::getGetInheritedValues();
46+
}
47+
48+
public function doGetInheritedValues(?Concrete $object = null): bool
49+
{
50+
return Concrete::doGetInheritedValues($object);
51+
}
52+
53+
public function getTypes(): array
54+
{
55+
return Concrete::getTypes();
56+
}
57+
58+
public function getByPath(string $path, array $params = []): AbstractObject|null
59+
{
60+
return Concrete::getByPath($path, $params);
61+
}
62+
63+
/**
64+
* @throws \Exception
65+
*/
66+
public function getList(array $config = []): Listing
67+
{
68+
return Concrete::getList($config);
69+
}
70+
71+
public function doNotRestoreKeyAndPath(): bool
72+
{
73+
return Concrete::doNotRestoreKeyAndPath();
74+
}
75+
76+
public function setDoNotRestoreKeyAndPath(bool $doNotRestoreKeyAndPath): void
77+
{
78+
Concrete::setDoNotRestoreKeyAndPath($doNotRestoreKeyAndPath);
79+
}
80+
81+
public function locateDaoClass(string $modelClass): ?string
82+
{
83+
return Concrete::locateDaoClass($modelClass);
84+
}
85+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Models\DataObject;
5+
6+
use Pimcore\Model\DataObject\AbstractObject;
7+
use Pimcore\Model\DataObject\Concrete;
8+
use Pimcore\Model\DataObject\Listing;
9+
10+
interface ConcreteObjectResolverContractInterface
11+
{
12+
public function getById(int $id, array $params = []): null|Concrete;
13+
14+
public function classId(): string;
15+
16+
public function getHideUnpublished(): bool;
17+
18+
public function setHideUnpublished(bool $hideUnpublished): void;
19+
20+
public function doHideUnpublished(): bool;
21+
22+
public function setGetInheritedValues(bool $getInheritedValues): void;
23+
24+
public function getGetInheritedValues(): ?bool;
25+
26+
public function doGetInheritedValues(?Concrete $object = null): bool;
27+
28+
public function getTypes(): array;
29+
30+
public function getByPath(string $path, array $params = []): AbstractObject|null;
31+
32+
/**
33+
* @throws \Exception
34+
*/
35+
public function getList(array $config = []): Listing;
36+
37+
public function doNotRestoreKeyAndPath(): bool;
38+
39+
public function setDoNotRestoreKeyAndPath(bool $doNotRestoreKeyAndPath): void;
40+
41+
public function locateDaoClass(string $modelClass): ?string;
42+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Pimcore\Bundle\StaticResolverBundle\Contract\Models\DataObject;
5+
6+
use Pimcore\Model\DataObject\AbstractObject;
7+
use Pimcore\Model\DataObject\Folder;
8+
use Pimcore\Model\DataObject\Listing;
9+
10+
class DataObjectFolderResolverContract implements DataObjectFolderResolverContractInterface
11+
{
12+
public function getById(int $id, array $params = []): null|Folder
13+
{
14+
return Folder::getById($id, $params);
15+
}
16+
17+
public function create(array $values): Folder
18+
{
19+
return Folder::create($values);
20+
}
21+
22+
public function getHideUnpublished(): bool
23+
{
24+
return Folder::getHideUnpublished();
25+
}
26+
27+
public function setHideUnpublished(bool $hideUnpublished): void
28+
{
29+
Folder::setHideUnpublished($hideUnpublished);
30+
}
31+
32+
public function doHideUnpublished(): bool
33+
{
34+
return Folder::doHideUnpublished();
35+
}
36+
37+
public function setGetInheritedValues(bool $getInheritedValues): void
38+
{
39+
Folder::setGetInheritedValues($getInheritedValues);
40+
}
41+
42+
public function getGetInheritedValues(): ?bool
43+
{
44+
return Folder::getGetInheritedValues();
45+
}
46+
47+
public function doGetInheritedValues(?Folder $object = null): bool
48+
{
49+
return Folder::doGetInheritedValues($object);
50+
}
51+
52+
public function getTypes(): array
53+
{
54+
return Folder::getTypes();
55+
}
56+
57+
public function getByPath(string $path, array $params = []): AbstractObject|null
58+
{
59+
return Folder::getByPath($path, $params);
60+
}
61+
62+
/**
63+
* @throws \Exception
64+
*/
65+
public function getList(array $config = []): Listing
66+
{
67+
return Folder::getList($config);
68+
}
69+
70+
public function doNotRestoreKeyAndPath(): bool
71+
{
72+
return Folder::doNotRestoreKeyAndPath();
73+
}
74+
75+
public function setDoNotRestoreKeyAndPath(bool $doNotRestoreKeyAndPath): void
76+
{
77+
Folder::setDoNotRestoreKeyAndPath($doNotRestoreKeyAndPath);
78+
}
79+
80+
public function locateDaoClass(string $modelClass): ?string
81+
{
82+
return Folder::locateDaoClass($modelClass);
83+
}
84+
}

0 commit comments

Comments
 (0)