-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #611 from localgovdrupal/feature/3.x/543-content-lock
[3.x] Add but don't enable the Content Lock module
- Loading branch information
Showing
8 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# LocalGov Drupal Content Lock | ||
|
||
Customises the Content Lock module for use with LocalGov Drupal. | ||
|
||
When enabled this module will: | ||
|
||
* Enable the Content Lock and Content Lock Timeout modules. | ||
* Enables content locking for all enabled content types. | ||
* Adds a link to the content lock view to the content admin page and the admin menu. | ||
|
||
The default content lock timeout is left at 30 minutes. This can be changed at /admin/config/content/content_lock/timeout. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: LocalGov Content Lock | ||
type: module | ||
description: Customises the Content Lock module for use with LocalGov Drupal | ||
package: LocalGov Drupal | ||
core_version_requirement: ^9 || ^10 | ||
dependencies: | ||
- content_lock:content_lock | ||
- content_lock:content_lock_timeout |
22 changes: 22 additions & 0 deletions
22
modules/localgov_content_lock/localgov_content_lock.install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Install, update and uninstall functions for the LocalGov Content Lock module. | ||
*/ | ||
|
||
/** | ||
* Implements hook_install(). | ||
*/ | ||
function localgov_content_lock_install($is_syncing) { | ||
|
||
if ($is_syncing) { | ||
return; | ||
} | ||
|
||
// Enable content locking on all content types. | ||
$config_factory = \Drupal::configFactory(); | ||
$content_lock_config = $config_factory->getEditable('content_lock.settings'); | ||
$content_lock_config->set('types.node', ['*' => '*']); | ||
$content_lock_config->save(); | ||
} |
4 changes: 4 additions & 0 deletions
4
modules/localgov_content_lock/localgov_content_lock.links.menu.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
localgov_content_lock.locked_content: | ||
title: 'Locked content' | ||
parent: system.admin_content | ||
route_name: view.locked_content.page_1 |
5 changes: 5 additions & 0 deletions
5
modules/localgov_content_lock/localgov_content_lock.links.task.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
localgov_content_lock.locked_content: | ||
title: 'Locked' | ||
parent_id: system.admin_content | ||
route_name: view.locked_content.page_1 | ||
weight: 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Primary module hooks for LocalGov Content Lock module. | ||
*/ |
58 changes: 58 additions & 0 deletions
58
modules/localgov_content_lock/tests/src/Functional/ContentLockTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\localgov_content_lock\Functional; | ||
|
||
use Drupal\Tests\BrowserTestBase; | ||
|
||
/** | ||
* Functional tests for LocalGov Content Lock module. | ||
*/ | ||
class ContentLockTest extends BrowserTestBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $profile = 'localgov'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $defaultTheme = 'stark'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static $modules = [ | ||
'localgov_content_lock', | ||
]; | ||
|
||
/** | ||
* Test content lock configuration. | ||
*/ | ||
public function testContentLockConfiguration() { | ||
|
||
$user = $this->drupalCreateUser([], 'test_user', TRUE); | ||
$this->drupalLogin($user); | ||
|
||
// Create a node. | ||
$this->drupalGet('/node/add/localgov_services_page'); | ||
$title = $this->randomMachineName(); | ||
$this->submitForm( | ||
[ | ||
'title[0][value]' => $title, | ||
'body[0][summary]' => 'Test content lock', | ||
'body[0][value]' => 'Test content lock', | ||
], | ||
'Save' | ||
); | ||
$this->assertSession()->pageTextContains('Service page ' . $title . ' has been created.'); | ||
$nid = $this->drupalGetNodeByTitle($title)->id(); | ||
|
||
// Check that the node gets locked when editing. | ||
$this->drupalGet('/node/' . $nid . '/edit'); | ||
$this->assertSession()->pageTextContains('This content is now locked against simultaneous editing.'); | ||
$this->drupalGet('/admin/content/locked-content'); | ||
$this->assertSession()->pageTextContains($title); | ||
} | ||
|
||
} |