src/Form/PageParts/InsertPagePagePartAdminType.php
protected function validateParentPage()
    {
        $request = $this->requestStack->getMasterRequest();

        // the node which the pagepart belongs to
        if ($request->query->has('pageid') && $request->query->has('pageclassname')) {
            $repo = $this->doctrine->getManager()->getRepository('KunstmaanNodeBundle:Node');
            $node = $repo->getNodeForIdAndEntityname(
              $request->query->get('pageid'),
              $request->query->get('pageclassname')
            );

            $pageReflection = new \ReflectionClass($node->getRefEntityName());

            // if the current page implements the interface, then it is forbidden to insert anything beneath
            if ($pageReflection->implementsInterface(InsertablePageInterface::class)) {
                $currentContext = $this->requestStack->getMasterRequest()->get('context');
                $page = $pageReflection->newInstanceWithoutConstructor();

                // get pagepart configurations for the current page
                $pagePartConfigs = $this->pagePartConfigReader->getPagePartAdminConfigurators($page);

                foreach ($pagePartConfigs as $config) {
                    if ($config->getContext() === $currentContext) {
                        foreach ($config->getPossiblePagePartTypes() as $pagePartType) {
                            if ($pagePartType['class'] === InsertPagePagePart::class) {
                                throw new \LogicException(
                                  sprintf(
                                    'The %s page must not allow %s as possible page part, because it implements %s! You must modify the "%s" context.',
                                    $pageReflection->getName(),
                                    InsertPagePagePart::class,
                                    InsertablePageInterface::class,
                                    $currentContext
                                  ));
                            }
                        }
                    }
                }
            }
        }
    }
protected function validateParentPage()
    {
        $request = $this->requestStack->getMasterRequest();

        // the node which the pagepart belongs to
        if ($request->query->has('pageid') && $request->query->has('pageclassname')) {
            $repo = $this->doctrine->getManager()->getRepository('KunstmaanNodeBundle:Node');
            $node = $repo->getNodeForIdAndEntityname(
              $request->query->get('pageid'),
              $request->query->get('pageclassname')
            );

            $pageReflection = new \ReflectionClass($node->getRefEntityName());

            // if the current page implements the interface, then it is forbidden to insert anything beneath
            if ($pageReflection->implementsInterface(InsertablePageInterface::class)) {
                $currentContext = $this->requestStack->getMasterRequest()->get('context');
                $page = $pageReflection->newInstanceWithoutConstructor();

                // get pagepart configurations for the current page
                $pagePartConfigs = $this->pagePartConfigReader->getPagePartAdminConfigurators($page);

                foreach ($pagePartConfigs as $config) {
                    if ($config->getContext() === $currentContext) {
                        foreach ($config->getPossiblePagePartTypes() as $pagePartType) {
                            if ($pagePartType['class'] === InsertPagePagePart::class) {
                                throw new \LogicException(
                                  sprintf(
                                    'The %s page must not allow %s as possible page part, because it implements %s! You must modify the "%s" context.',
                                    $pageReflection->getName(),
                                    InsertPagePagePart::class,
                                    InsertablePageInterface::class,
                                    $currentContext
                                  ));
                            }
                        }
                    }
                }
            }
        }
    }
protected function validateParentPage ( ) { $ request = $ this -> requestStack -> getMasterRequest ( ) ; // the node which the pagepart belongs to if ( $ request -> query -> has ( 'pageid' ) && $ request -> query -> has ( 'pageclassname' ) ) { $ repo = $ this -> doctrine -> getManager ( ) -> getRepository ( 'KunstmaanNodeBundle:Node' ) ; $ node = $ repo -> getNodeForIdAndEntityname ( $ request -> query -> get ( 'pageid' ) , $ request -> query -> get ( 'pageclassname' ) ) ; $ pageReflection = new \ ReflectionClass ( $ node -> getRefEntityName ( ) ) ; // if the current page implements the interface, then it is forbidden to insert anything beneath if ( $ pageReflection -> implementsInterface ( InsertablePageInterface :: class ) ) { $ currentContext = $ this -> requestStack -> getMasterRequest ( ) -> get ( 'context' ) ; $ page = $ pageReflection -> newInstanceWithoutConstructor ( ) ; // get pagepart configurations for the current page $ pagePartConfigs = $ this -> pagePartConfigReader -> getPagePartAdminConfigurators ( $ page ) ; foreach ( $ pagePartConfigs as $ config ) { if ( $ config -> getContext ( ) === $ currentContext ) { foreach ( $ config -> getPossiblePagePartTypes ( ) as $ pagePartType ) { if ( $ pagePartType [ 'class' ] === InsertPagePagePart :: class ) { throw new \ LogicException ( sprintf ( 'The %s page must not allow %s as possible page part, because it implements %s! You must modify the "%s" context.' , $ pageReflection -> getName ( ) , InsertPagePagePart :: class , InsertablePageInterface :: class , $ currentContext ) ) ; } } } } } } }
Check if the page part is insertable into the current page.

@throws \LogicException
Check if the page part is insertable into the current page .