Skip to content

Commit e202317

Browse files
authored
Merge pull request #113 from ntzrbtr/master
2 parents a788567 + 3c25664 commit e202317

File tree

220 files changed

+1339
-678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+1339
-678
lines changed

examples/MyExampleEntity/MyCustomCollection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace examples\MyExampleEntity;
36

47
use Vin\ShopwareSdk\Data\Entity\EntityCollection;
58

69
/**
710
* @method void add(MyCustomEntity $entity)
8-
* @method void set(MyCustomEntity $entity)
11+
* @method void set(string $key, MyCustomEntity $entity)
912
* @method MyCustomEntity[] getIterator()
1013
* @method MyCustomEntity[] getElements()
1114
* @method MyCustomEntity|null get(string $key)
@@ -14,7 +17,7 @@
1417
*/
1518
class MyCustomCollection extends EntityCollection
1619
{
17-
public function getExpectedClass() : string
20+
public function getExpectedClass(): string
1821
{
1922
return MyCustomEntity::class;
2023
}

script/src/CodeGenerator.php

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Vin\Script;
46

@@ -105,7 +107,7 @@ private static function generateEntityClass(string $entityNamespace, string $ent
105107
);
106108

107109
$foo->setName($entityName . 'Entity')
108-
->setNamespaceName($entityNamespace . "\\". $entityName)
110+
->setNamespaceName($entityNamespace . "\\" . $entityName)
109111
->setDocblock($docblock)
110112
->addProperties($properties);
111113
$foo->addUse(Entity::class);
@@ -129,7 +131,7 @@ private static function generateCollectionClass(string $entityNamespace, string
129131

130132
$docblock->setTags([
131133
new MethodTag(null, 'void', sprintf('add(%s $%s)', $entityClass, 'entity')),
132-
new MethodTag(null, 'void', sprintf('set(%s $%s)', $entityClass, 'entity')),
134+
new MethodTag(null, 'void', sprintf('set(string $key, %s $%s)', $entityClass, 'entity')),
133135
new MethodTag('getIterator', $entityClass . '[]'),
134136
new MethodTag('getElements', $entityClass . '[]'),
135137
new MethodTag(null, $entityClass . '|null', 'get(string $key)'),
@@ -186,13 +188,14 @@ private static function generateDefinitionClass(string $entityNamespace, string
186188
$valueFlag = "'$valueFlag'";
187189
} elseif (is_array($valueFlag)) {
188190
if ($keyFlag === 'read_protected' || $keyFlag === 'write_protected') {
189-
$valueFlag = array_map(function ($item) { return "'$item'"; }, array_merge(...$valueFlag));
191+
$valueFlag = array_map(function ($item) {
192+
return "'$item'";
193+
}, array_merge(...$valueFlag));
190194
$valueFlag = "[[" . implode(", ", $valueFlag) . "]]";
191195
} else {
192196
$valueFlag = serialize($valueFlag);
193197

194198
$valueFlag = "unserialize('$valueFlag')";
195-
196199
}
197200
}
198201

@@ -236,10 +239,11 @@ private static function generateDefinitionClass(string $entityNamespace, string
236239
return '<?php declare(strict_types=1);' . PHP_EOL . $foo->generate();
237240
}
238241

239-
private static function escapeJson(array $input) {
240-
$escapedData = json_encode($input, JSON_HEX_QUOT|JSON_HEX_APOS );
241-
// $escapedData = str_replace('"', '\\"', $escapedData );
242-
// $escapedData = str_replace("'", "\\'", $escapedData );
242+
private static function escapeJson(array $input)
243+
{
244+
$escapedData = json_encode($input, JSON_HEX_QUOT | JSON_HEX_APOS);
245+
// $escapedData = str_replace('"', '\\"', $escapedData );
246+
// $escapedData = str_replace("'", "\\'", $escapedData );
243247
return $escapedData;
244248
}
245249

@@ -252,10 +256,10 @@ private static function getTypedProperty(string $entityNamespace, string $entity
252256

253257
$prefix = '?';
254258

255-
// $flags = $property->flags;
256-
// if ($flags->has('required') && $flags->get('required')->value) {
257-
// $prefix = '';
258-
// }
259+
// $flags = $property->flags;
260+
// if ($flags->has('required') && $flags->get('required')->value) {
261+
// $prefix = '';
262+
// }
259263

260264
if ($property->isStringField()) {
261265
return $prefix . 'string';
@@ -291,17 +295,17 @@ private static function getTypedProperty(string $entityNamespace, string $entity
291295
case 'bool':
292296
case 'float':
293297
case 'int': {
294-
return $prefix . $property->type;
295-
}
298+
return $prefix . $property->type;
299+
}
296300
case 'boolean': {
297-
return $prefix . 'bool';
298-
}
301+
return $prefix . 'bool';
302+
}
299303
case 'date': {
300-
return $prefix . \DateTimeInterface::class;
301-
}
304+
return $prefix . \DateTimeInterface::class;
305+
}
302306
default: {
303-
return null;
304-
}
307+
return null;
308+
}
305309
}
306310
}
307311
}

src/Data/Custom/CustomCollection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Vin\ShopwareSdk\Data\Custom;
36

47
use Vin\ShopwareSdk\Data\Entity\EntityCollection;
58

69
/**
710
* @method void add(CustomEntity $entity)
8-
* @method void set(CustomEntity $entity)
11+
* @method void set(string $key, CustomEntity $entity)
912
* @method CustomEntity[] getIterator()
1013
* @method CustomEntity[] getElements()
1114
* @method CustomEntity|null get(string $key)
@@ -14,7 +17,7 @@
1417
*/
1518
class CustomCollection extends EntityCollection
1619
{
17-
public function getExpectedClass() : string
20+
public function getExpectedClass(): string
1821
{
1922
return CustomEntity::class;
2023
}

src/Data/Entity/AclRole/AclRoleCollection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Vin\ShopwareSdk\Data\Entity\AclRole;
36

47
use Vin\ShopwareSdk\Data\Entity\EntityCollection;
@@ -9,7 +12,7 @@
912
* This class is generated dynamically following SW entities schema
1013
*
1114
* @method void add(AclRoleEntity $entity)
12-
* @method void set(AclRoleEntity $entity)
15+
* @method void set(string $key, AclRoleEntity $entity)
1316
* @method AclRoleEntity[] getIterator()
1417
* @method AclRoleEntity[] getElements()
1518
* @method AclRoleEntity|null get(string $key)
@@ -18,7 +21,7 @@
1821
*/
1922
class AclRoleCollection extends EntityCollection
2023
{
21-
public function getExpectedClass() : string
24+
public function getExpectedClass(): string
2225
{
2326
return AclRoleEntity::class;
2427
}

src/Data/Entity/AclUserRole/AclUserRoleCollection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Vin\ShopwareSdk\Data\Entity\AclUserRole;
36

47
use Vin\ShopwareSdk\Data\Entity\EntityCollection;
@@ -9,7 +12,7 @@
912
* This class is generated dynamically following SW entities schema
1013
*
1114
* @method void add(AclUserRoleEntity $entity)
12-
* @method void set(AclUserRoleEntity $entity)
15+
* @method void set(string $key, AclUserRoleEntity $entity)
1316
* @method AclUserRoleEntity[] getIterator()
1417
* @method AclUserRoleEntity[] getElements()
1518
* @method AclUserRoleEntity|null get(string $key)
@@ -18,7 +21,7 @@
1821
*/
1922
class AclUserRoleCollection extends EntityCollection
2023
{
21-
public function getExpectedClass() : string
24+
public function getExpectedClass(): string
2225
{
2326
return AclUserRoleEntity::class;
2427
}

src/Data/Entity/App/AppCollection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Vin\ShopwareSdk\Data\Entity\App;
36

47
use Vin\ShopwareSdk\Data\Entity\EntityCollection;
@@ -9,7 +12,7 @@
912
* This class is generated dynamically following SW entities schema
1013
*
1114
* @method void add(AppEntity $entity)
12-
* @method void set(AppEntity $entity)
15+
* @method void set(string $key, AppEntity $entity)
1316
* @method AppEntity[] getIterator()
1417
* @method AppEntity[] getElements()
1518
* @method AppEntity|null get(string $key)
@@ -18,7 +21,7 @@
1821
*/
1922
class AppCollection extends EntityCollection
2023
{
21-
public function getExpectedClass() : string
24+
public function getExpectedClass(): string
2225
{
2326
return AppEntity::class;
2427
}

src/Data/Entity/AppActionButton/AppActionButtonCollection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Vin\ShopwareSdk\Data\Entity\AppActionButton;
36

47
use Vin\ShopwareSdk\Data\Entity\EntityCollection;
@@ -9,7 +12,7 @@
912
* This class is generated dynamically following SW entities schema
1013
*
1114
* @method void add(AppActionButtonEntity $entity)
12-
* @method void set(AppActionButtonEntity $entity)
15+
* @method void set(string $key, AppActionButtonEntity $entity)
1316
* @method AppActionButtonEntity[] getIterator()
1417
* @method AppActionButtonEntity[] getElements()
1518
* @method AppActionButtonEntity|null get(string $key)
@@ -18,7 +21,7 @@
1821
*/
1922
class AppActionButtonCollection extends EntityCollection
2023
{
21-
public function getExpectedClass() : string
24+
public function getExpectedClass(): string
2225
{
2326
return AppActionButtonEntity::class;
2427
}

src/Data/Entity/AppActionButtonTranslation/AppActionButtonTranslationCollection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Vin\ShopwareSdk\Data\Entity\AppActionButtonTranslation;
36

47
use Vin\ShopwareSdk\Data\Entity\EntityCollection;
@@ -9,7 +12,7 @@
912
* This class is generated dynamically following SW entities schema
1013
*
1114
* @method void add(AppActionButtonTranslationEntity $entity)
12-
* @method void set(AppActionButtonTranslationEntity $entity)
15+
* @method void set(string $key, AppActionButtonTranslationEntity $entity)
1316
* @method AppActionButtonTranslationEntity[] getIterator()
1417
* @method AppActionButtonTranslationEntity[] getElements()
1518
* @method AppActionButtonTranslationEntity|null get(string $key)
@@ -18,7 +21,7 @@
1821
*/
1922
class AppActionButtonTranslationCollection extends EntityCollection
2023
{
21-
public function getExpectedClass() : string
24+
public function getExpectedClass(): string
2225
{
2326
return AppActionButtonTranslationEntity::class;
2427
}

src/Data/Entity/AppAdministrationSnippet/AppAdministrationSnippetCollection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Vin\ShopwareSdk\Data\Entity\AppAdministrationSnippet;
36

47
use Vin\ShopwareSdk\Data\Entity\EntityCollection;
@@ -9,7 +12,7 @@
912
* This class is generated dynamically following SW entities schema
1013
*
1114
* @method void add(AppAdministrationSnippetEntity $entity)
12-
* @method void set(AppAdministrationSnippetEntity $entity)
15+
* @method void set(string $key, AppAdministrationSnippetEntity $entity)
1316
* @method AppAdministrationSnippetEntity[] getIterator()
1417
* @method AppAdministrationSnippetEntity[] getElements()
1518
* @method AppAdministrationSnippetEntity|null get(string $key)
@@ -18,7 +21,7 @@
1821
*/
1922
class AppAdministrationSnippetCollection extends EntityCollection
2023
{
21-
public function getExpectedClass() : string
24+
public function getExpectedClass(): string
2225
{
2326
return AppAdministrationSnippetEntity::class;
2427
}

src/Data/Entity/AppCmsBlock/AppCmsBlockCollection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Vin\ShopwareSdk\Data\Entity\AppCmsBlock;
36

47
use Vin\ShopwareSdk\Data\Entity\EntityCollection;
@@ -9,7 +12,7 @@
912
* This class is generated dynamically following SW entities schema
1013
*
1114
* @method void add(AppCmsBlockEntity $entity)
12-
* @method void set(AppCmsBlockEntity $entity)
15+
* @method void set(string $key, AppCmsBlockEntity $entity)
1316
* @method AppCmsBlockEntity[] getIterator()
1417
* @method AppCmsBlockEntity[] getElements()
1518
* @method AppCmsBlockEntity|null get(string $key)
@@ -18,7 +21,7 @@
1821
*/
1922
class AppCmsBlockCollection extends EntityCollection
2023
{
21-
public function getExpectedClass() : string
24+
public function getExpectedClass(): string
2225
{
2326
return AppCmsBlockEntity::class;
2427
}

0 commit comments

Comments
 (0)