Hazaar\XML\Element may have issues with elements that have only one child #45

Closed
opened 2015-02-22 22:50:42 +00:00 by jamie · 3 comments
jamie commented 2015-02-22 22:50:42 +00:00 (Migrated from git.hazaar.io)

I'm not sure yet what is going on here but I have finding I get inconsistent results with the following XML:

<theme>
    <name>Alternative Theme</name>
    <description>An alternative theme for testing.</description>
    <files>
        <file>layout.phtml</file>
        <file>theme.xml</file>
    </files>
    <menus>
        <menu name="primary">Primary Menu</menu>
        <menu name="secondary">Secondary Menu</menu>
        <menu name="footer">Footer Menu</menu>
    </menus>
    <positions>
        <position>breadcrumb</position>
        <position>top</position>
        <position>left</position>
        <position>footer</position>
    </positions>
    <options>
        <option type="image" name="logo">Site Logo</option>
    </options>
</theme>

The section in question is the <options> block with a single <option> child. Although things seem to parse correctly I'm not able to access the child element. If I add another element everything works as it should.

I'm not sure yet what is going on here but I have finding I get inconsistent results with the following XML: ``` <theme> <name>Alternative Theme</name> <description>An alternative theme for testing.</description> <files> <file>layout.phtml</file> <file>theme.xml</file> </files> <menus> <menu name="primary">Primary Menu</menu> <menu name="secondary">Secondary Menu</menu> <menu name="footer">Footer Menu</menu> </menus> <positions> <position>breadcrumb</position> <position>top</position> <position>left</position> <position>footer</position> </positions> <options> <option type="image" name="logo">Site Logo</option> </options> </theme> ``` The section in question is the `<options>` block with a single `<option>` child. Although things seem to parse correctly I'm not able to access the child element. If I add another element everything works as it should.
jamie commented 2015-02-22 23:32:23 +00:00 (Migrated from git.hazaar.io)

Ok, turns out when there is only one child (or none, even) then the 'children' variable is an XML\Element instead of an array so the calls to ArrayAccess methods next(), current(), etc don't work properly because they are not operating on an array.

I need to make 'children' an array always? This will alter the way child elements are accessed.

Ok, turns out when there is only one child (or none, even) then the 'children' variable is an XML\Element instead of an array so the calls to ArrayAccess methods next(), current(), etc don't work properly because they are not operating on an array. I need to make 'children' an array always? This will alter the way child elements are accessed.
jamie commented 2015-02-23 01:06:09 +00:00 (Migrated from git.hazaar.io)

Status changed to closed by commit 96b98b4933

Status changed to closed by commit 96b98b493367c7e2861311efa35f91e28beda1fe
jamie commented 2015-12-03 02:27:11 +00:00 (Migrated from git.hazaar.io)

mentioned in commit 96b98b4933

mentioned in commit 96b98b493367c7e2861311efa35f91e28beda1fe
Commenting is not possible because the repository is archived.
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hazaar/hazaar-mvc-old#45
No description provided.