{"action":"created","issue":{"url":"https://api.github.com/repos/contao/core-bundle/issues/474","repository_url":"https://api.github.com/repos/contao/core-bundle","labels_url":"https://api.github.com/repos/contao/core-bundle/issues/474/labels{/name}","comments_url":"https://api.github.com/repos/contao/core-bundle/issues/474/comments","events_url":"https://api.github.com/repos/contao/core-bundle/issues/474/events","html_url":"https://github.com/contao/core-bundle/pull/474","id":147454235,"number":474,"title":"[RTM] Added PaletteManipulator","user":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/contao/core-bundle/labels/feature","name":"feature","color":"3364b7"}],"state":"closed","locked":false,"assignee":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/contao/core-bundle/milestones/7","html_url":"https://github.com/contao/core-bundle/milestones/4.2.0","labels_url":"https://api.github.com/repos/contao/core-bundle/milestones/7/labels","id":1404782,"number":7,"title":"4.2.0","description":"Contao 4.2.0 (feature release)","creator":{"login":"leofeyer","id":1192057,"avatar_url":"https://avatars.githubusercontent.com/u/1192057?v=3","gravatar_id":"","url":"https://api.github.com/users/leofeyer","html_url":"https://github.com/leofeyer","followers_url":"https://api.github.com/users/leofeyer/followers","following_url":"https://api.github.com/users/leofeyer/following{/other_user}","gists_url":"https://api.github.com/users/leofeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/leofeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leofeyer/subscriptions","organizations_url":"https://api.github.com/users/leofeyer/orgs","repos_url":"https://api.github.com/users/leofeyer/repos","events_url":"https://api.github.com/users/leofeyer/events{/privacy}","received_events_url":"https://api.github.com/users/leofeyer/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":21,"state":"open","created_at":"2015-11-10T15:44:38Z","updated_at":"2016-04-22T19:17:01Z","due_on":null,"closed_at":null},"comments":14,"created_at":"2016-04-11T14:51:41Z","updated_at":"2016-04-25T09:20:49Z","closed_at":"2016-04-22T19:17:01Z","pull_request":{"url":"https://api.github.com/repos/contao/core-bundle/pulls/474","html_url":"https://github.com/contao/core-bundle/pull/474","diff_url":"https://github.com/contao/core-bundle/pull/474.diff","patch_url":"https://github.com/contao/core-bundle/pull/474.patch"},"body":"`PaletteManipulator` is finally a helper tool to add fields in existing DCA palettes. It handles the following cases:\r\n - Add field after existing field\r\n - Add field before existing field\r\n - Append field to legend\r\n - Prepend field to legend\r\n - Add new legend and fields after existing legend\r\n - Add new legend and fields before existing legend\r\n\r\n\r\nIt is intentionally kept as simple as possible. I did not want to introduce object-oriented palettes, as I doubt that would be backwards compatible. The class is simply a helper to *string replace*.\r\n\r\nI'm actually in need of such a tool to continue working on https://github.com/contao/core-bundle/pull/471. There's a field `tl_layout.calendarfeeds` and `tl_layout.newsfeeds` which should not be in `core-bundle` (see https://github.com/contao/core-bundle/blob/master/src/Resources/contao/dca/tl_layout.php#L100). \r\n\r\n**Example how to add `tl_layout.calendarfeeds` fields:**\r\n```php\r\n// CalendarBundle/Resources/contao/dca/tl_content.php\r\n$GLOBALS['TL_DCA']['tl_layout']['palettes']['default'] = \r\n    PaletteManipulator::append('feed_legend', 'calendarfeeds')\r\n    ->setFallback(\r\n        PaletteManipulator::afterLegend('picturefill_legend', 'feed_legend', 'calendarfeeds')\r\n    )\r\n    ->applyTo($GLOBALS['TL_DCA']['tl_layout']['palettes']['default'])\r\n````\r\n\r\nWhat it does:\r\n 1. Try to append field `calendarfeeds` (could also be an array of fields) to legend `feed_legend`.\r\n 2. If 1. fails, add new legend `feed_legend` with new fields after `picturefill_legend`\r\n 3. If 2. would fail (which it should not in core…), it would simply append the new legend at the end"},"comment":{"url":"https://api.github.com/repos/contao/core-bundle/issues/comments/214225659","html_url":"https://github.com/contao/core-bundle/pull/474#issuecomment-214225659","issue_url":"https://api.github.com/repos/contao/core-bundle/issues/474","id":214225659,"user":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"created_at":"2016-04-25T09:20:49Z","updated_at":"2016-04-25T09:20:49Z","body":"FYI I'm not very happing with your merge. You removed a lot of my comments on how methods and arguments work, and I don't think thats a good thing…"}}