Skip to content

[DependencyInjection] Use DOM instead of SimpleXML for namespace support #9350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

sandermarechal
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #9345
License MIT
Doc PR

This PR makes the XmlFileLoader use the DOM instead of SimpleXML. This allows full namespace support in XML files. Previously, the Symfony container namespace had to be the default namespace for the document. See also #9345.

Some things to discuss:

I avoided any BC breaks but I do not know if the things I avoided breaking are actually part of the API. There are two places this applies to:

  1. The Symfony\Component\DependencyInjection\SimpleXMLElement still exists, but it is no longer used, except to maintain BC. It does not appear to be used anywhere else in Symfony itself. Maybe some userland code uses it somewhere. If this is not part of the API it could be removed.
  2. The parseFile method still returns a SimpleXMLElement to maintain BC. I have added a new function parseFileToDOM that is used by the XmlFileLoader itself. If this is not part of the API we could drop that new function and have parseFile return a \DOMDocument instead.

@hason
Copy link
Contributor

hason commented Oct 21, 2013

Duplicated #6147

@sandermarechal
Copy link
Contributor Author

@fabpot Can this, or #6147 be merged?

guilhermeblanco pushed a commit to doctrine/DoctrineBundle that referenced this pull request Jan 27, 2014
This allows tagging a service with an 'doctrine.orm.entity_listener'
tag. These tagged services will automatically be registered with the
entity listener resolver.

Note: The changes to the XML fixture cannot be parsed due to a bug in
the Symfony DependencyInjection component. A PR that fixes this issue
can be found at symfony/symfony#9350. When that
PR has been merged, all tests in this commit pass.
@sandermarechal
Copy link
Contributor Author

Any updates on whether this issue or issue #6147 will be merged?

*
* @throws InvalidArgumentException When loading of XML file returns error
*/
protected function parseFileToDOM($file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should be private.

@fabpot
Copy link
Member

fabpot commented Mar 28, 2014

@sandermarechal Can you rebase on current master?

To answer your questions:

  1. Symfony\Component\DependencyInjection\SimpleXMLElement cannot be removed but it must be marked as deprecated in 2.5 (to be removed in 3.0)

  2. Drop the current parseFile() method.

@fabpot
Copy link
Member

fabpot commented Apr 2, 2014

Closing in favor of #10619

@fabpot fabpot closed this Apr 2, 2014
fabpot added a commit that referenced this pull request Apr 2, 2014
… namespace support (sandermarechal, romainneutron)

This PR was merged into the 2.5-dev branch.

Discussion
----------

[DependencyInjection] Use DOM instead of SimpleXML for namespace support

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #9345
| License       | MIT

This PR replaces #9350

Commits
-------

a3c60c8 [DependencyInjection] Deprecate SimpleXMLElement
33c91f9 [DependencyInjection] Use DOM instead of SimpleXML for namespace support
BonyHanter83 added a commit to BonyHanter83/DoctrineBundle that referenced this pull request May 29, 2025
This allows tagging a service with an 'doctrine.orm.entity_listener'
tag. These tagged services will automatically be registered with the
entity listener resolver.

Note: The changes to the XML fixture cannot be parsed due to a bug in
the Symfony DependencyInjection component. A PR that fixes this issue
can be found at symfony/symfony#9350. When that
PR has been merged, all tests in this commit pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants