R
R
RSalo2020-09-29 05:10:59
symfony
RSalo, 2020-09-29 05:10:59

PHPCR How to create a node with a user?

Hello. When I try to create a document for a user using PHPCR, I get an error:

In NamespaceRegistry.php line 193:

Mapping for 'rep' is not defined

The document itself and the fixture:
spoiler
/**
 * @Document(nodeType="rep:User")
 */
class UserDocument implements HierarchyInterface
{
    /**
     * @Id(strategy="parent")
     */
    private $id;

    /**
     * @Nodename()
     */
    private $nodeName;

    /**
     * @ParentDocument()
     */
    private $parent;

    /**
     * @Field(property="rep:password")
     */
    private $password;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getParent()
    {
        return $this->getParentDocument();
    }

    public function setParent($parent)
    {
        return $this->setParentDocument($parent);
    }

    public function getParentDocument()
    {
        return $this->parent;
    }

    public function setParentDocument($parent)
    {
        $this->parent = $parent;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getNodeName()
    {
        return $this->nodeName;
    }

    /**
     * @param string $nodeName
     * @return ArticleDocument
     */
    public function setNodeName(string $nodeName)
    {
        $this->nodeName = $nodeName;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getPassword()
    {
        return $this->password;
    }

    /**
     * @param mixed $password
     * @return ArticleDocument
     */
    public function setPassword($password): ArticleDocument
    {
        $this->password = $password;

        return $this;
    }
}

        $article = new UserDocument();
        $article->setParentDocument($members);
        $article->setNodeName('userNode');
        $article->setPassword('testPassword');

        $manager->persist($article);
        $manager->flush();

Do I need to register namespaces separately or am I doing something wrong? I would be grateful for a hint.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question