Commit 4e96093f authored by Oleksandr Kuzava's avatar Oleksandr Kuzava
Browse files

Issue #3293030: TypeError: Argument 1 passed to...

Issue #3293030: TypeError: Argument 1 passed to Drupal\single_content_sync\ContentSyncHelper::access() must implement interface Drupal\Core\Entity\EntityInterface, string given
parent cf61a0ae
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\single_content_sync\Form;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
@@ -241,11 +242,20 @@ class ContentExportForm extends FormBase {
  }

  /**
   * {@inheritdoc}
   * Check if user has access to the export form.
   */
  public function access() {
    $parameters = $this->getRouteMatch()->getParameters();
    $entity = $parameters->getIterator()->current();

    if (is_string($entity)) {
      $entity = $parameters->get($entity);
    }

    if (!$entity instanceof EntityInterface) {
      return AccessResult::forbidden();
    }

    $hasAccess = $this->contentSyncHelper->access($entity);

    return $hasAccess ? AccessResult::allowed() : AccessResult::forbidden();