ConditionAddForm.php in Block Visibility Groups 8
File
src/Form/ConditionAddForm.php
View source
<?php
namespace Drupal\block_visibility_groups\Form;
use Drupal\Core\Condition\ConditionManager;
use Drupal\Core\Plugin\Context\ContextRepositoryInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ConditionAddForm extends ConditionFormBase {
protected $conditionManager;
public function __construct(ConditionManager $condition_manager, ContextRepositoryInterface $context_repository) {
$this->conditionManager = $condition_manager;
$this->contextRepository = $context_repository;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('plugin.manager.condition'), $container
->get('context.repository'));
}
public function getFormId() {
return 'block_visibility_group_condition_add_form';
}
protected function prepareCondition($condition_id) {
return $this->conditionManager
->createInstance($condition_id);
}
protected function submitButtonText() {
return $this
->t('Add condition');
}
protected function submitMessageText() {
return $this
->t('The %label condition has been added.', [
'%label' => $this->condition
->getPluginDefinition()['label'],
]);
}
}