class XsdGenerator extends AbstractGenerator (View source)

XML Schema (XSD) Generator. Will generate an XML schema which can be used for auto-completion in schema-aware editors like Eclipse XML editor.

Properties

protected ClassReflection $abstractViewHelperReflectionClass

The reflection class for AbstractViewHelper. Is needed quite often, that's why we use a pre-initialized one.

from  AbstractGenerator
protected DocCommentParser $docCommentParser

The doc comment parser.

from  AbstractGenerator
protected ReflectionService $reflectionService from  AbstractGenerator
protected ObjectManagerInterface $objectManager

Methods

__construct()

Constructor. Sets $this->abstractViewHelperReflectionClass

array
getClassNamesInNamespace(string $namespace)

Get all class names inside this namespace and return them as array.

string
getTagNameForClass(string $className, string $namespace)

Get a tag name for a given ViewHelper class.

addChildWithCData(SimpleXMLElement $parentXmlNode, string $childNodeName, string $childNodeValue)

Add a child node to $parentXmlNode, and wrap the contents inside a CDATA section.

string
generateXsd(string $viewHelperNamespace, string $xsdNamespace)

Generate the XML Schema definition for a given namespace.

void
generateXmlForClassName(string $className, string $viewHelperNamespace, SimpleXMLElement $xmlRootNode)

Generate the XML Schema for a given class name.

void
addAttributes(string $className, SimpleXMLElement $xsdElement)

Add attribute descriptions to a given tag.

void
addDocumentation(string $documentation, SimpleXMLElement $xsdParentNode)

Add documentation XSD to a given XML node

Details

__construct()

Constructor. Sets $this->abstractViewHelperReflectionClass

protected array getClassNamesInNamespace(string $namespace)

Get all class names inside this namespace and return them as array.

Parameters

string $namespace

Return Value

array

Array of all class names inside a given namespace.

protected string getTagNameForClass(string $className, string $namespace)

Get a tag name for a given ViewHelper class.

Example: For the View Helper Neos\FluidAdaptor\ViewHelpers\Form\SelectViewHelper, and the namespace prefix Neos\FluidAdaptor\ViewHelpers\, this method returns "form.select".

Parameters

string $className

Class name

string $namespace

Base namespace to use

Return Value

string

Tag name

protected SimpleXMLElement addChildWithCData(SimpleXMLElement $parentXmlNode, string $childNodeName, string $childNodeValue)

Add a child node to $parentXmlNode, and wrap the contents inside a CDATA section.

Parameters

SimpleXMLElement $parentXmlNode

Parent XML Node to add the child to

string $childNodeName

Name of the child node

string $childNodeValue

Value of the child node. Will be placed inside CDATA.

Return Value

SimpleXMLElement

the new element

string generateXsd(string $viewHelperNamespace, string $xsdNamespace)

Generate the XML Schema definition for a given namespace.

It will generate an XSD file for all view helpers in this namespace.

Parameters

string $viewHelperNamespace

Namespace identifier to generate the XSD for, without leading Backslash.

string $xsdNamespace

$xsdNamespace unique target namespace used in the XSD schema (for example "http://yourdomain.org/ns/viewhelpers")

Return Value

string

XML Schema definition

Exceptions

Exception

protected void generateXmlForClassName(string $className, string $viewHelperNamespace, SimpleXMLElement $xmlRootNode)

Generate the XML Schema for a given class name.

Parameters

string $className

Class name to generate the schema for.

string $viewHelperNamespace

Namespace prefix. Used to split off the first parts of the class name.

SimpleXMLElement $xmlRootNode

XML root node where the xsd:element is appended.

Return Value

void

protected void addAttributes(string $className, SimpleXMLElement $xsdElement)

Add attribute descriptions to a given tag.

Initializes the view helper and its arguments, and then reads out the list of arguments.

Parameters

string $className

Class name where to add the attribute descriptions

SimpleXMLElement $xsdElement

XML element to add the attributes to.

Return Value

void

protected void addDocumentation(string $documentation, SimpleXMLElement $xsdParentNode)

Add documentation XSD to a given XML node

Parameters

string $documentation

Documentation string to add.

SimpleXMLElement $xsdParentNode

Node to add the documentation to

Return Value

void