{"action":"created","comment":{"url":"https://api.github.com/repos/backdrop/backdrop/pulls/comments/39475650","id":39475650,"diff_hunk":"@@ -196,6 +196,191 @@ function hook_layout_renderer_info() {\n }\n \n /**\n+ * Respond to a block being removed from a layout.\n+ *\n+ * This hook is invoked from Layout::removeBlock() after a block has been \n+ * removed from a layout.\n+ * In the context of the Layout Builder User Interface, this hook is \n+ * executed when a user clicks the \"Remove block\" link in the dropbutton\n+ * which displays the block edit options.\n+ * In a custom module, if custom settings have been saved as a result of\n+ * a hook_block_save() operation, hook_layout_block_remove() allows\n+ * these settings to be deleted if the block is removed before the layout\n+ * is saved. \n+ *\n+ * @param Layout $layout\n+ *   The layout object from which the block is being removed.\n+ * @param Block $block\n+ *   The block object which is being removed.\n+ *\n+ * @see hook_block_save()\n+ * @see hook_block_add()\n+ *\n+ * @ingroup layout_api_hooks\n+ */\n+function hook_layout_block_remove(Block $block, Layout $layout) {\n+  if ($block->delta == 'my_block') {\n+    config_set('my_module', 'custom_settings', array());\n+  }\n+}\n+\n+/**\n+ * Respond to a block being programmatically added to a layout.\n+ *\n+ * This hook is invoked from Layout::addBlock() after a block has been \n+ * programmatically added to a region in a layout.\n+ * In the context of the Layout Builder User Interface, this hook does NOT run\n+ * after a user has clicked the \"Add Block\" button to insert the block into a \n+ * region.\n+ * To respond to a block being added via Layout Builder, use hook_block_save().\n+ *\n+ * @param Layout $layout\n+ *   The layout object to which the block is being added.\n+ * @param Block $block\n+ *   The block object which is being added.\n+ *\n+ * @see hook_block_save()\n+ * @see hook_block_remove()\n+ *\n+ * @ingroup layout_api_hooks\n+ */\n+function hook_layout_block_add(Block $block, Layout $layout) {\n+  if ($block->delta == 'my_block') {\n+    config_set('my_module', 'custom_settings', $layout->content[$block->uuid]);\n+  }\n+}\n+\n+/**\n+ * Respond to a layout being reverted.\n+ *\n+ * Layouts can be reverted only if the configuration is provided\n+ * by a module. Layouts created in the Layout Builder User Interface\n+ * cannot be reverted. \n+ * A layout revert operation results in deletion of the existing\n+ * layout configuration and replacement with the default configuration\n+ * from the providing module. \n+ * This hook is invoked from Layout::Revert() after a layout has been \n+ * reverted and the new configuration has been inserted into the live\n+ * config directory and the layout cache has been cleared.\n+ *\n+ * @param Layout $layout\n+ *   The old layout object that has just been deleted.\n+ *\n+ * @ingroup layout_api_hooks\n+ */\n+function hook_layout_revert(Layout $old_layout) {\n+  if ($old_layout == 'my_layout') {\n+    my_custom_function();\n+  }\n+  // Get the new (reverted) configuration.\n+  $new_config = config_get('layout.layout.' . $old_layout->name);\n+}\n+\n+/**\n+ * Respond to a layout being deleted.\n+ *\n+ * This hook is invoked from Layout::Delete() after a layout has been \n+ * deleted.\n+ *\n+ * @param Layout $layout\n+ *   The layout object that was deleted.\n+ *\n+ * @ingroup layout_api_hooks\n+ */\n+function hook_layout_delete(Layout $layout) {\n+  if ($layout->path == 'my_path') {\n+    my_custom_function();\n+  }\n+}\n+\n+/**\n+ * Respond to a layout being enabled.\n+ *\n+ * This hook is invoked from Layout::Enable() after a layout has been \n+ * enabled.\n+ *\n+ * @param Layout $layout\n+ *   The layout object that was enabled.\n+ *\n+ * @ingroup layout_api_hooks\n+ */\n+function hook_layout_enable(Layout $layout) {\n+  if ($layout->path == 'my_path') {\n+    my_custom_function();\n+  }\n+}\n+\n+/**\n+ * Respond to a layout being disabled.\n+ *\n+ * This hook is invoked from Layout::Disable() after a layout has been \n+ * disabled.\n+ *\n+ * @param Layout $layout\n+ *   The layout object that was disabled.\n+ *\n+ * @ingroup layout_api_hooks\n+ */\n+function hook_layout_disable(Layout $layout) {\n+  if ($layout->path == 'my_path') {\n+    my_custom_function();\n+  }\n+}\n+\n+/**\n+ * Respond to updates to a layout.\n+ *\n+ * This hook is invoked from Layout::Save() after a layout has been saved\n+ * to configuration.\n+ *\n+ * @param Layout $layout\n+ *   The layout object that was saved.\n+ *\n+ * @ingroup layout_api_hooks\n+ */\n+function hook_layout_update(Layout $layout) {\n+  if ($layout->path == 'my_path') {\n+    my_custom_function();\n+  }\n+}\n+\n+/**\n+ * Respond to insertion of a layout.\n+ *\n+ * This hook is invoked from Layout::Save() after a layout has been saved\n+ * to configuration.\n+ *\n+ * @param Layout $layout\n+ *   The layout object that was saved.\n+ *\n+ * @ingroup layout_api_hooks\n+ */\n+function hook_layout_insert(Layout $layout) {\n+  if ($layout->path == 'my_path') {\n+    my_custom_function();\n+  }\n+}\n+\n+/**\n+ * Act on a layout being inserted or updated.\n+ *\n+ * This hook is invoked from Layout::Save() before the layout is saved to","path":"core/modules/layout/layout.api.php","position":172,"original_position":172,"commit_id":"4ee8a0ebe33e108e1b20cd40de952b03ac0e5ae8","original_commit_id":"4ee8a0ebe33e108e1b20cd40de952b03ac0e5ae8","user":{"login":"quicksketch","id":100206,"avatar_url":"https://avatars.githubusercontent.com/u/100206?v=3","gravatar_id":"","url":"https://api.github.com/users/quicksketch","html_url":"https://github.com/quicksketch","followers_url":"https://api.github.com/users/quicksketch/followers","following_url":"https://api.github.com/users/quicksketch/following{/other_user}","gists_url":"https://api.github.com/users/quicksketch/gists{/gist_id}","starred_url":"https://api.github.com/users/quicksketch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quicksketch/subscriptions","organizations_url":"https://api.github.com/users/quicksketch/orgs","repos_url":"https://api.github.com/users/quicksketch/repos","events_url":"https://api.github.com/users/quicksketch/events{/privacy}","received_events_url":"https://api.github.com/users/quicksketch/received_events","type":"User","site_admin":false},"body":"`Layout::Save()` => `Layout::save()`","created_at":"2015-09-15T05:27:38Z","updated_at":"2015-09-15T05:27:38Z","html_url":"https://github.com/backdrop/backdrop/pull/1017#discussion_r39475650","pull_request_url":"https://api.github.com/repos/backdrop/backdrop/pulls/1017","_links":{"self":{"href":"https://api.github.com/repos/backdrop/backdrop/pulls/comments/39475650"},"html":{"href":"https://github.com/backdrop/backdrop/pull/1017#discussion_r39475650"},"pull_request":{"href":"https://api.github.com/repos/backdrop/backdrop/pulls/1017"}}},"pull_request":{"url":"https://api.github.com/repos/backdrop/backdrop/pulls/1017","id":42836113,"html_url":"https://github.com/backdrop/backdrop/pull/1017","diff_url":"https://github.com/backdrop/backdrop/pull/1017.diff","patch_url":"https://github.com/backdrop/backdrop/pull/1017.patch","issue_url":"https://api.github.com/repos/backdrop/backdrop/issues/1017","number":1017,"state":"open","locked":false,"title":"Issue #767: Add hooks for Layout presave/insert/update","user":{"login":"docwilmot","id":1042283,"avatar_url":"https://avatars.githubusercontent.com/u/1042283?v=3","gravatar_id":"","url":"https://api.github.com/users/docwilmot","html_url":"https://github.com/docwilmot","followers_url":"https://api.github.com/users/docwilmot/followers","following_url":"https://api.github.com/users/docwilmot/following{/other_user}","gists_url":"https://api.github.com/users/docwilmot/gists{/gist_id}","starred_url":"https://api.github.com/users/docwilmot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docwilmot/subscriptions","organizations_url":"https://api.github.com/users/docwilmot/orgs","repos_url":"https://api.github.com/users/docwilmot/repos","events_url":"https://api.github.com/users/docwilmot/events{/privacy}","received_events_url":"https://api.github.com/users/docwilmot/received_events","type":"User","site_admin":false},"body":"- Also added hooks for disable, enable and revert.\r\n- Modified `layout.admin.inc` to actually use layout class functions for\r\ndisabling and enabling.\r\n\r\nFix for: https://github.com/backdrop/backdrop-issues/issues/767","created_at":"2015-08-19T16:36:51Z","updated_at":"2015-09-15T05:27:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"efdee506f99cc15a4f987f09f9216706a7b2518d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/backdrop/backdrop/pulls/1017/commits","review_comments_url":"https://api.github.com/repos/backdrop/backdrop/pulls/1017/comments","review_comment_url":"https://api.github.com/repos/backdrop/backdrop/pulls/comments{/number}","comments_url":"https://api.github.com/repos/backdrop/backdrop/issues/1017/comments","statuses_url":"https://api.github.com/repos/backdrop/backdrop/statuses/4ee8a0ebe33e108e1b20cd40de952b03ac0e5ae8","head":{"label":"docwilmot:layout-hooks","ref":"layout-hooks","sha":"4ee8a0ebe33e108e1b20cd40de952b03ac0e5ae8","user":{"login":"docwilmot","id":1042283,"avatar_url":"https://avatars.githubusercontent.com/u/1042283?v=3","gravatar_id":"","url":"https://api.github.com/users/docwilmot","html_url":"https://github.com/docwilmot","followers_url":"https://api.github.com/users/docwilmot/followers","following_url":"https://api.github.com/users/docwilmot/following{/other_user}","gists_url":"https://api.github.com/users/docwilmot/gists{/gist_id}","starred_url":"https://api.github.com/users/docwilmot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docwilmot/subscriptions","organizations_url":"https://api.github.com/users/docwilmot/orgs","repos_url":"https://api.github.com/users/docwilmot/repos","events_url":"https://api.github.com/users/docwilmot/events{/privacy}","received_events_url":"https://api.github.com/users/docwilmot/received_events","type":"User","site_admin":false},"repo":{"id":28466458,"name":"backdrop","full_name":"docwilmot/backdrop","owner":{"login":"docwilmot","id":1042283,"avatar_url":"https://avatars.githubusercontent.com/u/1042283?v=3","gravatar_id":"","url":"https://api.github.com/users/docwilmot","html_url":"https://github.com/docwilmot","followers_url":"https://api.github.com/users/docwilmot/followers","following_url":"https://api.github.com/users/docwilmot/following{/other_user}","gists_url":"https://api.github.com/users/docwilmot/gists{/gist_id}","starred_url":"https://api.github.com/users/docwilmot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docwilmot/subscriptions","organizations_url":"https://api.github.com/users/docwilmot/orgs","repos_url":"https://api.github.com/users/docwilmot/repos","events_url":"https://api.github.com/users/docwilmot/events{/privacy}","received_events_url":"https://api.github.com/users/docwilmot/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/docwilmot/backdrop","description":"Backdrop core code repository.","fork":true,"url":"https://api.github.com/repos/docwilmot/backdrop","forks_url":"https://api.github.com/repos/docwilmot/backdrop/forks","keys_url":"https://api.github.com/repos/docwilmot/backdrop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docwilmot/backdrop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docwilmot/backdrop/teams","hooks_url":"https://api.github.com/repos/docwilmot/backdrop/hooks","issue_events_url":"https://api.github.com/repos/docwilmot/backdrop/issues/events{/number}","events_url":"https://api.github.com/repos/docwilmot/backdrop/events","assignees_url":"https://api.github.com/repos/docwilmot/backdrop/assignees{/user}","branches_url":"https://api.github.com/repos/docwilmot/backdrop/branches{/branch}","tags_url":"https://api.github.com/repos/docwilmot/backdrop/tags","blobs_url":"https://api.github.com/repos/docwilmot/backdrop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docwilmot/backdrop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docwilmot/backdrop/git/refs{/sha}","trees_url":"https://api.github.com/repos/docwilmot/backdrop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docwilmot/backdrop/statuses/{sha}","languages_url":"https://api.github.com/repos/docwilmot/backdrop/languages","stargazers_url":"https://api.github.com/repos/docwilmot/backdrop/stargazers","contributors_url":"https://api.github.com/repos/docwilmot/backdrop/contributors","subscribers_url":"https://api.github.com/repos/docwilmot/backdrop/subscribers","subscription_url":"https://api.github.com/repos/docwilmot/backdrop/subscription","commits_url":"https://api.github.com/repos/docwilmot/backdrop/commits{/sha}","git_commits_url":"https://api.github.com/repos/docwilmot/backdrop/git/commits{/sha}","comments_url":"https://api.github.com/repos/docwilmot/backdrop/comments{/number}","issue_comment_url":"https://api.github.com/repos/docwilmot/backdrop/issues/comments{/number}","contents_url":"https://api.github.com/repos/docwilmot/backdrop/contents/{+path}","compare_url":"https://api.github.com/repos/docwilmot/backdrop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docwilmot/backdrop/merges","archive_url":"https://api.github.com/repos/docwilmot/backdrop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docwilmot/backdrop/downloads","issues_url":"https://api.github.com/repos/docwilmot/backdrop/issues{/number}","pulls_url":"https://api.github.com/repos/docwilmot/backdrop/pulls{/number}","milestones_url":"https://api.github.com/repos/docwilmot/backdrop/milestones{/number}","notifications_url":"https://api.github.com/repos/docwilmot/backdrop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docwilmot/backdrop/labels{/name}","releases_url":"https://api.github.com/repos/docwilmot/backdrop/releases{/id}","created_at":"2014-12-25T01:15:09Z","updated_at":"2015-04-03T15:20:10Z","pushed_at":"2015-09-15T04:41:53Z","git_url":"git://github.com/docwilmot/backdrop.git","ssh_url":"git@github.com:docwilmot/backdrop.git","clone_url":"https://github.com/docwilmot/backdrop.git","svn_url":"https://github.com/docwilmot/backdrop","homepage":"","size":48252,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"1.x"}},"base":{"label":"backdrop:1.x","ref":"1.x","sha":"3952898959e3698358ec08cb32bfaca74f32e6d9","user":{"login":"backdrop","id":5283039,"avatar_url":"https://avatars.githubusercontent.com/u/5283039?v=3","gravatar_id":"","url":"https://api.github.com/users/backdrop","html_url":"https://github.com/backdrop","followers_url":"https://api.github.com/users/backdrop/followers","following_url":"https://api.github.com/users/backdrop/following{/other_user}","gists_url":"https://api.github.com/users/backdrop/gists{/gist_id}","starred_url":"https://api.github.com/users/backdrop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backdrop/subscriptions","organizations_url":"https://api.github.com/users/backdrop/orgs","repos_url":"https://api.github.com/users/backdrop/repos","events_url":"https://api.github.com/users/backdrop/events{/privacy}","received_events_url":"https://api.github.com/users/backdrop/received_events","type":"Organization","site_admin":false},"repo":{"id":12285928,"name":"backdrop","full_name":"backdrop/backdrop","owner":{"login":"backdrop","id":5283039,"avatar_url":"https://avatars.githubusercontent.com/u/5283039?v=3","gravatar_id":"","url":"https://api.github.com/users/backdrop","html_url":"https://github.com/backdrop","followers_url":"https://api.github.com/users/backdrop/followers","following_url":"https://api.github.com/users/backdrop/following{/other_user}","gists_url":"https://api.github.com/users/backdrop/gists{/gist_id}","starred_url":"https://api.github.com/users/backdrop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backdrop/subscriptions","organizations_url":"https://api.github.com/users/backdrop/orgs","repos_url":"https://api.github.com/users/backdrop/repos","events_url":"https://api.github.com/users/backdrop/events{/privacy}","received_events_url":"https://api.github.com/users/backdrop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/backdrop/backdrop","description":"Backdrop core code repository.","fork":false,"url":"https://api.github.com/repos/backdrop/backdrop","forks_url":"https://api.github.com/repos/backdrop/backdrop/forks","keys_url":"https://api.github.com/repos/backdrop/backdrop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/backdrop/backdrop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/backdrop/backdrop/teams","hooks_url":"https://api.github.com/repos/backdrop/backdrop/hooks","issue_events_url":"https://api.github.com/repos/backdrop/backdrop/issues/events{/number}","events_url":"https://api.github.com/repos/backdrop/backdrop/events","assignees_url":"https://api.github.com/repos/backdrop/backdrop/assignees{/user}","branches_url":"https://api.github.com/repos/backdrop/backdrop/branches{/branch}","tags_url":"https://api.github.com/repos/backdrop/backdrop/tags","blobs_url":"https://api.github.com/repos/backdrop/backdrop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/backdrop/backdrop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/backdrop/backdrop/git/refs{/sha}","trees_url":"https://api.github.com/repos/backdrop/backdrop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/backdrop/backdrop/statuses/{sha}","languages_url":"https://api.github.com/repos/backdrop/backdrop/languages","stargazers_url":"https://api.github.com/repos/backdrop/backdrop/stargazers","contributors_url":"https://api.github.com/repos/backdrop/backdrop/contributors","subscribers_url":"https://api.github.com/repos/backdrop/backdrop/subscribers","subscription_url":"https://api.github.com/repos/backdrop/backdrop/subscription","commits_url":"https://api.github.com/repos/backdrop/backdrop/commits{/sha}","git_commits_url":"https://api.github.com/repos/backdrop/backdrop/git/commits{/sha}","comments_url":"https://api.github.com/repos/backdrop/backdrop/comments{/number}","issue_comment_url":"https://api.github.com/repos/backdrop/backdrop/issues/comments{/number}","contents_url":"https://api.github.com/repos/backdrop/backdrop/contents/{+path}","compare_url":"https://api.github.com/repos/backdrop/backdrop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/backdrop/backdrop/merges","archive_url":"https://api.github.com/repos/backdrop/backdrop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/backdrop/backdrop/downloads","issues_url":"https://api.github.com/repos/backdrop/backdrop/issues{/number}","pulls_url":"https://api.github.com/repos/backdrop/backdrop/pulls{/number}","milestones_url":"https://api.github.com/repos/backdrop/backdrop/milestones{/number}","notifications_url":"https://api.github.com/repos/backdrop/backdrop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/backdrop/backdrop/labels{/name}","releases_url":"https://api.github.com/repos/backdrop/backdrop/releases{/id}","created_at":"2013-08-22T01:50:58Z","updated_at":"2015-09-13T16:08:07Z","pushed_at":"2015-09-15T04:59:01Z","git_url":"git://github.com/backdrop/backdrop.git","ssh_url":"git@github.com:backdrop/backdrop.git","clone_url":"https://github.com/backdrop/backdrop.git","svn_url":"https://github.com/backdrop/backdrop","homepage":"","size":57595,"stargazers_count":535,"watchers_count":535,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":178,"mirror_url":null,"open_issues_count":67,"forks":178,"open_issues":67,"watchers":535,"default_branch":"1.x"}},"_links":{"self":{"href":"https://api.github.com/repos/backdrop/backdrop/pulls/1017"},"html":{"href":"https://github.com/backdrop/backdrop/pull/1017"},"issue":{"href":"https://api.github.com/repos/backdrop/backdrop/issues/1017"},"comments":{"href":"https://api.github.com/repos/backdrop/backdrop/issues/1017/comments"},"review_comments":{"href":"https://api.github.com/repos/backdrop/backdrop/pulls/1017/comments"},"review_comment":{"href":"https://api.github.com/repos/backdrop/backdrop/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/backdrop/backdrop/pulls/1017/commits"},"statuses":{"href":"https://api.github.com/repos/backdrop/backdrop/statuses/4ee8a0ebe33e108e1b20cd40de952b03ac0e5ae8"}}}}