Sylius / PluginSkeleton

Skeleton for starting Sylius plugins.
https://sylius.com/plugins/
73 stars 62 forks source link

New istall fail #[\ApiPlatform\Core\Annotation\ApiProperty(identifier: true)] #230

Closed vanssata closed 3 years ago

vanssata commented 3 years ago

After create template or new install on plugin skeleton i have this error:

tests/Application$ symfony console c:c

 // Clearing the cache for the dev environment with debug true                                                          

In FileLoader.php line 180:

  No identifier defined "Sylius\Bundle\ApiBundle\Command\RegisterShopUser". You should add #[\ApiPlatform\Core\Annotation\ApiProperty(identifier: true)]" on the property identifying the resource." in . (  
  which is being imported from "/home/vansa/PhpstormProjects/EUVATTAX/vendor/sylius/sylius/src/Sylius/Bundle/ApiBundle/Resources/config/routing.yml"). Make sure there is a loader supporting the "api_plat  
  form" type.                                                                                                                                                                                                

In IdentifiersExtractor.php line 65:

  No identifier defined "Sylius\Bundle\ApiBundle\Command\RegisterShopUser". You should add #[\ApiPlatform\Core\Annotation\ApiProperty(identifier: true)]" on the property identifying the resource."  

cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

exit status 1

Possible solution: Add identifier="true" to resource RegisterShopUser . Somethin like this: change vendor/sylius/sylius/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Commands/RegisterShopUser.xml

<?xml version="1.0" ?>

<!--

 This file is part of the Sylius package.

 (c) Paweł Jędrzejewski

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<resources xmlns="https://api-platform.com/schema/metadata"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.5.xsd"
>
    <resource class="Sylius\Bundle\ApiBundle\Command\RegisterShopUser" shortName="RegisterShopUser">
        <attribute name="route_prefix">shop</attribute>

        <attribute name="messenger">true</attribute>

        <attribute name="output">false</attribute>

        <attribute name="validation_groups">sylius</attribute>

        <collectionOperations>
            <collectionOperation name="post">
                <attribute name="path">/register</attribute>
                <attribute name="openapi_context">
                    <attribute name="summary">Registers a shop user</attribute>
                </attribute>
                <attribute name="validation_groups">
                    <attribute>sylius</attribute>
                </attribute>
            </collectionOperation>
        </collectionOperations>

        <itemOperations />

        <property name="firstName" required="true" />
        <property name="lastName" required="true" />
        <property name="email" required="true" />
        <property name="password" required="true" />
    </resource>
</resources>

to :

<?xml version="1.0" ?>

<!--

 This file is part of the Sylius package.

 (c) Paweł Jędrzejewski

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<resources xmlns="https://api-platform.com/schema/metadata"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.5.xsd"
>
    <resource class="Sylius\Bundle\ApiBundle\Command\RegisterShopUser" shortName="RegisterShopUser">
        <attribute name="route_prefix">shop</attribute>

        <attribute name="messenger">true</attribute>

        <attribute name="output">false</attribute>

        <attribute name="validation_groups">sylius</attribute>

        <collectionOperations>
            <collectionOperation name="post">
                <attribute name="path">/register</attribute>
                <attribute name="openapi_context">
                    <attribute name="summary">Registers a shop user</attribute>
                </attribute>
                <attribute name="validation_groups">
                    <attribute>sylius</attribute>
                </attribute>
            </collectionOperation>
        </collectionOperations>

        <itemOperations />

        <property name="firstName" required="true" />
        <property name="lastName" required="true" />
        <property name="email" required="true" identifier="true" />
        <property name="password" required="true" />
    </resource>
</resources>
lchrusciel commented 3 years ago

Hey Vanesta,

thanks for raising it up, there is already some work in progress in https://github.com/Sylius/Sylius/pull/12274 & issue submitted at https://github.com/Sylius/Sylius/issues/12273