Loading modules/memory_limit_policy_route/config/schema/memory_limit_policy_route.schema.yml +7 −0 Changes for modules/memory_limit_policy_route/config/schema/memory_limit_policy_route.schema.yml: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -4,3 +4,10 @@ memory_limit_policy.constraint.plugin.route: routes: type: sequence label: 'Routes' memory_limit_policy.constraint.plugin.admin_route: type: memory_limit_policy.constraint.plugin mapping: negate: type: boolean label: 'Negate the condition' modules/memory_limit_policy_route/src/Plugin/MemoryLimitConstraint/AdminRoute.php +15 −6 Changes for modules/memory_limit_policy_route/src/Plugin/MemoryLimitConstraint/AdminRoute.php: 15 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ use Drupal\memory_limit_policy\MemoryLimitConstraintBase; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Configure the memory limit based on route. * Configure the memory limit based on admin route. * * @MemoryLimitConstraint( * id = "admin_route", Loading Loading @@ -60,31 +60,40 @@ class AdminRoute extends MemoryLimitConstraintBase implements ContainerFactoryPl * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return [ '#type' => 'markup', '#markup' => '<p>' . $this->t('The admin routes constraint has no configuration options.') . '</p>', $form['negate'] = [ '#type' => 'checkbox', '#title' => $this->t('Negate the constraint'), '#description' => $this->t('Check to apply on all non-admin routes.'), '#default_value' => $this->getConfiguration()['negate'] ?? FALSE, ]; return $form; } /** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { // No configuration to be saved here. $this->configuration['negate'] = $form_state->getValue('negate'); } /** * {@inheritdoc} */ public function getSummary() { if ($this->configuration['negate']) { return $this->t('Applies to all non-admin routes.'); } else { return $this->t('Applies to all admin routes.'); } } /** * {@inheritdoc} */ public function evaluate() { return $this->adminContext->isAdminRoute(); return $this->configuration['negate'] xor $this->adminContext->isAdminRoute(); } } Loading
modules/memory_limit_policy_route/config/schema/memory_limit_policy_route.schema.yml +7 −0 Changes for modules/memory_limit_policy_route/config/schema/memory_limit_policy_route.schema.yml: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -4,3 +4,10 @@ memory_limit_policy.constraint.plugin.route: routes: type: sequence label: 'Routes' memory_limit_policy.constraint.plugin.admin_route: type: memory_limit_policy.constraint.plugin mapping: negate: type: boolean label: 'Negate the condition'
modules/memory_limit_policy_route/src/Plugin/MemoryLimitConstraint/AdminRoute.php +15 −6 Changes for modules/memory_limit_policy_route/src/Plugin/MemoryLimitConstraint/AdminRoute.php: 15 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ use Drupal\memory_limit_policy\MemoryLimitConstraintBase; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Configure the memory limit based on route. * Configure the memory limit based on admin route. * * @MemoryLimitConstraint( * id = "admin_route", Loading Loading @@ -60,31 +60,40 @@ class AdminRoute extends MemoryLimitConstraintBase implements ContainerFactoryPl * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return [ '#type' => 'markup', '#markup' => '<p>' . $this->t('The admin routes constraint has no configuration options.') . '</p>', $form['negate'] = [ '#type' => 'checkbox', '#title' => $this->t('Negate the constraint'), '#description' => $this->t('Check to apply on all non-admin routes.'), '#default_value' => $this->getConfiguration()['negate'] ?? FALSE, ]; return $form; } /** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { // No configuration to be saved here. $this->configuration['negate'] = $form_state->getValue('negate'); } /** * {@inheritdoc} */ public function getSummary() { if ($this->configuration['negate']) { return $this->t('Applies to all non-admin routes.'); } else { return $this->t('Applies to all admin routes.'); } } /** * {@inheritdoc} */ public function evaluate() { return $this->adminContext->isAdminRoute(); return $this->configuration['negate'] xor $this->adminContext->isAdminRoute(); } }