Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Arul
    @Arul-
    @Erwyn Just commited the fix. Test and let me know
    Martin Goyot
    @Erwyn
    Hello there
    So, I'm willing to try your patch but I need to update from RC4 to RC5 or RC6 for that. Do you have any upgrade procedure for this? Cause I'm have troubles with the iAuthenticate Interface that changes and other things like this
    Arul
    @Arul-
    you may just overwrite the XmlFormat class from that commit to save some trouble
    Arul
    @Arul-
    At least for testing
    Martin Goyot
    @Erwyn
    And what should I do to upgrade from RC4 to RC5 and RC6? do you have any idea of what's required to modify?
    Arul
    @Arul-
    nothing much changed, iAuthenticate now requires one more method to be defined. Some defaults have chaneged. Many new features were added
    Martin Goyot
    @Erwyn
    okay so I'll continue my tests, something must be wrong on my side
    that has all the majour changes till RC5. RC6 is yet to be documented and released
    Martin Goyot
    @Erwyn
    mhhh okay, I don't know why but I'm experiencing Warning: Class 'Luracast\Restler\string' not found in /usr/share/restler/vendor/Luracast/Restler/AutoLoader.php on line 307
    and such things
    Arul
    @Arul-
    are you using composer?
    use composer to handle the install, update, and autoloading
    all the problems should disappear
    Martin Goyot
    @Erwyn
    mhhh no, we are not using composer
    Ok, I'll try it
    \o/
    thank you @Arul- you're my hero those days
    Arul
    @Arul-
    :) you are welcome
    Martin Goyot
    @Erwyn
    So after a few tests, it fixes part of the problem
    let me explain

    Say I have a route defined this way:

    /**
         * test post
         *
         * @url POST {id}
         * @param int $id   Id of the artifact {@from body}
         * @param array  $values    Artifact fields values {@from body}
         *
         * @return int
         */
        protected function post($id, array $values) {
            var_dump($values);
            return 4;
        }

    if I input this:

    <response><item><some-property>123</some-property></item></response>

    I will have:

    array (
        '0' => array (
            'some-property' => 123
        )
    )

    which is correct by the way, and what the fixes targets

    Arul
    @Arul-
    ok
    Martin Goyot
    @Erwyn

    but, know, if I input this:

    <response><values><some-property>123</some-property></values></response>

    I will have:

    array(
        'some-property' => 123
    )
    mainly because <values> matches @param array $values as a name
    Arul
    @Arul-
    does it work when you change values to item ?
    Martin Goyot
    @Erwyn
    in the @param?
    Arul
    @Arul-
    in the xml
    let me explain the solution for your problem
    Martin Goyot
    @Erwyn
    if i put <item> instead of <values> yes I have:
    array (
        '0' => array (
            'some-property' => 123
        )
    )
    Arul
    @Arul-
    XmlFormat needs to know which tag it has to consider as numeric index, by default it is item you can change it by adding
    Martin Goyot
    @Erwyn
    but if I put @param array $item then it is the contrary, values works and not item
    oh no you're right, it works
    in RC6
    the problem appeared in RC4
    I'm listening to you though :p
    Arul
    @Arul-
    use Luracast\Restler\Format\XmlFormat;
    
    XmlFormat::$defaultTagName = 'values';
    you can place it in your index.php
    or if each of your api needs different default tag, you can also do the following
    //make sure you add a use statement on top
    use Luracast\Restler\Format\XmlFormat;
    
    //in your api class add the method with a @class comment
    /**
     * test post
     *
     * @url POST {id}
     * @param int $id   Id of the artifact {@from body}
     * @param array  $values    Artifact fields values {@from body}
     *
     * @return int
     *
     * @class XmlFormat {@defaultTagName values}
     */
    protected function post($id, array $values) {
        var_dump($values);
        return 4;
    }
    Martin Goyot
    @Erwyn
    mhhh
    and If I need multiple defaultTagNames? to match the JSON API? is this something possible
    Arul
    @Arul-
    nope not at the moment
    Martin Goyot
    @Erwyn
    okay
    Arul
    @Arul-
    if you present a good and common use case in the same issue (#410) I can consider adding that ;)
    Martin Goyot
    @Erwyn
    haha, would be great :)
    Martin Goyot
    @Erwyn
    no, I have to run some further testing to see if it is really necessary
    Arul
    @Arul-
    sure, go ahead and keep me posted!
    Martin Goyot
    @Erwyn
    just to be sure, it seems that there is another big difference between RC4 and RC6. All @param that are not tagged as {@required false} seems to be considered as required. Am I doing something wrong? Is this configurable somehow?