isNegated example


  protected function resolveConditions($conditions$condition_logic) {
    foreach ($conditions as $condition) {
      try {
        $pass = $condition->execute();
      }
      catch (ContextException $e) {
        // If a condition is missing context and is not negated, consider that a         // fail.         $pass = $condition->isNegated();
      }

      // If a condition fails and all conditions were needed, deny access.       if (!$pass && $condition_logic == 'and') {
        return FALSE;
      }
      // If a condition passes and only one condition was needed, grant access.       elseif ($pass && $condition_logic == 'or') {
        return TRUE;
      }
    }

    
public function createInstance($plugin_id, array $configuration = []) {
    $plugin = $this->getFactory()->createInstance($plugin_id$configuration);
    return $plugin->setExecutableManager($this);
  }

  /** * {@inheritdoc} */
  public function execute(ExecutableInterface $condition) {
    if ($condition instanceof ConditionInterface) {
      $result = $condition->evaluate();
      return $condition->isNegated() ? !$result : $result;
    }
    throw new ExecutableException("This manager object can only execute condition plugins");
  }

}
return $this->t('The user is not a member of @roles', ['@roles' => $roles]);
    }
    else {
      return $this->t('The user is a member of @roles', ['@roles' => $roles]);
    }
  }

  /** * {@inheritdoc} */
  public function evaluate() {
    if (empty($this->configuration['roles']) && !$this->isNegated()) {
      return TRUE;
    }
    $user = $this->getContextValue('user');
    return (bool) array_intersect($this->configuration['roles']$user->getRoles());
  }

  /** * {@inheritdoc} */
  public function getCacheContexts() {
    // Optimize cache context, if a user cache context is provided, only use

  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    $this->configuration['bundles'] = array_filter($form_state->getValue('bundles'));
    parent::submitConfigurationForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function evaluate() {
    // Returns true if no bundles are selected and negate option is disabled.     if (empty($this->configuration['bundles']) && !$this->isNegated()) {
      return TRUE;
    }
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = $this->getContextValue($this->getDerivativeId());
    return !empty($this->configuration['bundles'][$entity->bundle()]);
  }

  /** * {@inheritdoc} */
  public function summary() {
    
if (!$this->configuration['theme']) {
      return TRUE;
    }

    return $this->themeManager->getActiveTheme()->getName() == $this->configuration['theme'];
  }

  /** * {@inheritdoc} */
  public function summary() {
    if ($this->isNegated()) {
      return $this->t('The current theme is not @theme', ['@theme' => $this->configuration['theme']]);
    }

    return $this->t('The current theme is @theme', ['@theme' => $this->configuration['theme']]);
  }

  /** * {@inheritdoc} */
  public function getCacheContexts() {
    $contexts = parent::getCacheContexts();
    

    if (!empty($this->configuration['negate'])) {
      return $this->t('The language is not @languages.', ['@languages' => $languages]);
    }
    return $this->t('The language is @languages.', ['@languages' => $languages]);
  }

  /** * {@inheritdoc} */
  public function evaluate() {
    if (empty($this->configuration['langcodes']) && !$this->isNegated()) {
      return TRUE;
    }

    $language = $this->getContextValue('language');
    // Language visibility settings.     return !empty($this->configuration['langcodes'][$language->getId()]);
  }

  /** * {@inheritdoc} */
  
Home | Imprint | This part of the site doesn't use cookies.