LanguageCookieConditionBase.php in Language Cookie 8
File
src/LanguageCookieConditionBase.php
View source
<?php
namespace Drupal\language_cookie;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\Config\Config;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class LanguageCookieConditionBase extends ConditionPluginBase implements LanguageCookieConditionInterface, ContainerFactoryPluginInterface {
protected $weight = 0;
protected $currentLanguage;
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition);
}
public function block() {
return FALSE;
}
public function pass() {
return TRUE;
}
public function summary() {
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
$this->configuration[$this
->getPluginId()] = $form_state
->getValue($this
->getPluginId());
}
public function getName() {
$definition = $this
->getPluginDefinition();
return !empty($definition['name']) ? $definition['name'] : $this
->getPluginId();
}
public function getDescription() {
$definition = $this
->getPluginDefinition();
return !empty($definition['description']) ? $definition['description'] : NULL;
}
public function setWeight($weight) {
$this->weight = $weight;
return $this;
}
public function getWeight() {
return !empty($this->weight) ? $this->weight : 0;
}
public function evaluate() {
return $this
->execute();
}
public function postConfigSave(Config $config, array &$form, FormStateInterface $form_state) {
}
public function setCurrentLanguage(LanguageInterface $language) {
$this->currentLanguage = $language;
return $this;
}
public function getCurrentLanguage() {
return $this->currentLanguage;
}
}