Skip to content

Commit

Permalink
refactor #759 Remove Component namespace on annotation (loic425)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.11 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Bug fix?        | no/yes
| New feature?    | no/yes
| BC breaks?      | no/yes
| Deprecations?   | no/yes <!-- don't forget to update the UPGRADE-*.md file -->
| Related tickets | 
| License         | MIT

Based on previous one.

Commits
-------

b00cdd5 Remove Component namespace on annotation
  • Loading branch information
lchrusciel authored Oct 24, 2023
2 parents ca05fca + b00cdd5 commit 0de9728
Show file tree
Hide file tree
Showing 46 changed files with 208 additions and 156 deletions.
20 changes: 10 additions & 10 deletions docs/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ app_book:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusCrudRoutes;

#[SyliusCrudRoutes(
alias: 'app.book',
Expand Down Expand Up @@ -68,7 +68,7 @@ app_book:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusCrudRoutes;

#[SyliusCrudRoutes(
alias: 'app.book',
Expand Down Expand Up @@ -140,7 +140,7 @@ app_book:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusCrudRoutes;

#[SyliusCrudRoutes(
alias: 'app.book',
Expand Down Expand Up @@ -185,7 +185,7 @@ app_book:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusCrudRoutes;

#[SyliusCrudRoutes(
alias: 'app.book',
Expand Down Expand Up @@ -235,7 +235,7 @@ app_library_book:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusCrudRoutes;

#[SyliusCrudRoutes(
alias: 'app.book',
Expand Down Expand Up @@ -295,7 +295,7 @@ app_admin_book:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusCrudRoutes;

#[SyliusCrudRoutes(
alias: 'app.book',
Expand Down Expand Up @@ -336,7 +336,7 @@ app_book:
# src/Entity/Book

use App\Form\Type\AdminBookType;
use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusCrudRoutes;

#[SyliusCrudRoutes(
alias: 'app.book',
Expand Down Expand Up @@ -373,7 +373,7 @@ app_book:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusCrudRoutes;

#[SyliusCrudRoutes(
alias: 'app.book',
Expand Down Expand Up @@ -431,7 +431,7 @@ app_book:
```php
# src/Entity/Book
use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusCrudRoutes;
#[SyliusCrudRoutes(
alias: 'app.book',
Expand Down Expand Up @@ -485,7 +485,7 @@ app_book:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusCrudRoutes;

#[SyliusCrudRoutes(
identifier: 'isbn',
Expand Down
12 changes: 6 additions & 6 deletions docs/show_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ app_book_show:
```php
// src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_show',
Expand Down Expand Up @@ -68,7 +68,7 @@ app_admin_book_show:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_admin_book_show',
Expand Down Expand Up @@ -111,7 +111,7 @@ app_book_show:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_show',
Expand Down Expand Up @@ -158,7 +158,7 @@ app_book_show:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_show',
Expand Down Expand Up @@ -203,7 +203,7 @@ app_book_show:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_show',
Expand Down Expand Up @@ -251,7 +251,7 @@ app_book_show:
```php
# src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_show',
Expand Down
18 changes: 9 additions & 9 deletions docs/update_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ app_book_update:
```php
// src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_update',
Expand Down Expand Up @@ -74,7 +74,7 @@ app_book_update:
```php
// src/Entity/Book

use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_update',
Expand Down Expand Up @@ -113,7 +113,7 @@ app_book_update:
// src/Entity/Book

use App\Form\BookType;
use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_update',
Expand Down Expand Up @@ -157,7 +157,7 @@ app_book_update:
// src/Entity/Book

use App\Form\BookType;
use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_update',
Expand Down Expand Up @@ -199,7 +199,7 @@ app_book_update:
// src/Entity/Book

use App\Form\BookType;
use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_update',
Expand Down Expand Up @@ -240,7 +240,7 @@ app_book_update:
// src/Entity/Book

use App\Form\BookType;
use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_update',
Expand Down Expand Up @@ -279,7 +279,7 @@ app_book_update:
// src/Entity/Book

use App\Form\BookType;
use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_update',
Expand Down Expand Up @@ -323,7 +323,7 @@ app_book_customer_update:
// src/Entity/Book

use App\Form\BookType;
use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_customer_update',
Expand Down Expand Up @@ -368,7 +368,7 @@ app_book_update:
// src/Entity/Book

use App\Form\BookType;
use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Resource\Annotation\SyliusRoute;

#[SyliusRoute(
name: 'app_book_update',
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ parameters:
- %currentWorkingDirectory%/src/Bundle/Routing/Configuration.php
- %currentWorkingDirectory%/src/Bundle/spec/*
- %currentWorkingDirectory%/src/Bundle/Tests/*
- %currentWorkingDirectory%/src/Component/Annotation/*
- %currentWorkingDirectory%/src/Component/Reflection/ClassReflection.php
- %currentWorkingDirectory%/src/Component/spec/*
- %currentWorkingDirectory%/src/Component/vendor/*
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@

<TypeDoesNotContainType>
<errorLevel type="suppress">
<directory name="src/Component/Annotation" />
<file name="src/Bundle/Event/ResourceControllerEvent.php" />
</errorLevel>
</TypeDoesNotContainType>
Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/Routing/CrudRoutesAttributesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Sylius\Bundle\ResourceBundle\Routing;

use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Component\Resource\Reflection\ClassReflection;
use Sylius\Resource\Annotation\SyliusCrudRoutes;
use Symfony\Bundle\FrameworkBundle\Routing\RouteLoaderInterface;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Yaml\Yaml;
Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/Routing/RouteAttributesFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Sylius\Bundle\ResourceBundle\Routing;

use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Component\Resource\Reflection\ClassReflection;
use Sylius\Resource\Annotation\SyliusRoute;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Webmozart\Assert\Assert;
Expand Down
69 changes: 5 additions & 64 deletions src/Component/Annotation/SyliusCrudRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,11 @@

namespace Sylius\Component\Resource\Annotation;

#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
final class SyliusCrudRoutes
{
public ?string $alias = null;
class_exists(\Sylius\Resource\Annotation\SyliusCrudRoutes::class);

public ?string $path = null;

public ?string $identifier = null;

public ?array $criteria = null;

public ?bool $filterable = null;

public ?string $form = null;

public ?string $serializationVersion = null;

public ?string $section = null;

public ?string $redirect = null;

public ?string $templates = null;

public ?string $grid = null;

public ?bool $permission = null;

public ?array $except = null;

public ?array $only = null;

public ?array $vars = null;

public function __construct(
?string $alias = null,
?string $path = null,
?string $identifier = null,
?array $criteria = null,
?bool $filterable = null,
?string $form = null,
?string $serializationVersion = null,
?string $section = null,
?string $redirect = null,
?string $templates = null,
?string $grid = null,
?bool $permission = null,
?array $except = null,
?array $only = null,
?array $vars = null,
) {
$this->alias = $alias;
$this->path = $path;
$this->identifier = $identifier;
$this->criteria = $criteria;
$this->filterable = $filterable;
$this->form = $form;
$this->serializationVersion = $serializationVersion;
$this->section = $section;
$this->redirect = $redirect;
$this->templates = $templates;
$this->grid = $grid;
$this->permission = $permission;
$this->except = $except;
$this->only = $only;
$this->vars = $vars;
if (false) {
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
final class SyliusCrudRoutes extends \Sylius\Resource\Annotation\SyliusCrudRoutes
{
}
}
35 changes: 6 additions & 29 deletions src/Component/Annotation/SyliusRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,11 @@

namespace Sylius\Component\Resource\Annotation;

#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
final class SyliusRoute
{
public function __construct(
public ?string $name = null,
public ?string $path = null,
public ?array $methods = null,
public ?string $controller = null,
public ?string $template = null,
public ?array $repository = null,
public ?array $criteria = null,
public ?array $serializationGroups = null,
public ?string $serializationVersion = null,
public ?array $requirements = null,
public ?array $options = null,
public ?string $host = null,
public ?array $schemes = null,
public ?int $priority = null,
public ?array $vars = null,
public string | array | null $form = null,
public ?string $section = null,
public ?bool $permission = null,
public ?string $grid = null,
public ?bool $csrfProtection = null,
public string | array | null $redirect = null,
public ?array $stateMachine = null,
public ?string $event = null,
public ?bool $returnContent = null,
) {
class_exists(\Sylius\Resource\Annotation\SyliusRoute::class);

if (false) {
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
final class SyliusRoute extends \Sylius\Resource\Annotation\SyliusRoute
{
}
}
4 changes: 2 additions & 2 deletions src/Component/Tests/Reflection/ClassReflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
use App\Entity\Route\ShowBook;
use App\Entity\Route\ShowBookWithPriority;
use PHPUnit\Framework\TestCase;
use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Component\Resource\Annotation\SyliusRoute;
use Sylius\Component\Resource\Reflection\ClassReflection;
use Sylius\Component\Resource\Tests\Dummy\DummyClassOne;
use Sylius\Component\Resource\Tests\Dummy\DummyClassTwo;
use Sylius\Component\Resource\Tests\Dummy\TraitPass;
use Sylius\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Resource\Annotation\SyliusRoute;

final class ClassReflectionTest extends TestCase
{
Expand Down
Loading

0 comments on commit 0de9728

Please sign in to comment.