Drupal Version

9.3.9

Domain module version

1.0-beta6

Expected Behavior

[What did you try to do? What URL did you use to do it?]
Install domain_content module without explicitly enabling domain_access

Actual Behavior

[What actually happened?]
Error: Class 'Drupal\\domain_access\\DomainAccessManagerInterface' not found in /home/www/domainsite/web/modules/contrib/domain/domain_content/domain_content.install on line 24 #0 [internal function]: domain_content_requirements()

Steps to reproduce

[A bullet list of steps to reproduce the error. Note if the error always happens or sometimes happens.]
Install domain on its own first, and then try to install domain_content on its own.

Issue fork domain-3272765

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

brad.bulger created an issue. See original summary.

brad.bulger’s picture

The problem is that other module classes are not available in the 'install' phase of hook_requirements():

During installation (when $phase == 'install'), if you need to load a class from your module, you'll need to include the class file directly.

Directly including the necessary class file, and then using the full path to the constant instead of the 'use' statement, works:

      require_once __DIR__ . './../domain_access/src/DomainAccessManagerInterface.php';
...
      $id = $entity_type . '.' . $bundle . '.' . \Drupal\domain_access\DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD;

cbeier made their first commit to this issue’s fork.

aimai’s picture

Attached a copy of the current status of the MR as a patch.

tostinni’s picture

Status: Active » Needs review

Working fine for us, switching to needs review to trigger the tests.

agentrickard’s picture

Status: Needs review » Needs work

Well that's just odd.

  • agentrickard committed c7e7379 on 8.x-1.x authored by aimai
    Issue #3272765 by cbeier, aimai: domain_content install fatal error...
agentrickard’s picture

Status: Needs work » Fixed

I guess tests always passed because the installer explicitly installs domain_access first....

Merged.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

levmyshkin’s picture

I have a Fatal error in Windows OS, because of slashes instead of backslashes. DIRECTORY_SEPARATOR helps to solve it. Attached a patch.

Error: Failed opening required 'C:\Repos\X2\home\doc9.site.com\web\modules\contrib\domain\domain_content./../domain_access/src/DomainAccessManagerInterface.php' (include_path='C:\Repos\X2\home\doc9.site.com\vendor/pear/archive_tar;C:\Repos\X2\home\doc9.site.com\vendor/pear/console_getopt;C:\Repos\X2\home\doc9.site.com\vendor/pear/pear-core-minimal/src;C:\Repos\X2\home\doc9.site.com\vendor/pear/pear_exception;.;C:/Repos/X2/data/PHP-8.3-FCGI/default/composer') in domain_content_requirements() (line 13 of modules\contrib\domain\domain_content\domain_content.install).