Skip to content

Instantly share code, notes, and snippets.

View EclipseGc's full-sized avatar

Kris Vanderwater EclipseGc

View GitHub Profile
diff --git a/block_page.services.yml b/block_page.services.yml
index 8df43da..da46708 100644
--- a/block_page.services.yml
+++ b/block_page.services.yml
@@ -12,3 +12,6 @@ services:
plugin.manager.page_variant:
class: Drupal\block_page\Plugin\PageVariantManager
parent: default_plugin_manager
+ context.handler:
+ class: Drupal\block_page\ContextHandler
diff --git a/core/lib/Drupal/Core/Plugin/Context/Context.php b/core/lib/Drupal/Core/Plugin/Context/Context.php
index 2d79d6f..36314a3 100644
--- a/core/lib/Drupal/Core/Plugin/Context/Context.php
+++ b/core/lib/Drupal/Core/Plugin/Context/Context.php
@@ -51,6 +51,13 @@ public function setContextValue($value) {
parent::setContextValue($value);
}
+ /**
+ * @return DataDefinitionInterface
diff --git a/src/Plugin/PageVariant/HttpStatusCodePageVariant.php b/src/Plugin/PageVariant/HttpStatusCodePageVariant.php
index c7cd807..64946c1 100644
--- a/src/Plugin/PageVariant/HttpStatusCodePageVariant.php
+++ b/src/Plugin/PageVariant/HttpStatusCodePageVariant.php
@@ -47,6 +47,7 @@ class HttpStatusCodePageVariant extends PageVariantBase {
$options = array(
'404' => $options['404'],
'403' => $options['403'],
+ '301' => $options['301'],
'500' => $options['500'],
<?php
class HttpStatusCodePageVariant {
public function render() {
$status_code = $this->configuration['status_code'];
$dispatcher = \Drupal::service('event_dispatcher');
$event = new PageManagerViewEvent();
$event->setStatusCode($status_code);
$dispatcher->dispatch(PageManagerEvents::VIEW, $event);
return new Response($event->getContent(), $event->getStatusCode());
Existing Rules ContextInterface -> Merge into Drupal\Core\Plugin\Context
Determine if ContextDefinitionInterface is still necessary (instead of DataDefinitionInterface) (hopefully not neccessary).
Form Widget Definitions are not part of Context, Fago will make a separate method for when he needs this at the plugin level.
Allowed values are part of contexts, Kris would prefer a addConstraint() approach to this usage.
Context validation will not happen on setContextValue().
Static methods for plugin context definitions is an implementation detail, Kris doesn't like it but w/e.
Fago wants a ContextException to actually get used & documented.
Fago wants getContext() to return Context objects even if a value has not been set for that context. Kris agrees in principle.
Fago & Kris both support a ContextDefinition Annotation class.
<?php
/**
* Constructs a new context definition object.
*
* @param array $values
* An associative array with the following keys:
* - value: The required data type.
* - required: (optional) Whether the context definition is required.
* - multiple: (optional) Whether the context definition is multivalue.
<?php
$contexts = array(
'node' => new ContextDefinition('entity:node'),
);
drupal_set_message('<pre>' . print_r(\Drupal::service('plugin.manager.condition')->getDefinitionsForContexts($contexts), TRUE) . '</pre>');
<?php
$migrate = new Migrator();
$migrate->disabled = FALSE; /* Edit this to true to make a default migrate disabled initially */
$migrate->api_version = 1;
$migrate->machine_name = 'drupal_org_planet_feed';
$migrate->admin_title = 'Drupal.org Planet Feed';
$migrate->source = 'xml';
$migrate->destination = 'node';
$migrate->configuration = array(
<?php
/**
* Implements hook_requirements().
*/
function git_config_requirements($phase) {
$requirements = array();
$requirements['git-wrapper'] = array(
'title' => t('Git Wrapper'),
'value' => t('!wrapper is required to use the git_config module.', array('!wrapper' => l('Git Wrapper', 'https://github.com/cpliakas/git-wrapper'))),
<?php
/**
* @file
* Contains FilterOEmbed.php.
*/
namespace Drupal\oembed\Plugin\Filter;
use Drupal\filter\FilterProcessResult;