Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

method created: processXmlContent() which just returns the PHP array … #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mowses
Copy link

@mowses mowses commented May 25, 2019

…instead of converting it to JSON plain text. Method fromXml() calls processXmlContent() method, fromXml() still returns the result as plain text

Provide a narrative description of what you are trying to accomplish:

  • Are you fixing a bug?

    • Detail how the bug is invoked currently.
    • Detail the original, incorrect behavior.
    • Detail the new, expected behavior.
    • Base your feature on the master branch, and submit against that branch.
    • Add a regression test that demonstrates the bug, and proves the fix.
    • Add a CHANGELOG.md entry for the fix.
  • Are you creating a new feature?

    • Why is the new feature needed? What purpose does it serve?
    • How will users use the new feature?
    • Base your feature on the develop branch, and submit against that branch.
    • Add only one feature per pull request; split multiple features over multiple pull requests
    • Add tests for the new feature.
    • Add documentation for the new feature.
    • Add a CHANGELOG.md entry for the new feature.
  • Is this related to quality assurance?

  • Is this related to documentation?

root and others added 2 commits May 25, 2019 15:14
…instead of converting it to JSON plain text. Method fromXml() calls processXmlContent() method, fromXml() still returns the result as plain text
convert xml to object instead of array
@michalbundyra
Copy link
Member

@mowses What problem does it solve? Can you elaborate, please?

@mowses
Copy link
Author

mowses commented Sep 4, 2019

@mowses What problem does it solve? Can you elaborate, please?

As a library for parsing XML I wanted to use zend-xml2json as a third party library to convert XML to PHP variable (Array/Object), so I realized that there are not any method that could do that.
The original method fromXml() has been returning the encoded JSON (as string). Well, I may call Json:decode() after fromXml to convert the returned value to array/object again, but it would be waste of resource.

To accomplish this, I just cut some part of the fromXml() code and paste it in the static method processXmlContent() which now returns the resulting array I needed.
In place of code I cut, I just call the processXmlContent which returns the resulting array, then is encoded by Json::encode, returning the same value and having the exact same behavior as before.

Now anyone can use zend-xml2json with the option to retrieve the XML as PHP variable, instead of only as JSON (string).
To use it just call processXmlContent passing the same parameters as you would for fromXml.

Note: I did not removed nor changed any script behavior. The return from fromXml is still the same as before, so I made sure I did not broke applications who are using this method.

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-xml2json; a new issue has been opened at laminas/laminas-xml2json#1.

@weierophinney
Copy link
Member

This repository has been moved to laminas/laminas-xml2json. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:

  • Squash all commits in your branch (git rebase -i origin/{branch})
  • Make a note of all changed files (`git diff --name-only origin/{branch}...HEAD
  • Run the laminas/laminas-migration tool on the code.
  • Clone laminas/laminas-xml2json to another directory.
  • Copy the files from the second bullet point to the clone of laminas/laminas-xml2json.
  • In your clone of laminas/laminas-xml2json, commit the files, push to your fork, and open the new PR.
    We will be providing tooling via laminas/laminas-migration soon to help automate the process.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants