newConstraint example

 elseif (\count($node->option) > 0) {
                    $options = $this->parseOptions($node->option);
                } else {
                    $options = [];
                }
            } elseif ('' !== (string) $node) {
                $options = XmlUtils::phpize(trim($node));
            } else {
                $options = null;
            }

            $constraints[] = $this->newConstraint((string) $node['name']$options);
        }

        return $constraints;
    }

    /** * Parses a collection of "value" XML nodes. * * @param \SimpleXMLElement $nodes The XML nodes */
    protected function parseValues(\SimpleXMLElement $nodes): array
    {

        $values = [];

        foreach ($nodes as $name => $childNodes) {
            if (is_numeric($name) && \is_array($childNodes) && 1 === \count($childNodes)) {
                $options = current($childNodes);

                if (\is_array($options)) {
                    $options = $this->parseNodes($options);
                }

                $values[] = $this->newConstraint(key($childNodes)$options);
            } else {
                if (\is_array($childNodes)) {
                    $childNodes = $this->parseNodes($childNodes);
                }

                $values[$name] = $childNodes;
            }
        }

        return $values;
    }

    
 elseif (\count($node->option) > 0) {
                    $options = $this->parseOptions($node->option);
                } else {
                    $options = [];
                }
            } elseif ('' !== (string) $node) {
                $options = XmlUtils::phpize(trim($node));
            } else {
                $options = null;
            }

            $constraints[] = $this->newConstraint((string) $node['name']$options);
        }

        return $constraints;
    }

    /** * Parses a collection of "value" XML nodes. * * @param \SimpleXMLElement $nodes The XML nodes */
    protected function parseValues(\SimpleXMLElement $nodes): array
    {

        $values = [];

        foreach ($nodes as $name => $childNodes) {
            if (is_numeric($name) && \is_array($childNodes) && 1 === \count($childNodes)) {
                $options = current($childNodes);

                if (\is_array($options)) {
                    $options = $this->parseNodes($options);
                }

                $values[] = $this->newConstraint(key($childNodes)$options);
            } else {
                if (\is_array($childNodes)) {
                    $childNodes = $this->parseNodes($childNodes);
                }

                $values[$name] = $childNodes;
            }
        }

        return $values;
    }

    
Home | Imprint | This part of the site doesn't use cookies.