Skip to content

Commit 0d7c67a

Browse files
committed
Refactor and add constructors in Reorder classes
Introduced constructors in `AbstractReorder`, `FormReorder`, `ShowReorder`, and `ShowAndFormReorder` classes to set initial values. Also removed unneeded import, improved function return types and removed unneeded whitespace. The refactoring improves code readability and makes initial state setting more explicit.
1 parent 75a51d0 commit 0d7c67a

7 files changed

Lines changed: 31 additions & 10 deletions

File tree

src/Admin/BaseAdmin.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ public function getTrackedActions(): array
132132

133133
protected function configureListFields(ListMapper $list): void
134134
{
135-
136135
$this->getSonataAnnotationReader()?->configureListFields($this->getClass(), $list);
137136
}
138137

src/Annotation/Order/AbstractReorder.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44

55
namespace Networking\InitCmsBundle\Annotation\Order;
66

7-
use Networking\InitCmsBundle\Annotation\Order\ShowAndFormReorderInterface;
8-
97
abstract class AbstractReorder implements ReorderInterface
108
{
119
/**
1210
* @var array
1311
*/
1412
public $keys = [];
1513

14+
public function __construct(array $keys)
15+
{
16+
$this->keys = $keys;
17+
}
18+
1619
/**
1720
* @return array
1821
*/

src/Annotation/Order/FormReorder.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010
#[\Attribute(\Attribute::TARGET_CLASS)]
1111
class FormReorder extends AbstractReorder implements FormReorderInterface
1212
{
13+
1314
/**
1415
* @var string
1516
*/
16-
public $with = null;
17+
public ?string $with = null;
18+
19+
public function __construct(array $keys, ?string $with = null)
20+
{
21+
parent::__construct($keys);
22+
$this->with = $with;
23+
}
1724

1825
public function getWith(): ?string
1926
{

src/Annotation/Order/ShowAndFormReorder.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ class ShowAndFormReorder extends AbstractReorder implements ShowAndFormReorderIn
1313
/**
1414
* @var string
1515
*/
16-
public $with = null;
16+
public ?string $with = null;
17+
18+
public function __construct(array $keys, ?string $with = null)
19+
{
20+
parent::__construct($keys);
21+
$this->with = $with;
22+
}
1723

1824
public function getWith(): ?string
1925
{

src/Annotation/Order/ShowReorder.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ class ShowReorder extends AbstractReorder implements ShowReorderInterface
1313
/**
1414
* @var string
1515
*/
16-
public $with = null;
16+
public ?string $with = null;
17+
18+
public function __construct(array $keys, ?string $with = null)
19+
{
20+
parent::__construct($keys);
21+
$this->with = $with;
22+
}
1723

1824
public function getWith(): ?string
1925
{

src/AttributeReader/SonataAdminAttributeReader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ public function getDatagridMapperCallbacks($entity): array
251251
}
252252

253253
/**
254-
* @return ListReorderInterface
254+
* @return ListReorderInterface|null
255255
*/
256-
public function getListReorderAnnotation($entity): ListReorderInterface
256+
public function getListReorderAnnotation($entity): ?ListReorderInterface
257257
{
258258
return $this->getAnnotationsByType($entity, self::ANNOTATION_TYPE_ADMIN_LIST_REORDER, self::SCOPE_CLASS);
259259
}

src/AttributeReader/SonataAdminAttributeReaderInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public function getListMapperAnnotations($entity): array;
5454
public function getListMapperCallbacks($entity): array;
5555

5656
/**
57-
* @return ListReorderInterface
57+
* @return ListReorderInterface|null
5858
*/
59-
public function getListReorderAnnotation($entity): ListReorderInterface;
59+
public function getListReorderAnnotation($entity): ?ListReorderInterface;
6060

6161
/**
6262
* @return ShowInterface[]

0 commit comments

Comments
 (0)