zircote / Hal

A PHP implementation of HAL http://stateless.co/hal_specification.html
93 stars 6 forks source link

Fix resource issues #8

Closed jenwachter closed 11 years ago

jenwachter commented 11 years ago

Sets of data that demonstrate the issue that was solved per commit:

2b6875b91433640b660734ae026df30b755aabff: Allow null to be the value of an embedded item.

$noNullValues = array(
    "_links" => array(
        "self" => array("href" => "articles/123")
    ),
    "_embedded" => array(
        "topics" => array(
            array(
                "_links" => array(
                    "self" => array("href" => "topics/sciencs")
                ),
                "name" => "science",
                "slug" => "science"
            ),
            array(
                "_links" => array(
                    "self" => array("href" => "topics/astronomy")
                ),
                "name" => "astronomy",
                "slug" => "astronomy"
            )
        ),
        "tags" => null
    )
);

2590f00f50a7ae1c07c0bb7f2b7dd87b9900e84: Allow a link element to be an array of links. See 'admin' link element in the spec: http://stateless.co/hal_specification.html#examples

$multipleLinks = array(
    "_links" => array(
        "self" => array("href" => "articles/123"),
        "related_articles" => array(
            array("href" => "articles/124"),
            array("href" => "articles/125")
        )
    )
);

d4a7834db2257ce54a47ffe50cdb1b920e4890c9: Reworked _addData() method to correct a couple problems and simplify. When data consists of nested, associative arrays, the keys that were outputted into XML were incorrect. When a top level element contained an array containing string elements, _addData() failed because it was expected the values of the array to be arrays themselves.

$addData = array(
    "_links" => array(
        "self" => array("href" => "articles/123"),
        "related_articles" => array(
            array("href" => "articles/124"),
            array("href" => "articles/125")
        )
    ),
    "keywords" => array(
        "testOne" => array("space", "astronomy", "orbit"),
        "testTwo" => array("earth", "meteor", "star")
    ),
    "nested" => array(
        "moreNested" => array(
            "evenMoreNested" => array("mario", "luigi", "peach")
        ),
        "anotherNested" => array("metal man", "wood man", "air man")
    ),
    "string" => array("one", "two", "three")
);
hjr3 commented 11 years ago

@jenwachter This is awesome. Thank you! :+1:

jenwachter commented 11 years ago

@hjr3 Glad I could help! If it's not too much trouble, could you tag the latest version so it shows up on packagist?

baldurrensch commented 11 years ago

@jenwachter: Tag 0.3.2 created.

jenwachter commented 11 years ago

@baldurrensch thanks!

jenwachter commented 11 years ago

@baldurrensch hmm the tag is not showing up on packagist. Maybe it needs a forced updated?

zircote commented 11 years ago

The composer.json version must be updated to reflect the version in question, committed then tagged.

I want to apologize for being out of the loop for that last 5 weeks, @baldurrensch if you have any questions let me know.

hjr3 commented 11 years ago

@jenwachter I updated the version in composer.json and moved the tag to that commit.

jasonrhodes commented 11 years ago

Hmm, it looks like the 0.3.2 tag is gone? https://github.com/zircote/Hal/tags

zircote commented 11 years ago

I have pushed the tag and checking packagist now and it shows up.

jenwachter commented 11 years ago

Yep I see it too. Thanks @zircote :D

zircote commented 11 years ago

The whole packagist/version/tagging process is not the most intuitive, I had been working on git hooks to force a check before push to update version and tags but got sidetracked for that reason.

jasonrhodes commented 11 years ago

Yeah it can be strange, but you can set up a service hook through Github to make it a lot easier. They describe how to do it on this page: https://packagist.org/about

It is highly recommended to set up the GitHub service hook for all your packages. This reduces the load on our side, and ensures your package is updated almost instantly. To do so you can go to your GitHub repository, click the "Admin" button, then "Service Hooks". Pick "Packagist" in the list, and add the API key you will find on your profile, plus your Packagist username if it is not the same as on GitHub. Check the "Active" box and submit the form.

zircote commented 11 years ago

We have the service hook in place, I was referring to the act of remembering to update the version in the composer.json prior to tagging a version. Simple in itself just not something I personally always remember to do prior to tagging a version.

On Tue, Feb 19, 2013 at 9:09 AM, Jason Rhodes notifications@github.comwrote:

Yeah it can be strange, but you can set up a service hook through Github to make it a lot easier. They describe how to do it on this page: https://packagist.org/about

It is highly recommended to set up the GitHub service hook for all your packages. This reduces the load on our side, and ensures your package is updated almost instantly. To do so you can go to your GitHub repository, click the "Admin" button, then "Service Hooks". Pick "Packagist" in the list, and add the API key you will find on your profile, plus your Packagist username if it is not the same as on GitHub. Check the "Active" box and submit the form.

— Reply to this email directly or view it on GitHubhttps://github.com/zircote/Hal/pull/8#issuecomment-13776969.

jasonrhodes commented 11 years ago

Oh ok, I see. We don't include "version" in our projects' composer.json files (only in the 'require' declarations). Packagist's example composer.json file doesn't mention it either. Maybe just remove it?

{
    "name": "monolog/monolog",
    "type": "library",
    "description": "Logging for PHP 5.3",
    "keywords": ["log","logging"],
    "homepage": "http://github.com/Seldaek/monolog",
    "license": "MIT",
    "authors": [
        {
            "name": "Jordi Boggiano",
            "email": "j.boggiano@seld.be",
            "homepage": "http://seld.be",
            "role": "Developer"
        }
    ],
    "require": {
        "php": ">=5.3.0"
    },
    "autoload": {
        "psr-0": {
            "Monolog": "src"
        }
    }
}