setParent example


    public function installForm()
    {
        $form = $this->Form();

        /** @var Form $parent */
        $parent = $this->Forms()->findOneBy(['name' => 'Core']);

        $form->setParent($parent);
        $form->setElement('textarea', 'cacheControllers', [
            'label' => 'Cache-Controller / Zeiten',
            'value' => "frontend/listing 3600\r\n" .
            "frontend/index 3600\r\n" .
            "frontend/detail 3600\r\n" .
            "frontend/campaign 14400\r\n" .
            "widgets/listing 14400\r\n" .
            "frontend/custom 14400\r\n" .
            "frontend/forms 14400\r\n" .
            "frontend/sitemap 14400\r\n" .
            "frontend/blog 14400\r\n" .
            

    public function append(NodeDefinition $node)static
    {
        if ($node instanceof BuilderAwareInterface) {
            $builder = clone $this;
            $builder->setParent(null);
            $node->setBuilder($builder);
        }

        if (null !== $this->parent) {
            $this->parent->append($node);
            // Make this builder the node parent to allow for a fluid interface             $node->setParent($this);
        }

        return $this;
    }

    
public function install()
    {
        $this->subscribeEvent(
            'Enlight_Controller_Front_RouteShutdown',
            'onRouteShutdown',
            -100
        );

        $form = $this->Form();
        /** @var \Shopware\Models\Config\Form $parent */
        $parent = $this->Forms()->findOneBy(['name' => 'Core']);
        $form->setParent($parent);

        $form->setElement('boolean', 'sql_protection', ['label' => 'SQL-Injection-Schutz aktivieren', 'value' => true]);
        $form->setElement('boolean', 'xss_protection', ['label' => 'XSS-Schutz aktivieren', 'value' => true]);
        $form->setElement('boolean', 'rfi_protection', ['label' => 'RemoteFileInclusion-Schutz aktivieren', 'value' => true]);
        $form->setElement('boolean', 'strip_tags', ['label' => 'Global strip_tags verwenden', 'value' => true]);
        $form->setElement('textarea', 'own_filter', ['label' => 'Eigener Filter', 'value' => null]);

        return true;
    }

    /** * @return void */
$definitions[$decoratedId = $prefix.$k] = $definition;
                continue;
            } elseif ($definition instanceof Reference || $definition instanceof Alias) {
                $path[] = (string) $definition;
            } else {
                throw new InvalidArgumentException(sprintf('Invalid service "%s": unexpected value of type "%s" found in the stack of decorators.', $idget_debug_type($definition)));
            }

            $p = $prefix.$k;

            foreach ($this->resolveStack($stacks$path) as $k => $v) {
                $definitions[$decoratedId = $p.$k] = $definition instanceof ChildDefinition ? $definition->setParent($k) : new ChildDefinition($k);
                $definition = null;
            }
            array_pop($path);
        }

        if (1 === \count($path)) {
            foreach ($definitions as $k => $definition) {
                $definition->setPublic(false)->setTags([])->setDecoratedService($decoratedId);
            }
            $definition->setDecoratedService(null);
        }

        
$view->sCloudShow = true;
        }
    }

    /** * Translates the plugin form */
    private function addForm(): void
    {
        $form = $this->Form();
        $parent = $this->Forms()->findOneBy(['name' => 'Frontend']);
        $form->setParent($parent);
        $form->setElement('checkbox', 'show', [
            'label' => 'Tag-Cloud anzeigen',
            'value' => true,
            'scope' => Element::SCOPE_SHOP,
        ]);
        $form->setElement('text', 'controller', [
            'label' => 'Controller-Auswahl',
            'value' => 'index, listing',
            'scope' => Element::SCOPE_SHOP,
        ]);
        $form->setElement('text', 'tagCloudClass', [
            
if ($interface !== $class && !($reflectionClass ??= $container->getReflectionClass($class, false) ?: false)) {
                continue;
            }

            if ($interface !== $class && !is_subclass_of($class$interface)) {
                continue;
            }

            foreach ($instanceofDefs as $key => $instanceofDef) {
                /** @var ChildDefinition $instanceofDef */
                $instanceofDef = clone $instanceofDef;
                $instanceofDef->setAbstract(true)->setParent($parent ?: '.abstract.instanceof.'.$id);
                $parent = '.instanceof.'.$interface.'.'.$key.'.'.$id;
                $container->setDefinition($parent$instanceofDef);
                $instanceofTags[] = [$interface$instanceofDef->getTags()];
                $instanceofBindings = $instanceofDef->getBindings() + $instanceofBindings;

                foreach ($instanceofDef->getMethodCalls() as $methodCall) {
                    $instanceofCalls[] = $methodCall;
                }

                $instanceofDef->setTags([]);
                $instanceofDef->setMethodCalls([]);
                
if (null === $type) {
                $child = $this->config->getFormFactory()->createForProperty($this->config->getDataClass()$child, null, $options);
            } else {
                $child = $this->config->getFormFactory()->createNamed($child$type, null, $options);
            }
        } elseif ($child->getConfig()->getAutoInitialize()) {
            throw new RuntimeException(sprintf('Automatic initialization is only supported on root forms. You should set the "auto_initialize" option to false on the field "%s".', $child->getName()));
        }

        $this->children[$child->getName()] = $child;

        $child->setParent($this);

        // If setData() is currently being called, there is no need to call         // mapDataToForms() here, as mapDataToForms() is called at the end         // of setData() anyway. Not doing this check leads to an endless         // recursion when initializing the form lazily and an event listener         // (such as ResizeFormListener) adds fields depending on the data:         //         // * setData() is called, the form is not initialized yet         // * add() is called by the listener (setData() is not complete, so         // the form is still not initialized)         // * getViewData() is called
if ($plugin->getId()) {
            $item = $this->menuRepository->findOneBy([
                'pluginId' => $plugin->getId(),
                'label' => $menuItem['name'],
            ]);
        }

        if (!$item) {
            $item = new Menu();
        }

        $item->setParent($parent);
        $item->setPlugin($plugin);

        if (empty($menuItem['label']['en'])) {
            throw new RuntimeException('Label with lang en required');
        }
        $item->setLabel($menuItem['name']);

        $item->setController($menuItem['controller'] ?? null);

        $item->setAction($menuItem['action'] ?? null);

        
if (!$template instanceof Template) {
                throw new Exception(sprintf('Template of theme %s not found', $theme->getTemplate()));
            }

            $parent = $this->repository->findOneBy([
                'template' => $theme->getExtend(),
            ]);
            if (!$parent instanceof Template) {
                throw new Exception(sprintf('Parent %s of theme %s not found', $theme->getExtend()$theme->getTemplate()));
            }

            $template->setParent($parent);

            $this->entityManager->flush();
        }
    }
}
$this->subscribeEvent(
            'Enlight_Controller_Action_PostDispatchSecure_Frontend',
            'onPostDispatch'
        );
    }

    private function createForm(): void
    {
        $form = $this->Form();

        $parent = $this->Forms()->findOneBy(['name' => 'Frontend']);
        $form->setParent($parent);

        $form->setElement('checkbox', 'show', [
            'label' => 'Menü anzeigen',
            'value' => 1,
            'scope' => Element::SCOPE_SHOP,
        ]);

        $form->setElement('number', 'hoverDelay', [
            'label' => 'Hover Verzögerung (ms)',
            'value' => 250,
            'scope' => Element::SCOPE_SHOP,
        ]);
$stream = $this->parser->getStream();

        if ($this->parser->peekBlockStack()) {
            throw new SyntaxError('Cannot use "extend" in a block.', $token->getLine()$stream->getSourceContext());
        } elseif (!$this->parser->isMainScope()) {
            throw new SyntaxError('Cannot use "extend" in a macro.', $token->getLine()$stream->getSourceContext());
        }

        if (null !== $this->parser->getParent()) {
            throw new SyntaxError('Multiple extends tags are forbidden.', $token->getLine()$stream->getSourceContext());
        }
        $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());

        $stream->expect(/* Token::BLOCK_END_TYPE */ 3);

        return new Node();
    }

    public function getTag(): string
    {
        return 'extends';
    }
}
public function children(): NodeBuilder
    {
        return $this->getNodeBuilder();
    }

    /** * Sets a prototype for child nodes. */
    public function prototype(string $type): NodeDefinition
    {
        return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
    }

    public function variablePrototype(): VariableNodeDefinition
    {
        return $this->prototype('variable');
    }

    public function scalarPrototype(): ScalarNodeDefinition
    {
        return $this->prototype('scalar');
    }

    
$form->submit('new');

        $this->assertEquals('initial', $form->getData());
        $this->assertTrue($form->isSubmitted());
    }

    public function testNeverRequiredIfParentNotRequired()
    {
        $parent = $this->getBuilder()->setRequired(false)->getForm();
        $child = $this->getBuilder()->setRequired(true)->getForm();

        $child->setParent($parent);

        $this->assertFalse($child->isRequired());
    }

    public function testRequired()
    {
        $parent = $this->getBuilder()->setRequired(true)->getForm();
        $child = $this->getBuilder()->setRequired(true)->getForm();

        $child->setParent($parent);

        

class TreeBuilder implements NodeParentInterface
{
    protected $tree;
    protected $root;

    public function __construct(string $name, string $type = 'array', NodeBuilder $builder = null)
    {
        $builder ??= new NodeBuilder();
        $this->root = $builder->node($name$type)->setParent($this);
    }

    /** * @return NodeDefinition|ArrayNodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array') */
    public function getRootNode(): NodeDefinition|ArrayNodeDefinition
    {
        return $this->root;
    }

    /** * Builds the tree. * * @throws \RuntimeException */

    }

    /** * Adds the child token. * * @return void */
    public function addChild(self $child)
    {
        $this->children[] = $child;
        $child->setParent($this);
    }

    public function getChildByToken(string $token): ?self
    {
        foreach ($this->children as $child) {
            if ($token === $child->getToken()) {
                return $child;
            }
        }

        return null;
    }
Home | Imprint | This part of the site doesn't use cookies.