-
Notifications
You must be signed in to change notification settings - Fork 1
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 #4 from dennisinteractive/CMS-1243-mirror-contrib
CMS-1243 Version beta4 copy
- Loading branch information
Showing
40 changed files
with
2,031 additions
and
1,599 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Domain Path 8.x-1.0-beta4 , 2020-05-22 | ||
-------------------------------------- | ||
#3136977: When deleting an entity, translated domain paths are not deleted | ||
#3112534: Wrong validation on edit (Domain path matches an existing domain path alias...) | ||
#3137375: Remove deprecated code on DomainPathForm | ||
#3131284: Support pathauto for domain | ||
#3138970: Delete domain paths on domain delete | ||
#3040648: Unsaved Node Preview Causes fatal error. | ||
|
||
Domain Path 8.x-1.0-beta3 , 2020-05-12 | ||
-------------------------------------- | ||
#2976931: 'View' permission check name doesn't match permission definition | ||
#3009372: Domain path fieldset not in advanced node sidebar after upgrade to Drupal 8.6.x | ||
#3121647: Domain specific path validation does not work when pathauto autogenerate enabled | ||
#3121607: Add domain label title configuration options like domain navigation block does | ||
#3122607: processOutbound is generating wrong path when entity is not available on current domain | ||
#3128283: Respect url language options | ||
#3127593: Domain path field not hidden for disallowed domains |
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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
Domain Path | ||
====== | ||
Domain path | ||
=========== | ||
|
||
This module has been ported to D8 by Dennis. | ||
The Domain Path module allows the creation of separate path aliases per domain | ||
for entities created using the Domain Access module. For example, it looks like: | ||
https://d.pr/free/i/O4Vr9z on node edit form. The path aliases per domain are | ||
implemented as separate "domain_path" content entities. It is possible to create, | ||
edit or delete path alias per domain manually here - "admin/config/domain_path" | ||
(https://d.pr/free/i/8KbeOU). | ||
|
||
The issue to port is https://www.drupal.org/node/2821633 on https://www.drupal.org/project/domain_path | ||
|
||
Current status | ||
------ | ||
The a number of outstanding issues concerned with making it work with Pathauto module. The Pathauto module follows a different flow when generating aliases and makes it difficult to extend. Known issues include: | ||
* We have removed the logic that allows alias storage service to respect the wishes of the passing service in regards to whether to update or insert a new record. This would be required to maintain all functionality in Pathauto module. | ||
* Aliases don't respect access checks on nodes, meaning users with bypass node access permissions who can see a node can't always see the path alias. | ||
* If an alias has been entered but the node has not been enabled on any domains, the alias will not be saved, and the path field will be cleared on next load. | ||
The module is ready for testing, but requires Domain Access to work correctly. | ||
For background, see issue here - https://www.drupal.org/node/2878050. |
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
entity_types: | ||
node: '1' |
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 @@ | ||
domain_path.settings: | ||
type: config_object | ||
mapping: | ||
entity_types: | ||
label: Enabled entity types for domain paths | ||
type: sequence | ||
sequence: | ||
type: string |
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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
name: Domain Path | ||
name: 'Domain Path' | ||
description: 'Allows separate path aliases per domain.' | ||
type: module | ||
package: Domain | ||
description: 'Allow the same path to be used across different domains.' | ||
core: 8.x | ||
|
||
core_version_requirement: ^8.8 || ^9 | ||
dependencies: | ||
- path | ||
- domain | ||
- domain_access | ||
- domain_config |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
entity.domain_path_add: | ||
route_name: entity.domain_path_add | ||
title: 'Add Domain path' | ||
appears_on: | ||
- entity.domain_path.collection |
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,18 @@ | ||
entity.domain_path.admin: | ||
title: Domain Path | ||
route_name: entity.domain_path.collection | ||
parent: system.admin_config | ||
description: 'Domain Path configuration' | ||
weight: 0 | ||
entity.domain_path.collection: | ||
title: 'Domain Paths' | ||
route_name: entity.domain_path.collection | ||
parent: entity.domain_path.admin | ||
description: 'Lists Domain Paths' | ||
weight: -10 | ||
domain_path.admin.settings: | ||
title: Domain Path Settings | ||
route_name: entity.domain_path_settings | ||
parent: entity.domain_path.admin | ||
description: 'Configure Domain Paths' | ||
weight: 0 |
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 @@ | ||
domain_path.admin: | ||
title: Domain Path List | ||
route_name: entity.domain_path.collection | ||
base_route: entity.domain_path.collection | ||
domain_path.settings_tab: | ||
title: Domain Path Settings | ||
route_name: entity.domain_path_settings | ||
base_route: entity.domain_path.collection |
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 |
---|---|---|
@@ -1,27 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Path alias handling for multiple domains. | ||
*/ | ||
|
||
use Drupal\Core\Entity\EntityInterface; | ||
|
||
/** | ||
* Implements hook_field_widget_info_alter(). | ||
* Implements hook_form_alter(). | ||
*/ | ||
function domain_path_field_widget_info_alter(&$widgets) { | ||
$moduleHandler = \Drupal::service('module_handler'); | ||
if ($moduleHandler->moduleExists('pathauto')){ | ||
$widgets['path']['class'] = '\Drupal\domain_path\PathautoWidget'; | ||
} | ||
else { | ||
$widgets['path']['class'] = '\Drupal\domain_path\PathWidget'; | ||
function domain_path_form_alter(&$form, &$form_state, $form_id) { | ||
// We really only want to alter entity forms with the path widget on it since | ||
// we're editing path aliases. | ||
if (isset($form['path']['widget']) && ($object = $form_state->getFormObject()) | ||
&& !empty($object) && is_callable([$object, 'getEntity']) | ||
&& ($entity = $object->getEntity())) { | ||
$domain_path_helper = \Drupal::service('domain_path.helper'); | ||
if ($domain_path_helper->domainPathsIsEnabled($entity)) { | ||
$domain_path_helper->alterEntityForm($form, $form_state, $entity); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Implements hook_module_implements_alter(). | ||
* Implements hook_entity_delete(). | ||
*/ | ||
function domain_path_module_implements_alter(&$implementations, $hook) { | ||
if ($hook == 'field_widget_info_alter') { | ||
// Run hook_field_widget_info_alter last so that it overrides pathauto. | ||
$group = $implementations['domain_path']; | ||
unset($implementations['domain_path']); | ||
$implementations['domain_path'] = $group; | ||
} | ||
function domain_path_entity_delete(EntityInterface $entity) { | ||
\Drupal::service('domain_path.helper')->deleteEntityDomainPaths($entity, TRUE); | ||
} | ||
|
||
/** | ||
* Implements hook_entity_translation_delete(). | ||
*/ | ||
function domain_path_entity_translation_delete(EntityInterface $translation) { | ||
\Drupal::service('domain_path.helper')->deleteEntityDomainPaths($translation); | ||
} |
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,13 @@ | ||
view domain path list: | ||
title: 'View all domain paths in the administration list' | ||
add domain paths: | ||
title: 'Add Domain paths' | ||
edit domain paths: | ||
title: 'Edit Domain paths' | ||
edit domain path entity: | ||
title: 'Edit Domain path entity' | ||
delete domain paths: | ||
title: 'Delete Domain paths' | ||
administer domain paths: | ||
title: 'Administer Domain paths' | ||
restrict access: TRUE |
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,56 @@ | ||
entity.domain_path.canonical: | ||
path: '/admin/config/domain_path/{domain_path}/edit' | ||
defaults: | ||
_entity_form: domain_path.edit | ||
_title: 'Edit Domain path' | ||
requirements: | ||
_entity_access: 'domain_path.edit' | ||
options: | ||
_admin_route: TRUE | ||
|
||
entity.domain_path.collection: | ||
path: '/admin/config/domain_path' | ||
defaults: | ||
_entity_list: 'domain_path' | ||
_title: 'Domain path List' | ||
_title_context: 'With modules' | ||
requirements: | ||
_custom_access: '\Drupal\domain_path\Access\DomainPathListCheck::viewDomainPathList' | ||
|
||
entity.domain_path_add: | ||
path: '/admin/config/domain_path/add' | ||
defaults: | ||
_entity_form: domain_path.add | ||
_title: 'Add Domain path' | ||
requirements: | ||
_entity_create_access: 'domain_path' | ||
options: | ||
_admin_route: TRUE | ||
|
||
entity.domain_path.edit_form: | ||
path: '/admin/config/domain_path/{domain_path}/edit' | ||
defaults: | ||
_entity_form: domain_path.edit | ||
_title: 'Edit Domain path' | ||
requirements: | ||
_entity_access: 'domain_path.edit' | ||
options: | ||
_admin_route: TRUE | ||
|
||
entity.domain_path.delete_form: | ||
path: '/admin/config/domain_path/{domain_path}/delete' | ||
defaults: | ||
_entity_form: domain_path.delete | ||
_title: 'Delete Domain path' | ||
requirements: | ||
_entity_access: 'domain_path.delete' | ||
options: | ||
_admin_route: TRUE | ||
|
||
entity.domain_path_settings: | ||
path: '/admin/config/domain_path/domain_path_settings' | ||
defaults: | ||
_form: '\Drupal\domain_path\Form\DomainPathSettingsForm' | ||
_title: 'Domain path Settings' | ||
requirements: | ||
_permission: 'administer domain paths' |
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
services: | ||
domain_path.alias_storage: | ||
class: Drupal\domain_path\DomainAliasStorage | ||
public: false | ||
decorates: path.alias_storage | ||
decoration_priority: 1 | ||
decoration_inner_name: path.alias_storage.parent | ||
arguments: ['@database', '@module_handler', '@path.alias_storage.parent'] | ||
domain_path.path_processor: | ||
class: Drupal\domain_path\PathProcessor\DomainPathProcessor | ||
arguments: ['@language_manager', '@entity_type.manager', '@path_alias.manager', '@domain.negotiator'] | ||
tags: | ||
- { name: backend_overridable } | ||
calls: | ||
- [setDomainAccessManager, ['@domain_access.manager']] | ||
- [setDomainNegotiator, ['@domain.negotiator']] | ||
- [setEntityTypeManager, ['@entity_type.manager']] | ||
# Priority is very important here. The inbound processor needs to happen | ||
# BEFORE the path module alias processor, and the outbound needs to happen | ||
# AFTER the alias processor. | ||
- { name: path_processor_inbound, priority: 110 } | ||
- { name: path_processor_outbound, priority: 200 } | ||
domain_path.helper: | ||
class: Drupal\domain_path\DomainPathHelper | ||
arguments: ['@current_user', '@entity_type.manager', '@path_alias.manager', '@config.factory', '@module_handler'] |
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: Domain Path Pathauto (EXPERIMENTAL) | ||
type: module | ||
description: Domain Path Pathauto support | ||
core_version_requirement: ^8.8 || ^9 | ||
package: Domain | ||
dependencies: | ||
- domain_path | ||
- pathauto(>= 1.8) |
7 changes: 7 additions & 0 deletions
7
modules/domain_path_pathauto/domain_path_pathauto.services.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,7 @@ | ||
services: | ||
domain_path_pathauto.generator: | ||
class: Drupal\domain_path_pathauto\DomainPathautoGenerator | ||
arguments: ['@config.factory', '@module_handler', '@token', '@pathauto.alias_cleaner', '@pathauto.alias_storage_helper', '@domain_path_pathauto.alias_uniquifier', '@pathauto.verbose_messenger', '@string_translation', '@token.entity_mapper', '@entity_type.manager', '@plugin.manager.alias_type'] | ||
domain_path_pathauto.alias_uniquifier: | ||
class: Drupal\domain_path_pathauto\DomainAliasUniquifier | ||
arguments: ['@config.factory', '@pathauto.alias_storage_helper','@module_handler', '@router.route_provider', '@path_alias.manager'] |
84 changes: 84 additions & 0 deletions
84
modules/domain_path_pathauto/src/DomainAliasUniquifier.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,84 @@ | ||
<?php | ||
|
||
namespace Drupal\domain_path_pathauto; | ||
|
||
use Drupal\Core\Language\LanguageInterface; | ||
use Drupal\pathauto\AliasUniquifier; | ||
use Drupal\Component\Utility\Unicode; | ||
|
||
/** | ||
* Provides a utility for creating a unique domain path alias. | ||
*/ | ||
class DomainAliasUniquifier extends AliasUniquifier { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function uniquify(&$alias, $source, $langcode, $domain_id = '') { | ||
$config = $this->configFactory->get('pathauto.settings'); | ||
|
||
if (!$this->isReserved($alias, $source, $langcode, $domain_id)) { | ||
return; | ||
} | ||
|
||
// If the alias already exists, generate a new, hopefully unique, variant. | ||
$maxlength = min($config->get('max_length'), $this->aliasStorageHelper->getAliasSchemaMaxlength()); | ||
$separator = $config->get('separator'); | ||
$original_alias = $alias; | ||
|
||
$i = 0; | ||
do { | ||
// Append an incrementing numeric suffix until we find a unique alias. | ||
$unique_suffix = $separator . $i; | ||
$alias = Unicode::truncate($original_alias, $maxlength - mb_strlen($unique_suffix), TRUE) . $unique_suffix; | ||
$i++; | ||
} while ($this->isReserved($alias, $source, $langcode)); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isReserved($alias, $source, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $domain_id = '') { | ||
|
||
// Check if this domain alias already exists. | ||
$query = \Drupal::database()->select('domain_path', 'domain_path') | ||
->fields('domain_path', ['language', 'source', 'alias']) | ||
->condition('domain_id', $domain_id) | ||
->condition('alias', $alias); | ||
$result = $query->execute()->fetchAssoc(); | ||
|
||
if(isset($result['source'])) { | ||
$existing_source = $result["source"]; | ||
if ($existing_source != $alias) { | ||
// If it is an alias for the provided source, it is allowed to keep using | ||
// it. If not, then it is reserved. | ||
return $existing_source != $source; | ||
} | ||
} | ||
|
||
// Then check if there is a route with the same path. | ||
if ($this->isRoute($alias)) { | ||
return TRUE; | ||
} | ||
// Finally check if any other modules have reserved the alias. | ||
$args = [ | ||
$alias, | ||
$source, | ||
$langcode, | ||
]; | ||
$implementations = $this->moduleHandler->getImplementations('pathauto_is_alias_reserved'); | ||
foreach ($implementations as $module) { | ||
|
||
$result = $this->moduleHandler->invoke($module, 'pathauto_is_alias_reserved', $args); | ||
|
||
if (!empty($result)) { | ||
// As soon as the first module says that an alias is in fact reserved, | ||
// then there is no point in checking the rest of the modules. | ||
return TRUE; | ||
} | ||
} | ||
|
||
return FALSE; | ||
} | ||
|
||
} |
Oops, something went wrong.