Panelizer has a hard dependency on field_ui when the dependency is only required for the admin portion of panelizer. panelizer.info.yml has an existing comment that says "@todo Break the dependency on Field UI.". We can break this hard dependency by only getting the field_ui access_check service if/when the field ui admin actually uses it. Thus, we can easily make this a soft dependency. Patch to follow.

Comments

douggreen created an issue. See original summary.

douggreen’s picture

StatusFileSize
new2.9 KB

Patch attached

tim.plunkett’s picture

  1. +++ b/src/Access/ViewModeAccessCheck.php
    @@ -16,7 +18,7 @@ class ViewModeAccessCheck implements AccessInterface {
       protected $accessCheck;
    
    @@ -25,8 +27,13 @@ class ViewModeAccessCheck implements AccessInterface {
    +    else {
    +      $this->accessCheck = FALSE;
    +    }
    

    Could initialize this to FALSE up top, skip the else.

  2. +++ b/src/Access/ViewModeAccessCheck.php
    @@ -55,6 +62,9 @@ class ViewModeAccessCheck implements AccessInterface {
    +    if (!$this->accessCheck) {
    +      throw new \Exception('Field_ui must be enabled if using panelizer admin UI.');
    +    }
    

    I would consider logging a message and returning an AccessForbidden here? Not sure what happens when you throw exceptions in an access check.

douggreen’s picture

I think that code should never get called if field_ui is not enabled, and it's really an exception if it does.

douggreen’s picture

Should we use trigger_error() ?

douggreen’s picture

StatusFileSize
new2.71 KB

updated patch per comments in #3

suzymasri’s picture

StatusFileSize
new2.4 KB

Patch #6 rerolled against 4.1 release.

hershey.k’s picture

StatusFileSize
new2.8 KB
new335 bytes

Patch #8 rerolled again, against latest stable 4.4.0 release (should also work on 4.1^). With addition of missing code change outlined below. Fixes failing build from #7.

Patch Comment #7 is missing the removal of drupal:field_ui from the panelizer.info.yml file. Preventing config imports from disabling drupal:field_ui on an environment that requires panelizer module to stay enabled.