src/Sulu/Bundle/PageBundle/Form/Type/PageDocumentType.php
public function postSubmitDocumentParent(FormEvent $event)
    {
        $document = $event->getData();

        if ($document->getParent()) {
            return;
        }

        $form = $event->getForm();
        $webspaceKey = $form->getConfig()->getAttribute('webspace_key');
        $parent = $this->documentManager->find($this->sessionManager->getContentPath($webspaceKey));

        if (null === $parent) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Could not determine parent for document with title "%s" in webspace "%s"',
                    $document->getTitle(),
                    $webspaceKey
                )
            );
        }

        $document->setParent($parent);
    }
public function postSubmitDocumentParent(FormEvent $event)
    {
        $document = $event->getData();

        if ($document->getParent()) {
            return;
        }

        $form = $event->getForm();
        $webspaceKey = $form->getConfig()->getAttribute('webspace_key');
        $parent = $this->documentManager->find($this->sessionManager->getContentPath($webspaceKey));

        if (null === $parent) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Could not determine parent for document with title "%s" in webspace "%s"',
                    $document->getTitle(),
                    $webspaceKey
                )
            );
        }

        $document->setParent($parent);
    }
public function postSubmitDocumentParent ( FormEvent $ event ) { $ document = $ event -> getData ( ) ; if ( $ document -> getParent ( ) ) { return ; } $ form = $ event -> getForm ( ) ; $ webspaceKey = $ form -> getConfig ( ) -> getAttribute ( 'webspace_key' ) ; $ parent = $ this -> documentManager -> find ( $ this -> sessionManager -> getContentPath ( $ webspaceKey ) ) ; if ( null === $ parent ) { throw new \ InvalidArgumentException ( sprintf ( 'Could not determine parent for document with title "%s" in webspace "%s"' , $ document -> getTitle ( ) , $ webspaceKey ) ) ; } $ document -> setParent ( $ parent ) ; }
Set the document parent to be the webspace content path
when the document has no parent.

@param FormEvent $event
Set the document parent to be the webspace content path when the document has no parent .