Problem/Motivation
On a project, we are defaulting domain path pathauto to on, and completely disabling global pathauto. Unfortunately, since the state is either set to TRUE or empty (NULL), there is no way to persist a disabled state.
Steps to reproduce
- Add a form alter to default domain pathauto to enabled using this logic
$enabled = $this->domainPathautoGenerator->domainPathPathautoGenerationIsEnabled($this->node, $domain_id);
if ($enabled === FALSE) {
$this->form['path']['widget'][0]['domain_path'][$domain_id]['pathauto']['#default_value'] = TRUE;
}
- Now uncheck the pathauto checkbox for a domain and add a custom alias
- Since the state record is now deleted, the above form alter will re-check the pathauto box and wipe out the custom alias
Proposed resolution
Store the 0 state (like pathauto does). It actually looks like this was the original intent given the logic in DomainPathautGenerator::domainPathPathautoGenerationIsEnabled()
$collection = $this->getDomainPathPathautoStateCollection($entity, $domain_id);
$value = \Drupal::keyValue($collection)->get($entity->id());
if($value === NULL) {
return FALSE;
}
return $value;
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
jhedstromComment #3
shenzhuxi commentedIf the state is empty, will it cause any problem?
BTW, the latest 8.x-1.x-dev added an new option "Hide the default URL alias UI" which will avoid to store anything to the global pathauto while keep use the global pathauto pattern for domain_path alias.
Comment #4
mably commentedUnless new, valuable information is provided, this issue will be closed in a few weeks.
Comment #5
mably commentedProblem is fixed in latest 2.0.0-alpha5 release.