PUGXMultiUserBundle UserManager无法创建用户夹具

时间:2016-02-17 11:43:49

标签: symfony pugxmultiuserbundle

我在Symfony 2.8.2上。我安装了:

    "friendsofsymfony/user-bundle": "~2.0@dev",
    "pugx/multi-user-bundle": "~2.0@dev"

我配置了两种类型的用户,就像在documentation中一样,但targetClass注释中的UniqueEntity参数除外,似乎不被接受。

现在我正试图加载灯具,如下:

<?php
namespace CompanyName\Portal\AppBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use CompanyName\Common\CommonBundle\Entity\AdminUser;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class LoadUsers extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
{
    /**
     * @var ContainerInterface
     */
    private $container;

    public function load(ObjectManager $manager)
    {
        $discriminator = $this->container->get('pugx_user.manager.user_discriminator');
        $discriminator->setClass('CompanyName\Common\CommonBundle\Entity\AdminUser');

        $userManager = $this->container->get('pugx_user_manager');

        $user = new $userManager->createUser();

        $user->setUsername("admin");
        $user->setPlainPassword("test");
        $user->setEmail('email@example.com');
        $user->setFirstName('John');
        $user->setSurname('Smith');
        $user->setRoles(array('ROLE_ADMIN', 'ROLE_SONATA_ADMIN'));
        $user->setEnabled(true);

        $userManager->updateUser($user);
    }

    public function getOrder()
    {
        return 3;
    }

    public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
    }


}

但是当我doctrine:fixtures:load时,我得到了:

[Symfony\Component\Debug\Exception\ContextErrorException]
Notice: Undefined property: PUGX\MultiUserBundle\Doctrine\UserManager::$createUser

你能解释一下吗?我检查过UserManager类,它有createUser函数。

0 个答案:

没有答案