setAttribute example

\PDO::FETCH_OBJ => 'OBJ',
        ],
    ];

    /** * @return array */
    public static function castPdo(\PDO $c, array $a, Stub $stub, bool $isNested)
    {
        $attr = [];
        $errmode = $c->getAttribute(\PDO::ATTR_ERRMODE);
        $c->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

        foreach (self::PDO_ATTRIBUTES as $k => $v) {
            if (!isset($k[0])) {
                $k = $v;
                $v = [];
            }

            try {
                $attr[$k] = 'ERRMODE' === $k ? $errmode : $c->getAttribute(\constant('PDO::ATTR_'.$k));
                if ($v && isset($v[$attr[$k]])) {
                    $attr[$k] = new ConstStub($v[$attr[$k]]$attr[$k]);
                }
private \DOMDocument $document;

    /** * Dumps the service container as an XML string. */
    public function dump(array $options = []): string
    {
        $this->document = new \DOMDocument('1.0', 'utf-8');
        $this->document->formatOutput = true;

        $container = $this->document->createElementNS('http://symfony.com/schema/dic/services', 'container');
        $container->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
        $container->setAttribute('xsi:schemaLocation', 'http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd');

        $this->addParameters($container);
        $this->addServices($container);

        $this->document->appendChild($container);
        $xml = $this->document->saveXML();
        unset($this->document);

        return $this->container->resolveEnvPlaceholders($xml);
    }

    
$this->setAdditionalAddressLine2((string) $address->getAdditionalAddressLine2());
        $this->setCountry($address->getCountry());
        $this->setPhone($address->getPhone());
        $this->setTitle($address->getTitle());
        if ($address->getState()) {
            $this->setState($address->getState());
        } else {
            $this->setState(null);
        }

        $attributeData = Shopware()->Models()->toArray($address->getAttribute());
        $this->setAttribute($attributeData);
    }

    /** * @return string|null */
    public function getTitle()
    {
        return $this->title;
    }

    /** * @param string|null $title */
$cursor->node = $node;

            return;
        }

        // Otherwise create the node         $node = new Node($cursor->node, $domNodeName);
        $this->setAttributes($domNodeName$domNode$node$this->elementsConfig[$domNodeName]);

        // Force configured attributes         foreach ($this->forcedAttributes[$domNodeName] ?? [] as $attribute => $value) {
            $node->setAttribute($attribute$value);
        }

        $cursor->node->addChild($node);
        $cursor->node = $node;
    }

    private function visitChildren(\DOMNode $domNode, Cursor $cursor): void
    {
        /** @var \DOMNode $child */
        foreach ($domNode->childNodes ?? [] as $child) {
            if ('#text' === $child->nodeName) {
                

    public function __construct(bool $capture, Node $names, Node $values, int $lineno, string $tag = null)
    {
        parent::__construct(['names' => $names, 'values' => $values]['capture' => $capture, 'safe' => false]$lineno$tag);

        /* * Optimizes the node when capture is used for a large block of text. * * {% set foo %}foo{% endset %} is compiled to $context['foo'] = new Twig\Markup("foo"); */
        if ($this->getAttribute('capture')) {
            $this->setAttribute('safe', true);

            $values = $this->getNode('values');
            if ($values instanceof TextNode) {
                $this->setNode('values', new ConstantExpression($values->getAttribute('data')$values->getTemplateLine()));
                $this->setAttribute('capture', false);
            }
        }
    }

    public function compile(Compiler $compiler): void
    {
        

class DefinedTest extends TestExpression
{
    public function __construct(Node $node, string $name, ?Node $arguments, int $lineno)
    {
        if ($node instanceof NameExpression) {
            $node->setAttribute('is_defined_test', true);
        } elseif ($node instanceof GetAttrExpression) {
            $node->setAttribute('is_defined_test', true);
            $this->changeIgnoreStrictCheck($node);
        } elseif ($node instanceof BlockReferenceExpression) {
            $node->setAttribute('is_defined_test', true);
        } elseif ($node instanceof FunctionExpression && 'constant' === $node->getAttribute('name')) {
            $node->setAttribute('is_defined_test', true);
        } elseif ($node instanceof ConstantExpression || $node instanceof ArrayExpression) {
            $node = new ConstantExpression(true, $node->getTemplateLine());
        } elseif ($node instanceof MethodCallExpression) {
            $node->setAttribute('is_defined_test', true);
        }


        preg_match_all('/(?<!%)%([^%]+)%/', $msg$matches);

        foreach ($matches[1] as $var) {
            $key = new ConstantExpression('%'.$var.'%', $body->getTemplateLine());
            if (!$vars->hasElement($key)) {
                if ('count' === $var && $this->hasNode('count')) {
                    $vars->addElement($this->getNode('count')$key);
                } else {
                    $varExpr = new NameExpression($var$body->getTemplateLine());
                    $varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck);
                    $vars->addElement($varExpr$key);
                }
            }
        }

        return [new ConstantExpression(str_replace('%%', '%', trim($msg))$body->getTemplateLine())$vars];
    }
}
protected function getActionArguments(string $actionMethodName): array
    {
        if (!$this->Request()->attributes->has('controllerId')) {
            return [];
        }

        $controllerArray = [
            $this,
            $actionMethodName,
        ];

        $this->Request()->setAttribute('_controller', $this->Request()->getAttribute('controllerId') . '::' . $actionMethodName);

        try {
            return $this->container->get('argument_resolver')->getArguments($this->Request()$controllerArray);
        } catch (ReflectionException $e) {
            // Invalid action called             return [];
        }
    }
}


                return new GetAttrExpression($args->getNode(0)$args->getNode(1), \count($args) > 2 ? $args->getNode(2) : null, Template::ANY_CALL, $line);
            default:
                if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
                    $arguments = new ArrayExpression([]$line);
                    foreach ($this->parseArguments() as $n) {
                        $arguments->addElement($n);
                    }

                    $node = new MethodCallExpression($alias['node']$alias['name']$arguments$line);
                    $node->setAttribute('safe', true);

                    return $node;
                }

                $args = $this->parseArguments(true);
                $class = $this->getFunctionNodeClass($name$line);

                return new $class($name$args$line);
        }
    }

    
/** * @var Parser */
    protected $parser;

    public function parse(Token $token): SwInclude
    {
        $expr = $this->parser->getExpressionParser()->parseExpression();

        $icon = $expr->getAttribute('value');

        $expr->setAttribute('value', '@Storefront/storefront/utilities/icon.html.twig');

        $stream = $this->parser->getStream();

        $variables = new ArrayExpression([]$token->getLine());

        if ($stream->nextIf(Token::NAME_TYPE, 'style')) {
            /** @var ArrayExpression $variables */
            $variables = $this->parser->getExpressionParser()->parseExpression();
        }

        $stream->next();

        


    public function getTypeExtensions(): array
    {
        return $this->proxiedType->getTypeExtensions();
    }

    public function createBuilder(FormFactoryInterface $factory, string $name, array $options = []): FormBuilderInterface
    {
        $builder = $this->proxiedType->createBuilder($factory$name$options);

        $builder->setAttribute('data_collector/passed_options', $options);
        $builder->setType($this);

        return $builder;
    }

    public function createView(FormInterface $form, FormView $parent = null): FormView
    {
        return $this->proxiedType->createView($form$parent);
    }

    /** * @return void */

        unset($this->attributes[$key]);
    }

    /** * Sets an info message. * * @return void */
    public function setInfo(string $info)
    {
        $this->setAttribute('info', $info);
    }

    /** * Returns info message. */
    public function getInfo(): ?string
    {
        return $this->getAttribute('info');
    }

    /** * Sets the example configuration for this node. * * @return void */

  public function testSetAttribute() {
    $attribute = new Attribute();

    // Test adding various attributes.     $attributes = ['alt', 'id', 'src', 'title', 'value'];
    foreach ($attributes as $key) {
      foreach (['kitten', ''] as $value) {
        $attribute = new Attribute();
        $attribute->setAttribute($key$value);
        $this->assertEquals($value$attribute[$key]);
      }
    }

    // Test adding array to class.     $attribute = new Attribute();
    $attribute->setAttribute('class', ['kitten', 'cat']);
    $this->assertEquals(['kitten', 'cat']$attribute['class']->value());

    // Test adding boolean attributes.     $attribute = new Attribute();
    
 elseif ($this->inAModule) {
            if (
                $node instanceof GetAttrExpression &&
                $node->getNode('node') instanceof NameExpression &&
                '_self' === $node->getNode('node')->getAttribute('name') &&
                $node->getNode('attribute') instanceof ConstantExpression
            ) {
                $this->hasMacroCalls = true;

                $name = $node->getNode('attribute')->getAttribute('value');
                $node = new MethodCallExpression($node->getNode('node'), 'macro_'.$name$node->getNode('arguments')$node->getTemplateLine());
                $node->setAttribute('safe', true);
            }
        }

        return $node;
    }

    public function getPriority(): int
    {
        // we must be ran before auto-escaping         return -10;
    }
}
$request->setModuleName($params['module'])
                ->setControllerName('index')
                ->setActionName('index');
    }
    if (isset($params['controller'])) {
        $request->setControllerName($params['controller'])
                ->setActionName('index');
    }

    // setParam is used for bc reasons, the attribute should be read for new code     $request->setParam('_isSubrequest', true);
    $request->setAttribute('_isSubrequest', true);

    $request->setActionName(isset($params['action']) ? $params['action'] : 'index');
    $request->setParams($params)
            ->setDispatched(true);

    Shopware()->Container()->get('request_stack')->push($request);

    $dispatcher->dispatch($request$response);

    if (!$request->isDispatched() || $response->isRedirect()) {
        // forwards and redirects render nothing
Home | Imprint | This part of the site doesn't use cookies.