src/PHPDish/Bundle/PostBundle/EventListener/CategorySubscriber.php
public function onCategoryPersist(CategoryPersistEvent $event)
    {
        $category = $event->getCategory();
        $cover = $category->getCover();
        if (!$cover || $cover === '/avatar/user1.jpg') {
            $avatar = $this->avatarGenerator->generate($category->getName());
            $category->setCover($avatar->getKey());
        }
    }
public function onCategoryPersist(CategoryPersistEvent $event)
    {
        $category = $event->getCategory();
        $cover = $category->getCover();
        if (!$cover || $cover === '/avatar/user1.jpg') {
            $avatar = $this->avatarGenerator->generate($category->getName());
            $category->setCover($avatar->getKey());
        }
    }
专栏创建之前被触发
@param CategoryPersistEvent $event