8000 Extending XmlFormat? · Issue #59 · Luracast/Restler · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Extending XmlFormat? #59
Closed
Closed
@GaryJones

Description

@GaryJones

For a method in a class, for which I want the XML root name and list of values that should be attributes to be changed, I know I can do:

<?php
/**
 * @class XmlFormat(root_name=foobar&attribute_names=xmlns,id)
 */

...before the method. However, I'm potentially going to have hundreds of methods across various classes, and this duplication seems somewhat redundant as I'll want the same root name across all of them, and same attribute sets across most of them.

What I'd like to do (but I couldn't get working), is to create my own format, that extends XmlFormat, but sets new default values for properties. Something like:

<?php
require 'restler/xmlformat.php';

class MyXmlFormat extends XmlFormat {
    public static $root_name = 'foobar';
    public static $attribute_names = array('xmlns', 'id');
}

or

<?php
require 'restler/xmlformat.php';

class MyXmlFormat extends XmlFormat {
    public __construct() {
        self::$root_name = 'foobar';
        self::$attribute_names = array('xmlns', 'id');
    }
}

...with

<?php
$r->setSupportedFormats('JsonFormat', 'MyXmlFormat');

in the index.php.

Is such a thing possible / am I heading along the right lines? Some use of var_dump() showed that a MyXmlFormat object was being used, but the static properties being returned via self::$... were not picking up the new values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0