Reliance on an error of automatic registration of a service on an ORM object

I am developing a Symfony 3 application. Symfony Profiler Logs tell me:

Relying on service auto-registration for type "App\Entity\SubDir\Category"
is deprecated since version 3.4 and won't be supported in 4.0.
Create a service named "App\Entity\SubDir\Category" instead.

However, this is a simple ORM bean:

/**
 * @ORM\Entity
 * @ORM\Table(name="category")
 */
class Category
{
...

How do I get rid of this problem? Do I really need to declare ORM objects as services in services.yaml? If so, how?

Update In fact, my entity is in a subdirectory. I changed my question.

In mine, service.yamlI tried:

App\:
    resource: '../src/*'
    exclude: '../src/{Entity,Repository,Tests,Entity/SubDir}'

... but to no avail.

+4
source share
1 answer

Do you have classes in the Auto-Registration section that use the Entity as constructor argument?

What causes your problem.

, - , .

, 2 :

glob, ,

AppBundle\:
    resource: '...'
    # you can exclude directories or files
    # but if a service is unused, it removed anyway
    exclude: '../../{Entity,PathToYourNotService}'

parameters:
    container.autowiring.strict_mode: true

, , . sf4

, , , :

namespace AppBundle\Event;

use AppBundle\Entity\Item;
use Symfony\Component\EventDispatcher\Event;

class ItemUpdateEvent extends Event
{
    const NAME = 'item.update';

    protected $item;

    public function __construct(Item $item)
    {
        $this->item = $item;
    }

    public function getItem()
    {
        return $this->item;
    }
}

, , . Entity, . 3.4 , . strict_mode , , , .

+4

Source: https://habr.com/ru/post/1691117/


All Articles