contrib modules updates
This commit is contained in:
@@ -4,21 +4,13 @@ sudo: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- env: DRUPAL=8.5.x
|
||||
php: 5.5
|
||||
- env: DRUPAL=8.5.x
|
||||
php: 5.6
|
||||
- env: DRUPAL=8.5.x
|
||||
- env: DRUPAL=8.6.x
|
||||
php: 7.1
|
||||
- env: DRUPAL=8.5.x
|
||||
- env: DRUPAL=8.6.x
|
||||
php: 7.2
|
||||
- env: DRUPAL=8.6.x
|
||||
php: 5.5
|
||||
- env: DRUPAL=8.6.x
|
||||
php: 5.6
|
||||
- env: DRUPAL=8.6.x
|
||||
- env: DRUPAL=8.7.x
|
||||
php: 7.1
|
||||
- env: DRUPAL=8.6.x
|
||||
- env: DRUPAL=8.7.x
|
||||
php: 7.2
|
||||
|
||||
addons:
|
||||
@@ -94,11 +86,11 @@ before_script:
|
||||
- until curl -s example.com:8080; do true; done > /dev/null
|
||||
|
||||
script:
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 4 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 4 --types "PHPUnit-Kernel" --php `which php` --url http://example.com:8080 domain
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 4 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain_access
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 4 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain_alias
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 4 --types "PHPUnit-Kernel" --php `which php` --url http://example.com:8080 domain_alias
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 4 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain_config
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 4 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain_content
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 4 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain_source
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 20 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 20 --types "PHPUnit-Kernel" --php `which php` --url http://example.com:8080 domain
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 20 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain_access
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 20 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain_alias
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 20 --types "PHPUnit-Kernel" --php `which php` --url http://example.com:8080 domain_alias
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 20 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain_config
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 20 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain_content
|
||||
- php core/scripts/run-tests.sh --suppress-deprecations --verbose --color --concurrency 20 --types "PHPUnit-Functional" --php `which php` --url http://example.com:8080 domain_source
|
||||
|
||||
@@ -16,6 +16,7 @@ Changelog
|
||||
12-FEB-2018 8.x-1.0-alpha12
|
||||
07-MAR-2018 8.x-1.0-alpha13
|
||||
19-OCT-2018 8.x-1.0-alpha14
|
||||
21-FEB-2019 8.x-1.0-alpha15
|
||||
|
||||
Status
|
||||
====
|
||||
@@ -113,7 +114,7 @@ marked with [x] are considered complete.
|
||||
- [x] Check domain responses on configuration forms
|
||||
- [x] Remove deprecated `entity_get_form_display`
|
||||
- [x] Implement theme functions or twig templates where proper
|
||||
- [ ] Advanced drush integration / complete labelled tasks
|
||||
- [x] Advanced drush integration / complete labelled tasks
|
||||
- [ ] Add filter options to domain_access and domain_source views
|
||||
- [ ] Test cron handling
|
||||
- [ ] Caching strategies in DomainNegotiator
|
||||
|
||||
@@ -199,23 +199,16 @@ a beta release on Drupal.org.
|
||||
|
||||
We would like to tackle issues in that order, but feel free to work on what motivates you.
|
||||
|
||||
Testing
|
||||
Testing [](https://travis-ci.com/agentrickard/domain)
|
||||
====
|
||||
|
||||
@zerolab built a Travis definition file for automated testing! That means all pull requests will automatically run tests!
|
||||
|
||||
[](https://travis-ci.org/agentrickard/domain)
|
||||
|
||||
The module does have solid test coverage, and complete coverage is required for release.
|
||||
Right now, we mostly use SimpleTest, because it is most familiar, and much of our
|
||||
testing is about browser and http behavior.
|
||||
|
||||
If you file a pull request or patch, please (at a minimum) run the existing tests to check
|
||||
for failures. Writing additional tests will greatly speed completion, as I won't commit
|
||||
code without test coverage.
|
||||
|
||||
New tests should be written as Functional, Kernel, or Unit tests. Conversion patches that
|
||||
move Simpletests to Functional tests are welcome.
|
||||
New tests should be written in PHPUnit as Functional, Kernel, or Unit tests.
|
||||
|
||||
Because Domain requires varying http host requests to test, we can't normally use the Drupal.org
|
||||
testing infrastructure. (This may change, but we are not counting on it.)
|
||||
@@ -227,5 +220,3 @@ point to your drupal instance. I use variants of `example.com` for local tests.
|
||||
in most test cases. See `DomainTestBase::domainCreateTestDomains()` for the logic.
|
||||
|
||||
When running tests, you normally need to be on the default domain.
|
||||
|
||||
If anyone is capable of building a vagrant box to simplify testing, that would be ideal.
|
||||
|
||||
@@ -13,5 +13,14 @@
|
||||
"issues": "http://drupal.org/project/issues/domain",
|
||||
"irc": "http://irc.freenode.org/drupal-contribute",
|
||||
"source": "http://cgit.drupalcode.org/domain"
|
||||
},
|
||||
"extra": {
|
||||
"drush": {
|
||||
"services": {
|
||||
"domain/drush.services.yml": "^9",
|
||||
"domain_access/drush.services.yml": "^9",
|
||||
"domain_source/drush.services.yml": "^9"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ dependencies:
|
||||
- drupal:options
|
||||
configure: domain.admin
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
@@ -159,3 +159,19 @@ function domain_theme() {
|
||||
function template_preprocess_domain_nav_block(array &$variables) {
|
||||
$variables['items'] = $variables['items']['#items'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_hook_info().
|
||||
*/
|
||||
function domain_hook_info() {
|
||||
$hooks['domain_request_alter'] = [
|
||||
'group' => 'domain',
|
||||
];
|
||||
$hooks['domain_validate_alter'] = [
|
||||
'group' => 'domain',
|
||||
];
|
||||
$hooks['domain_references_alter'] = [
|
||||
'group' => 'domain',
|
||||
];
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
services:
|
||||
domain.commands:
|
||||
class: \Drupal\domain\Commands\DomainCommands
|
||||
tags:
|
||||
- { name: drush.command }
|
||||
@@ -75,17 +75,17 @@ class DomainAccessCheck implements AccessCheckInterface {
|
||||
// Is the domain allowed?
|
||||
// No domain, let it pass.
|
||||
if (empty($domain)) {
|
||||
return AccessResult::allowed()->setCacheMaxAge(0);
|
||||
return AccessResult::allowed()->addCacheTags(['url.site']);
|
||||
}
|
||||
// Active domain, let it pass.
|
||||
if ($domain->status()) {
|
||||
return AccessResult::allowed()->setCacheMaxAge(0);
|
||||
return AccessResult::allowed()->addCacheTags(['url.site']);
|
||||
}
|
||||
// Inactive domain, require permissions.
|
||||
else {
|
||||
$permissions = ['administer domains', 'access inactive domains'];
|
||||
$operator = 'OR';
|
||||
return AccessResult::allowedIfHasPermissions($account, $permissions, $operator)->setCacheMaxAge(0);
|
||||
return AccessResult::allowedIfHasPermissions($account, $permissions, $operator)->addCacheTags(['url.site']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Drupal\domain\Commands;
|
||||
|
||||
class DomainCommandException extends \Exception {
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -59,8 +59,15 @@ class DomainElementManager implements DomainElementManagerInterface {
|
||||
return $form;
|
||||
}
|
||||
$fields = $this->fieldList($field_name);
|
||||
$empty = FALSE;
|
||||
$disallowed = $this->disallowedOptions($form_state, $form[$field_name]);
|
||||
$empty = empty($form[$field_name]['widget']['#options']);
|
||||
if (empty($form[$field_name]['widget']['#options']) ||
|
||||
(count($form[$field_name]['widget']['#options']) == 1 &&
|
||||
isset($form[$field_name]['widget']['#options']['_none'])
|
||||
)
|
||||
) {
|
||||
$empty = TRUE;
|
||||
}
|
||||
|
||||
// If the domain form element is set as a group, and the field is not
|
||||
// assigned to another group, then move it. See
|
||||
@@ -68,7 +75,10 @@ class DomainElementManager implements DomainElementManagerInterface {
|
||||
if (isset($form['domain']) && !isset($form[$field_name]['#group'])) {
|
||||
$form[$field_name]['#group'] = 'domain';
|
||||
}
|
||||
|
||||
// If no values and we should hide the element, do so.
|
||||
if ($hide_on_disallow && $empty) {
|
||||
$form[$field_name]['#access'] = FALSE;
|
||||
}
|
||||
// Check for domains the user cannot access or the absence of any options.
|
||||
if (!empty($disallowed) || $empty) {
|
||||
// @TODO: Potentially show this information to users with permission.
|
||||
|
||||
@@ -38,7 +38,7 @@ class DomainNegotiator implements DomainNegotiatorInterface {
|
||||
/**
|
||||
* The domain storage class.
|
||||
*
|
||||
* @var \Drupal\domain\DomainStorageInterface
|
||||
* @var \Drupal\domain\DomainStorageInterface|null
|
||||
*/
|
||||
protected $domainStorage;
|
||||
|
||||
@@ -87,7 +87,6 @@ class DomainNegotiator implements DomainNegotiatorInterface {
|
||||
$this->requestStack = $requestStack;
|
||||
$this->moduleHandler = $module_handler;
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->domainStorage = $this->entityTypeManager->getStorage('domain');
|
||||
$this->configFactory = $config_factory;
|
||||
}
|
||||
|
||||
@@ -98,7 +97,7 @@ class DomainNegotiator implements DomainNegotiatorInterface {
|
||||
// @TODO: Investigate caching methods.
|
||||
$this->setHttpHost($httpHost);
|
||||
// Try to load a direct match.
|
||||
if ($domain = $this->domainStorage->loadByHostname($httpHost)) {
|
||||
if ($domain = $this->domainStorage()->loadByHostname($httpHost)) {
|
||||
// If the load worked, set an exact match flag for the hook.
|
||||
$domain->setMatchType(self::DOMAIN_MATCH_EXACT);
|
||||
}
|
||||
@@ -107,16 +106,10 @@ class DomainNegotiator implements DomainNegotiatorInterface {
|
||||
else {
|
||||
$values = ['hostname' => $httpHost];
|
||||
/** @var \Drupal\domain\DomainInterface $domain */
|
||||
$domain = $this->domainStorage->create($values);
|
||||
$domain = $this->domainStorage()->create($values);
|
||||
$domain->setMatchType(self::DOMAIN_MATCH_NONE);
|
||||
}
|
||||
|
||||
// Make sure all modules are loaded and can alter the found domains.
|
||||
// See https://www.drupal.org/node/2896434#comment-12267208.
|
||||
$this->moduleHandler->reload();
|
||||
foreach ($this->moduleHandler->getImplementations('domain_request_alter') as $module) {
|
||||
$this->moduleHandler->load($module);
|
||||
}
|
||||
// Now check with modules (like Domain Alias) that register alternate
|
||||
// lookup systems with the main module.
|
||||
$this->moduleHandler->alter('domain_request', $domain);
|
||||
@@ -126,7 +119,7 @@ class DomainNegotiator implements DomainNegotiatorInterface {
|
||||
$this->setActiveDomain($domain);
|
||||
}
|
||||
// Fallback to default domain if no match.
|
||||
elseif ($domain = $this->domainStorage->loadDefaultDomain()) {
|
||||
elseif ($domain = $this->domainStorage()->loadDefaultDomain()) {
|
||||
$this->moduleHandler->alter('domain_request', $domain);
|
||||
$domain->setMatchType(self::DOMAIN_MATCH_NONE);
|
||||
if (!empty($domain->id())) {
|
||||
@@ -180,7 +173,7 @@ class DomainNegotiator implements DomainNegotiatorInterface {
|
||||
$httpHost = $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
$hostname = !empty($httpHost) ? $httpHost : 'localhost';
|
||||
return $this->domainStorage->prepareHostname($hostname);
|
||||
return $this->domainStorage()->prepareHostname($hostname);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,13 +195,13 @@ class DomainNegotiator implements DomainNegotiatorInterface {
|
||||
*/
|
||||
public function isRegisteredDomain($hostname) {
|
||||
// Direct hostname match always passes.
|
||||
if ($domain = $this->domainStorage->loadByHostname($hostname)) {
|
||||
if ($domain = $this->domainStorage()->loadByHostname($hostname)) {
|
||||
return TRUE;
|
||||
}
|
||||
// Check for registered alias matches.
|
||||
$values = ['hostname' => $hostname];
|
||||
/** @var \Drupal\domain\DomainInterface $domain */
|
||||
$domain = $this->domainStorage->create($values);
|
||||
$domain = $this->domainStorage()->create($values);
|
||||
$domain->setMatchType(self::DOMAIN_MATCH_NONE);
|
||||
|
||||
// Now check with modules (like Domain Alias) that register alternate
|
||||
@@ -222,4 +215,17 @@ class DomainNegotiator implements DomainNegotiatorInterface {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the domain storage handler.
|
||||
*
|
||||
* @return \Drupal\domain\DomainStorageInterface
|
||||
* The domain storage handler.
|
||||
*/
|
||||
protected function domainStorage() {
|
||||
if (!$this->domainStorage) {
|
||||
$this->domainStorage = $this->entityTypeManager->getStorage('domain');
|
||||
}
|
||||
return $this->domainStorage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -132,10 +132,9 @@ class DomainValidator implements DomainValidatorInterface {
|
||||
}
|
||||
// We cannot know which Guzzle Exception class will be returned; be generic.
|
||||
catch (RequestException $e) {
|
||||
watchdog_exception('domain', $e);
|
||||
// File a general server failure.
|
||||
$domain->setResponse(500);
|
||||
return;
|
||||
return $domain->getResponse();
|
||||
}
|
||||
// Expected result (i.e. no exception thrown.)
|
||||
$domain->setResponse($request->getStatusCode());
|
||||
|
||||
@@ -343,8 +343,8 @@ class Domain extends ConfigEntityBase implements DomainInterface {
|
||||
$default->is_default = FALSE;
|
||||
$default->save();
|
||||
}
|
||||
// Ensures we have a proper domain_id.
|
||||
if ($this->isNew()) {
|
||||
// Ensures we have a proper domain_id but does not erase existing ones.
|
||||
if ($this->isNew() && empty($this->getDomainId())) {
|
||||
$this->createDomainId();
|
||||
}
|
||||
// Prevent duplicate hostname.
|
||||
|
||||
@@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
* id = "domain",
|
||||
* label = @Translation("Domain"),
|
||||
* context = {
|
||||
* "entity:domain" = @ContextDefinition("entity:domain", label = @Translation("Domain"), required = TRUE)
|
||||
* "entity:domain" = @ContextDefinition("entity:domain", label = @Translation("Domain"), required = FALSE)
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
@@ -73,7 +73,12 @@ class Domain extends ConditionPluginBase implements ContainerFactoryPluginInterf
|
||||
],
|
||||
],
|
||||
];
|
||||
return parent::buildConfigurationForm($form, $form_state);
|
||||
$form = parent::buildConfigurationForm($form, $form_state);
|
||||
if (isset($form['context_mapping']['entity:domain']['#title'])) {
|
||||
$form['context_mapping']['entity:domain']['#title'] = $this->t('Select the Domain condition');
|
||||
$form['context_mapping']['entity:domain']['#description'] = $this->t('This value must be set to "Active domain" for the context to work.');
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -9,8 +9,8 @@ hidden: TRUE
|
||||
dependencies:
|
||||
- domain
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
+3
-3
@@ -9,8 +9,8 @@ hidden: TRUE
|
||||
dependencies:
|
||||
- domain
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
@@ -8,8 +8,8 @@ dependencies:
|
||||
- drupal:node
|
||||
- domain:domain
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
services:
|
||||
domain_access.commands:
|
||||
class: \Drupal\domain_access\Commands\DomainAccessCommands
|
||||
tags:
|
||||
- { name: drush.command }
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\domain_access\Commands;
|
||||
|
||||
use Consolidation\AnnotatedCommand\AnnotationData;
|
||||
use Consolidation\AnnotatedCommand\CommandData;
|
||||
use Drupal\domain\Commands\DomainCommands;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Drush commands for the domain access module.
|
||||
*
|
||||
* These commands mainly extend base Domain commands. See the documentation at
|
||||
* https://github.com/consolidation/annotated-command for details.
|
||||
*/
|
||||
class DomainAccessCommands extends DomainCommands {
|
||||
|
||||
/**
|
||||
* Registers additional information to domain:info.
|
||||
*
|
||||
* @hook init domain:info
|
||||
*/
|
||||
public function initDomainInfo(InputInterface $input, AnnotationData $annotationData) {
|
||||
// To add a field label, append to the 'field-labels' item.
|
||||
// @TODO: watch https://github.com/consolidation/annotated-command/pull/174
|
||||
$annotationData['field-labels'] .= "\n" . 'domain_access_entities: Domain access entities';
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides additional information to domain:info.
|
||||
*
|
||||
* @hook alter domain:info
|
||||
*/
|
||||
public function alterDomainInfo($result, CommandData $commandData) {
|
||||
// Display which entities are enabled for domain by checking for the fields.
|
||||
$result['domain_access_entities'] = $this->getFieldEntities(DOMAIN_ACCESS_FIELD);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hook option domain:delete
|
||||
*/
|
||||
public function deleteOptions(Command $command, AnnotationData $annotationData) {
|
||||
$command->addOption(
|
||||
'content-assign',
|
||||
'',
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'Reassign content for Domain Access',
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hook on-event domain-delete
|
||||
*/
|
||||
public function domainAccessDomainDelete($target_domain, $options) {
|
||||
// Run our own deletion routine here.
|
||||
if (is_null($options['content-assign'])) {
|
||||
$policy_content = 'prompt';
|
||||
}
|
||||
if (!empty($options['content-assign'])) {
|
||||
if (in_array($options['content-assign'], $this->reassignment_policies, TRUE)) {
|
||||
$policy_content = $options['content-assign'];
|
||||
}
|
||||
}
|
||||
|
||||
$delete_options = [
|
||||
'entity_filter' => 'node',
|
||||
'policy' => $policy_content,
|
||||
'field' => DOMAIN_ACCESS_FIELD,
|
||||
];
|
||||
|
||||
return $this->doReassign($target_domain, $delete_options);
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -11,8 +11,8 @@ dependencies:
|
||||
- domain_access
|
||||
- taxonomy
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
@@ -7,8 +7,8 @@ package: Domain
|
||||
dependencies:
|
||||
- domain:domain
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
@@ -7,8 +7,8 @@ package: Domain
|
||||
dependencies:
|
||||
- domain:domain
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
@@ -3,7 +3,7 @@ services:
|
||||
class: Drupal\domain_config\DomainConfigOverrider
|
||||
tags:
|
||||
- { name: config.factory.override, priority: -150}
|
||||
arguments: ['@config.storage']
|
||||
arguments: ['@config.storage', '@module_handler']
|
||||
|
||||
domain_config.library.discovery.collector:
|
||||
decorates: library.discovery.collector
|
||||
|
||||
@@ -6,6 +6,7 @@ use Drupal\domain\DomainInterface;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Config\ConfigFactoryOverrideInterface;
|
||||
use Drupal\Core\Config\StorageInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
|
||||
/**
|
||||
* Domain-specific config overrides.
|
||||
@@ -29,6 +30,13 @@ class DomainConfigOverrider implements ConfigFactoryOverrideInterface {
|
||||
*/
|
||||
protected $storage;
|
||||
|
||||
/**
|
||||
* The module handler.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleHandlerInterface
|
||||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* The domain context of the request.
|
||||
*
|
||||
@@ -64,9 +72,12 @@ class DomainConfigOverrider implements ConfigFactoryOverrideInterface {
|
||||
*
|
||||
* @param \Drupal\Core\Config\StorageInterface $storage
|
||||
* The configuration storage engine.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler.
|
||||
*/
|
||||
public function __construct(StorageInterface $storage) {
|
||||
public function __construct(StorageInterface $storage, ModuleHandlerInterface $module_handler) {
|
||||
$this->storage = $storage;
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,11 +88,16 @@ class DomainConfigOverrider implements ConfigFactoryOverrideInterface {
|
||||
static $lookups;
|
||||
// Key should be a known length, so hash.
|
||||
$key = md5(implode(':', $names));
|
||||
|
||||
if (isset($lookups[$key])) {
|
||||
return $lookups[$key];
|
||||
}
|
||||
|
||||
// Set the context of the override request.
|
||||
if (empty($this->contextSet)) {
|
||||
$this->initiateContext();
|
||||
}
|
||||
|
||||
// Prepare our overrides.
|
||||
$overrides = [];
|
||||
// loadOverrides() runs on config entities, which means that if we try
|
||||
// to run this routine on our own data, then we end up in an infinite loop.
|
||||
@@ -92,9 +108,6 @@ class DomainConfigOverrider implements ConfigFactoryOverrideInterface {
|
||||
$lookups[$key] = $overrides;
|
||||
return $overrides;
|
||||
}
|
||||
if (empty($this->contextSet)) {
|
||||
$this->initiateContext();
|
||||
}
|
||||
if (!empty($this->domain)) {
|
||||
foreach ($names as $name) {
|
||||
$config_name = $this->getDomainConfigName($name, $this->domain);
|
||||
@@ -198,7 +211,11 @@ class DomainConfigOverrider implements ConfigFactoryOverrideInterface {
|
||||
// run.
|
||||
if (empty($this->domain)) {
|
||||
$this->domain = $this->domainNegotiator->getActiveDomain(TRUE);
|
||||
// Ensure the module hook cache is set properly.
|
||||
// See https://www.drupal.org/project/domain/issues/3025541
|
||||
$this->moduleHandler->resetImplementations();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
name: "Domain config hook test"
|
||||
description: "Support module for domain config testing."
|
||||
type: module
|
||||
package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
hidden: TRUE
|
||||
|
||||
dependencies: []
|
||||
|
||||
# This module represents several services that could be provided by multiple modules in the Drupal community.
|
||||
# The following are not playing nice together:
|
||||
# - A page cache policy service that uses the config factory.
|
||||
# - A module that implements hook_module_implements.
|
||||
# - A random hook that hook_module_implements wishes to control.
|
||||
# - The domain_config module (and domain negotiator service, I believe).
|
||||
|
||||
# When this module is functioning correctly, when a user logs in, there will not be a state key set.
|
||||
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1550763190
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hook implementations for this module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_user_login().
|
||||
*/
|
||||
function domain_config_hook_test_user_login($account) {
|
||||
\Drupal::state()->set('domain_config_test__user_login', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_module_implements_alter().
|
||||
*/
|
||||
function domain_config_hook_test_module_implements_alter(&$implementations, $hook) {
|
||||
if ($hook == 'user_login') {
|
||||
// Turn off the domain_config_hook_test's hook_user_login (above).
|
||||
unset($implementations['domain_config_hook_test']);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
services:
|
||||
domain_config_service.page_cache_request_policy:
|
||||
class: Drupal\domain_config_hook_test\PageCache\RequestPolicy\PageCacheRequestPolicy
|
||||
arguments: ['@config.factory']
|
||||
tags:
|
||||
- { name: page_cache_request_policy }
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\domain_config_hook_test\PageCache\RequestPolicy;
|
||||
|
||||
use Drupal\Core\Config\ConfigFactory;
|
||||
use Drupal\Core\PageCache\RequestPolicyInterface;
|
||||
use Drupal\Core\Session\SessionConfigurationInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* A page cache request policy.
|
||||
*
|
||||
* This service is not meant to DO anything, it's just meant to represent
|
||||
* a service that might be present in the Drupal community. For example,
|
||||
* persistent_login module has this same structure.
|
||||
*/
|
||||
class PageCacheRequestPolicy implements RequestPolicyInterface {
|
||||
|
||||
/**
|
||||
* Drupal config factory.
|
||||
*
|
||||
* @var \Drupal\Core\Config\ConfigFactory
|
||||
*/
|
||||
protected $configFactory;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \Drupal\Core\Config\ConfigFactory $config_factory
|
||||
* Drupal config factory.
|
||||
*/
|
||||
public function __construct(ConfigFactory $config_factory) {
|
||||
$this->configFactory = $config_factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function check(Request $request) {
|
||||
// This line is important. You have to use this service for it to fail.
|
||||
$this->configFactory
|
||||
->get('system.site');
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -10,8 +10,8 @@ dependencies:
|
||||
- domain
|
||||
- domain_config
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
+3
-3
@@ -10,8 +10,8 @@ dependencies:
|
||||
- domain
|
||||
- domain_config
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\domain_config\Functional;
|
||||
|
||||
/**
|
||||
* Tests the domain config system.
|
||||
*
|
||||
* @group domain_config
|
||||
*/
|
||||
class DomainConfigHookProblemTest extends DomainConfigHookTest {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
// Adds the domain_config module.
|
||||
'domain_config',
|
||||
];
|
||||
|
||||
/**
|
||||
* Disabled config schema checking.
|
||||
*
|
||||
* Domain Config actually duplicates schemas provided by other modules,
|
||||
* so it cannot define its own.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $strictConfigSchema = FALSE;
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\domain_config\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the domain config system.
|
||||
*
|
||||
* @group domain_config
|
||||
*/
|
||||
class DomainConfigHookTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'domain',
|
||||
// See module info file for description of what this module does.
|
||||
'domain_config_hook_test',
|
||||
];
|
||||
|
||||
/**
|
||||
* Test to ensure a domain_config_hook_test_user_login() does not run.
|
||||
*
|
||||
* This test serves as a control to show the domain_config_hook_test module
|
||||
* functions correctly on it's own. Only when you add the domain_config
|
||||
* module, does it fail.
|
||||
*/
|
||||
public function testHookRuns() {
|
||||
$this->drupalGet('user/login');
|
||||
$user = $this->drupalCreateUser([]);
|
||||
$edit = ['name' => $user->getUserName(), 'pass' => $user->passRaw];
|
||||
$this->drupalPostForm(NULL, $edit, t('Log in'));
|
||||
|
||||
$test = \Drupal::state()->get('domain_config_test__user_login', NULL);
|
||||
// When this test passes, it means domain_config_hook_test_user_login was
|
||||
// not run.
|
||||
$this->assertNull($test, 'The hook_user_login state message is set.');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,8 @@ dependencies:
|
||||
- domain:domain
|
||||
- domain:domain_access
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ use Drupal\Core\Url;
|
||||
class DomainContentController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Builds the lost of domains and relevant entities.
|
||||
* Builds the list of domains and relevant entities.
|
||||
*
|
||||
* @param array $options
|
||||
* A list of variables required to build editor or content pages.
|
||||
|
||||
@@ -8,8 +8,8 @@ dependencies:
|
||||
- drupal:node
|
||||
- domain:domain
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
@@ -286,3 +286,17 @@ function domain_source_presave_generate(EntityInterface $entity) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_hook_info().
|
||||
*/
|
||||
function domain_source_hook_info() {
|
||||
$hooks['domain_source_alter'] = [
|
||||
'group' => 'domain_source',
|
||||
];
|
||||
$hooks['domain_source_path_alter'] = [
|
||||
'group' => 'domain_source',
|
||||
];
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
services:
|
||||
domain_source.commands:
|
||||
class: \Drupal\domain_source\Commands\DomainSourceCommands
|
||||
tags:
|
||||
- { name: drush.command }
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\domain_source\Commands;
|
||||
|
||||
use Consolidation\AnnotatedCommand\AnnotationData;
|
||||
use Consolidation\AnnotatedCommand\CommandData;
|
||||
use Drupal\domain\Commands\DomainCommands;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Drush commands for the domain source module.
|
||||
*
|
||||
* These commands mainly extend base Domain commands. See the documentation at
|
||||
* https://github.com/consolidation/annotated-command for details.
|
||||
*/
|
||||
class DomainSourceCommands extends DomainCommands {
|
||||
|
||||
/**
|
||||
* Registers additional information to domain:info.
|
||||
*
|
||||
* @hook init domain:info
|
||||
*/
|
||||
public function initDomainInfo(InputInterface $input, AnnotationData $annotationData) {
|
||||
// To add a field label, append to the 'field-labels' item.
|
||||
// @TODO: watch https://github.com/consolidation/annotated-command/pull/174
|
||||
$annotationData['field-labels'] .= "\n" . 'domain_source_entities: Domain source entities';
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides additional information to domain:info.
|
||||
*
|
||||
* @hook alter domain:info
|
||||
*/
|
||||
public function alterDomainInfo($result, CommandData $commandData) {
|
||||
// Display which entities are enabled for domain by checking for the fields.
|
||||
$result['domain_source_entities'] = $this->getFieldEntities(DOMAIN_SOURCE_FIELD);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hook option domain:delete
|
||||
*/
|
||||
public function deleteOptions(Command $command, AnnotationData $annotationData) {
|
||||
$command->addOption(
|
||||
'source-assign',
|
||||
'',
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'Reassign content for Domain Source',
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hook on-event domain-delete
|
||||
*/
|
||||
public function domainSourceDomainDelete($target_domain, $options) {
|
||||
// Run our own deletion routine here.
|
||||
if (is_null($options['content-assign'])) {
|
||||
$policy_content = 'prompt';
|
||||
}
|
||||
if (!empty($options['content-assign'])) {
|
||||
if (in_array($options['content-assign'], $this->reassignment_policies, TRUE)) {
|
||||
$policy_content = $options['content-assign'];
|
||||
}
|
||||
}
|
||||
|
||||
$delete_options = [
|
||||
'entity_filter' => 'node',
|
||||
'policy' => $policy_content,
|
||||
'field' => DOMAIN_SOURCE_FIELD,
|
||||
];
|
||||
|
||||
return $this->doReassign($target_domain, $delete_options);
|
||||
}
|
||||
|
||||
}
|
||||
+16
-4
@@ -76,7 +76,7 @@ class DomainSourcePathProcessor implements OutboundPathProcessorInterface {
|
||||
/**
|
||||
* The domain storage.
|
||||
*
|
||||
* @var \Drupal\domain\DomainStorageInterface
|
||||
* @var \Drupal\domain\DomainStorageInterface|null
|
||||
*/
|
||||
protected $domainStorage;
|
||||
|
||||
@@ -100,7 +100,6 @@ class DomainSourcePathProcessor implements OutboundPathProcessorInterface {
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->aliasManager = $alias_manager;
|
||||
$this->configFactory = $config_factory;
|
||||
$this->domainStorage = $entity_type_manager->getStorage('domain');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +158,7 @@ class DomainSourcePathProcessor implements OutboundPathProcessorInterface {
|
||||
$target_id = domain_source_get($entity);
|
||||
}
|
||||
if (!empty($target_id)) {
|
||||
$source = $this->domainStorage->load($target_id);
|
||||
$source = $this->domainStorage()->load($target_id);
|
||||
}
|
||||
$options['entity'] = $entity;
|
||||
$options['entity_type'] = $entity->getEntityTypeId();
|
||||
@@ -169,7 +168,7 @@ class DomainSourcePathProcessor implements OutboundPathProcessorInterface {
|
||||
else {
|
||||
if (isset($options['domain_target_id'])) {
|
||||
$target_id = $options['domain_target_id'];
|
||||
$source = $this->domainStorage->load($target_id);
|
||||
$source = $this->domainStorage()->load($target_id);
|
||||
}
|
||||
$this->moduleHandler->alter('domain_source_path', $source, $path, $options);
|
||||
}
|
||||
@@ -279,4 +278,17 @@ class DomainSourcePathProcessor implements OutboundPathProcessorInterface {
|
||||
return $this->activeDomain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the domain storage handler.
|
||||
*
|
||||
* @return \Drupal\domain\DomainStorageInterface
|
||||
* The domain storage handler.
|
||||
*/
|
||||
protected function domainStorage() {
|
||||
if (!$this->domainStorage) {
|
||||
$this->domainStorage = $this->entityTypeManager->getStorage('domain');
|
||||
}
|
||||
return $this->domainStorage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,8 +14,8 @@ dependencies:
|
||||
- serialization
|
||||
- user
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-14
|
||||
version: '8.x-1.0-alpha14+9-dev'
|
||||
# Information added by Drupal.org packaging script on 2019-02-21
|
||||
version: '8.x-1.0-alpha15'
|
||||
core: '8.x'
|
||||
project: 'domain'
|
||||
datestamp: 1542230887
|
||||
datestamp: 1550763190
|
||||
|
||||
+40
@@ -141,4 +141,44 @@ class DomainSourceElementTest extends DomainTestBase {
|
||||
$this->assert(strpos($url, 'node/' . $nid . '/edit') === FALSE, 'Form submitted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for https://www.drupal.org/project/domain/issues/3010256.
|
||||
*/
|
||||
public function testAnonForm() {
|
||||
// Editor with no domain permissions should not see the element.
|
||||
$editor = $this->drupalCreateUser([
|
||||
'create article content',
|
||||
]);
|
||||
$this->drupalLogin($editor);
|
||||
|
||||
$this->drupalGet('node/add/article');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
|
||||
$locator = DOMAIN_SOURCE_FIELD;
|
||||
$this->assertSession()->fieldNotExists($locator);
|
||||
|
||||
// Editor with domain permissions should see the element once they
|
||||
// are assigned to domains.
|
||||
$editor2 = $this->drupalCreateUser([
|
||||
'create article content',
|
||||
'publish to any assigned domain',
|
||||
]);
|
||||
$this->drupalLogin($editor2);
|
||||
|
||||
$this->drupalGet('node/add/article');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
|
||||
$locator = DOMAIN_SOURCE_FIELD;
|
||||
$this->assertSession()->fieldNotExists($locator);
|
||||
|
||||
// Domain assignment.
|
||||
$ids = ['example_com', 'one_example_com'];
|
||||
$this->addDomainsToEntity('user', $editor2->id(), $ids, DOMAIN_ACCESS_FIELD);
|
||||
|
||||
$this->drupalGet('node/add/article');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
|
||||
$this->assertSession()->fieldExists($locator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user