{"action":"created","comment":{"url":"https://api.github.com/repos/symfony-cmf/resource/pulls/comments/64543629","id":64543629,"diff_hunk":"@@ -0,0 +1,88 @@\n+<?php\n+\n+/*\n+ * This file is part of the Symfony CMF package.\n+ *\n+ * (c) 2011-2015 Symfony CMF\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Symfony\\Cmf\\Component\\Resource\\Description;\n+\n+use Puli\\Repository\\Api\\Resource\\PuliResource;\n+\n+/**\n+ * Descriptive metadata for resources.\n+ */\n+class Description\n+{\n+    /**\n+     * @var array\n+     */\n+    private $descriptors = [];\n+\n+    /**\n+     * @var PuliResource\n+     */\n+    private $resource;\n+\n+    /**\n+     * @param PuliResource $resource\n+     */\n+    public function __construct(PuliResource $resource)\n+    {\n+        $this->resource = $resource;\n+    }\n+\n+    /**\n+     * Return the descriptors value for the given key.\n+     *\n+     * @param string $key\n+     *\n+     * @return mixed\n+     */\n+    public function get($key)\n+    {\n+        if (!isset($this->descriptors[$key])) {\n+            throw new \\InvalidArgumentException(sprintf(\n+                'Descriptor \"%s\" not supported for resource \"%s\" of class \"%s\". Supported descriptors: \"%s\"',\n+                $key,\n+                $this->resource->getPath(),\n+                get_class($this->resource),\n+                implode('\", \"', array_keys($this->descriptors))\n+            ));\n+        }\n+\n+        return $this->descriptors[$key];\n+    }\n+\n+    /**\n+     * Set value for descriptors key.\n+     *\n+     * Note that:\n+     *\n+     * - It is possible to overwrite existing keys.\n+     *\n+     * - Where possible the key should be the value of one of the constants\n+     *   defined in the Descriptor class.\n+     *\n+     * @param string $key\n+     * @param mixed  $value\n+     */\n+    public function set($key, $value)\n+    {\n+        $this->descriptors[$key] = $value;\n+    }","path":"Description/Description.php","position":77,"original_position":77,"commit_id":"dc64748e611c45da40da93fae5b61c54611f18e3","original_commit_id":"dc64748e611c45da40da93fae5b61c54611f18e3","user":{"login":"dantleech","id":530801,"avatar_url":"https://avatars.githubusercontent.com/u/530801?v=3","gravatar_id":"","url":"https://api.github.com/users/dantleech","html_url":"https://github.com/dantleech","followers_url":"https://api.github.com/users/dantleech/followers","following_url":"https://api.github.com/users/dantleech/following{/other_user}","gists_url":"https://api.github.com/users/dantleech/gists{/gist_id}","starred_url":"https://api.github.com/users/dantleech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dantleech/subscriptions","organizations_url":"https://api.github.com/users/dantleech/orgs","repos_url":"https://api.github.com/users/dantleech/repos","events_url":"https://api.github.com/users/dantleech/events{/privacy}","received_events_url":"https://api.github.com/users/dantleech/received_events","type":"User","site_admin":false},"body":"Yeah we are missing `has()` and possibly `all()`.","created_at":"2016-05-25T09:40:00Z","updated_at":"2016-05-25T09:40:00Z","html_url":"https://github.com/symfony-cmf/resource/pull/19#discussion_r64543629","pull_request_url":"https://api.github.com/repos/symfony-cmf/resource/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/symfony-cmf/resource/pulls/comments/64543629"},"html":{"href":"https://github.com/symfony-cmf/resource/pull/19#discussion_r64543629"},"pull_request":{"href":"https://api.github.com/repos/symfony-cmf/resource/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/symfony-cmf/resource/pulls/19","id":71037068,"html_url":"https://github.com/symfony-cmf/resource/pull/19","diff_url":"https://github.com/symfony-cmf/resource/pull/19.diff","patch_url":"https://github.com/symfony-cmf/resource/pull/19.patch","issue_url":"https://api.github.com/repos/symfony-cmf/resource/issues/19","number":19,"state":"open","locked":false,"title":"Example for admin metadata implementation,","user":{"login":"dantleech","id":530801,"avatar_url":"https://avatars.githubusercontent.com/u/530801?v=3","gravatar_id":"","url":"https://api.github.com/users/dantleech","html_url":"https://github.com/dantleech","followers_url":"https://api.github.com/users/dantleech/followers","following_url":"https://api.github.com/users/dantleech/following{/other_user}","gists_url":"https://api.github.com/users/dantleech/gists{/gist_id}","starred_url":"https://api.github.com/users/dantleech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dantleech/subscriptions","organizations_url":"https://api.github.com/users/dantleech/orgs","repos_url":"https://api.github.com/users/dantleech/repos","events_url":"https://api.github.com/users/dantleech/events{/privacy}","received_events_url":"https://api.github.com/users/dantleech/received_events","type":"User","site_admin":false},"body":"**REFACTORED**\r\n\r\nThis PR has now been refactored to provide \"descriptions\" of payloads.\r\n\r\nA description is just an key / value store and passed to any number of\r\nsupprorting \"enrichers\" (e.g. SonataEnricher, SyliusEnricher) which add any\r\ninformation.\r\n\r\nIn order to ensure interoperability a `Descriptor` class is given which\r\nprovides constant values for use as descriptor keys, e.g. `LINK_EDIT_HTML`,\r\n`TYPE_ALIAS`, `TITLE`.\r\n\r\nUse is as follows:\r\n\r\n```php\r\n$factory = new DescriptionFactory([\r\n    new SyliusEnricher(...),  // add links for Sylius\r\n    new IconEnricher()        // add \"icon\" URLs (as an example)\r\n]); \r\n\r\n$resource = $registry->get('/pages/foobar/my-article'); // get a resource\r\n$description = $factory->getPayloadDescriptionFor($resource);\r\n\r\necho $description->get(Descriptor::TITLE); // \"My Article\"\r\necho $description->get(Descriptor::TYPE); // AcmeBundle\\Document\\Article\r\necho $description->has(Descriptor::LINK_HTML_EDIT); // true\r\necho $description->get(Descriptor::LINK_HTML_EDIT); // /path/to/edit/page/123\r\n```\r\n\r\n\r\nSee #18 \r\n","created_at":"2016-05-23T10:18:46Z","updated_at":"2016-05-25T09:40:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c920e69b6957de04065a66c4c79e6ee2d9cfef9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony-cmf/resource/pulls/19/commits","review_comments_url":"https://api.github.com/repos/symfony-cmf/resource/pulls/19/comments","review_comment_url":"https://api.github.com/repos/symfony-cmf/resource/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony-cmf/resource/issues/19/comments","statuses_url":"https://api.github.com/repos/symfony-cmf/resource/statuses/dc64748e611c45da40da93fae5b61c54611f18e3","head":{"label":"symfony-cmf:admin_metadata","ref":"admin_metadata","sha":"dc64748e611c45da40da93fae5b61c54611f18e3","user":{"login":"symfony-cmf","id":342045,"avatar_url":"https://avatars.githubusercontent.com/u/342045?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony-cmf","html_url":"https://github.com/symfony-cmf","followers_url":"https://api.github.com/users/symfony-cmf/followers","following_url":"https://api.github.com/users/symfony-cmf/following{/other_user}","gists_url":"https://api.github.com/users/symfony-cmf/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony-cmf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony-cmf/subscriptions","organizations_url":"https://api.github.com/users/symfony-cmf/orgs","repos_url":"https://api.github.com/users/symfony-cmf/repos","events_url":"https://api.github.com/users/symfony-cmf/events{/privacy}","received_events_url":"https://api.github.com/users/symfony-cmf/received_events","type":"Organization","site_admin":false},"repo":{"id":26994566,"name":"resource","full_name":"symfony-cmf/resource","owner":{"login":"symfony-cmf","id":342045,"avatar_url":"https://avatars.githubusercontent.com/u/342045?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony-cmf","html_url":"https://github.com/symfony-cmf","followers_url":"https://api.github.com/users/symfony-cmf/followers","following_url":"https://api.github.com/users/symfony-cmf/following{/other_user}","gists_url":"https://api.github.com/users/symfony-cmf/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony-cmf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony-cmf/subscriptions","organizations_url":"https://api.github.com/users/symfony-cmf/orgs","repos_url":"https://api.github.com/users/symfony-cmf/repos","events_url":"https://api.github.com/users/symfony-cmf/events{/privacy}","received_events_url":"https://api.github.com/users/symfony-cmf/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony-cmf/resource","description":"CMF Resource Component","fork":false,"url":"https://api.github.com/repos/symfony-cmf/resource","forks_url":"https://api.github.com/repos/symfony-cmf/resource/forks","keys_url":"https://api.github.com/repos/symfony-cmf/resource/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony-cmf/resource/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony-cmf/resource/teams","hooks_url":"https://api.github.com/repos/symfony-cmf/resource/hooks","issue_events_url":"https://api.github.com/repos/symfony-cmf/resource/issues/events{/number}","events_url":"https://api.github.com/repos/symfony-cmf/resource/events","assignees_url":"https://api.github.com/repos/symfony-cmf/resource/assignees{/user}","branches_url":"https://api.github.com/repos/symfony-cmf/resource/branches{/branch}","tags_url":"https://api.github.com/repos/symfony-cmf/resource/tags","blobs_url":"https://api.github.com/repos/symfony-cmf/resource/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony-cmf/resource/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony-cmf/resource/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony-cmf/resource/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony-cmf/resource/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony-cmf/resource/languages","stargazers_url":"https://api.github.com/repos/symfony-cmf/resource/stargazers","contributors_url":"https://api.github.com/repos/symfony-cmf/resource/contributors","subscribers_url":"https://api.github.com/repos/symfony-cmf/resource/subscribers","subscription_url":"https://api.github.com/repos/symfony-cmf/resource/subscription","commits_url":"https://api.github.com/repos/symfony-cmf/resource/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony-cmf/resource/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony-cmf/resource/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony-cmf/resource/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony-cmf/resource/contents/{+path}","compare_url":"https://api.github.com/repos/symfony-cmf/resource/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony-cmf/resource/merges","archive_url":"https://api.github.com/repos/symfony-cmf/resource/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony-cmf/resource/downloads","issues_url":"https://api.github.com/repos/symfony-cmf/resource/issues{/number}","pulls_url":"https://api.github.com/repos/symfony-cmf/resource/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony-cmf/resource/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony-cmf/resource/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony-cmf/resource/labels{/name}","releases_url":"https://api.github.com/repos/symfony-cmf/resource/releases{/id}","deployments_url":"https://api.github.com/repos/symfony-cmf/resource/deployments","created_at":"2014-11-22T09:30:23Z","updated_at":"2016-04-07T08:02:09Z","pushed_at":"2016-05-25T08:56:24Z","git_url":"git://github.com/symfony-cmf/resource.git","ssh_url":"git@github.com:symfony-cmf/resource.git","clone_url":"https://github.com/symfony-cmf/resource.git","svn_url":"https://github.com/symfony-cmf/resource","homepage":null,"size":152,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":9,"forks":4,"open_issues":9,"watchers":0,"default_branch":"master"}},"base":{"label":"symfony-cmf:master","ref":"master","sha":"7bbae2da73af93bc59f54fcc3fef6383fca501cd","user":{"login":"symfony-cmf","id":342045,"avatar_url":"https://avatars.githubusercontent.com/u/342045?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony-cmf","html_url":"https://github.com/symfony-cmf","followers_url":"https://api.github.com/users/symfony-cmf/followers","following_url":"https://api.github.com/users/symfony-cmf/following{/other_user}","gists_url":"https://api.github.com/users/symfony-cmf/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony-cmf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony-cmf/subscriptions","organizations_url":"https://api.github.com/users/symfony-cmf/orgs","repos_url":"https://api.github.com/users/symfony-cmf/repos","events_url":"https://api.github.com/users/symfony-cmf/events{/privacy}","received_events_url":"https://api.github.com/users/symfony-cmf/received_events","type":"Organization","site_admin":false},"repo":{"id":26994566,"name":"resource","full_name":"symfony-cmf/resource","owner":{"login":"symfony-cmf","id":342045,"avatar_url":"https://avatars.githubusercontent.com/u/342045?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony-cmf","html_url":"https://github.com/symfony-cmf","followers_url":"https://api.github.com/users/symfony-cmf/followers","following_url":"https://api.github.com/users/symfony-cmf/following{/other_user}","gists_url":"https://api.github.com/users/symfony-cmf/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony-cmf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony-cmf/subscriptions","organizations_url":"https://api.github.com/users/symfony-cmf/orgs","repos_url":"https://api.github.com/users/symfony-cmf/repos","events_url":"https://api.github.com/users/symfony-cmf/events{/privacy}","received_events_url":"https://api.github.com/users/symfony-cmf/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony-cmf/resource","description":"CMF Resource Component","fork":false,"url":"https://api.github.com/repos/symfony-cmf/resource","forks_url":"https://api.github.com/repos/symfony-cmf/resource/forks","keys_url":"https://api.github.com/repos/symfony-cmf/resource/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony-cmf/resource/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony-cmf/resource/teams","hooks_url":"https://api.github.com/repos/symfony-cmf/resource/hooks","issue_events_url":"https://api.github.com/repos/symfony-cmf/resource/issues/events{/number}","events_url":"https://api.github.com/repos/symfony-cmf/resource/events","assignees_url":"https://api.github.com/repos/symfony-cmf/resource/assignees{/user}","branches_url":"https://api.github.com/repos/symfony-cmf/resource/branches{/branch}","tags_url":"https://api.github.com/repos/symfony-cmf/resource/tags","blobs_url":"https://api.github.com/repos/symfony-cmf/resource/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony-cmf/resource/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony-cmf/resource/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony-cmf/resource/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony-cmf/resource/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony-cmf/resource/languages","stargazers_url":"https://api.github.com/repos/symfony-cmf/resource/stargazers","contributors_url":"https://api.github.com/repos/symfony-cmf/resource/contributors","subscribers_url":"https://api.github.com/repos/symfony-cmf/resource/subscribers","subscription_url":"https://api.github.com/repos/symfony-cmf/resource/subscription","commits_url":"https://api.github.com/repos/symfony-cmf/resource/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony-cmf/resource/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony-cmf/resource/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony-cmf/resource/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony-cmf/resource/contents/{+path}","compare_url":"https://api.github.com/repos/symfony-cmf/resource/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony-cmf/resource/merges","archive_url":"https://api.github.com/repos/symfony-cmf/resource/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony-cmf/resource/downloads","issues_url":"https://api.github.com/repos/symfony-cmf/resource/issues{/number}","pulls_url":"https://api.github.com/repos/symfony-cmf/resource/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony-cmf/resource/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony-cmf/resource/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony-cmf/resource/labels{/name}","releases_url":"https://api.github.com/repos/symfony-cmf/resource/releases{/id}","deployments_url":"https://api.github.com/repos/symfony-cmf/resource/deployments","created_at":"2014-11-22T09:30:23Z","updated_at":"2016-04-07T08:02:09Z","pushed_at":"2016-05-25T08:56:24Z","git_url":"git://github.com/symfony-cmf/resource.git","ssh_url":"git@github.com:symfony-cmf/resource.git","clone_url":"https://github.com/symfony-cmf/resource.git","svn_url":"https://github.com/symfony-cmf/resource","homepage":null,"size":152,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":9,"forks":4,"open_issues":9,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony-cmf/resource/pulls/19"},"html":{"href":"https://github.com/symfony-cmf/resource/pull/19"},"issue":{"href":"https://api.github.com/repos/symfony-cmf/resource/issues/19"},"comments":{"href":"https://api.github.com/repos/symfony-cmf/resource/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony-cmf/resource/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony-cmf/resource/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony-cmf/resource/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/symfony-cmf/resource/statuses/dc64748e611c45da40da93fae5b61c54611f18e3"}}}}
{"actor":{"display_login":"dantleech"}}