added linkit contrib module
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
# Schema for the configuration files of the Linkit test module.
|
||||
|
||||
|
||||
# Plugin \Drupal\linkit_test\Plugin\Linkit\Attribute\ConfigurableDummyAttribute
|
||||
linkit.attribute.configurable_dummy_attribute:
|
||||
type: linkit.attribute
|
||||
mapping:
|
||||
dummy_setting:
|
||||
type: boolean
|
||||
|
||||
# Plugin \Drupal\linkit_test\Plugin\Linkit\Matcher\ConfigurableDummyMatcher
|
||||
linkit.matcher.configurable_dummy_matcher:
|
||||
type: linkit.matcher
|
||||
mapping:
|
||||
dummy_setting:
|
||||
type: boolean
|
||||
@@ -0,0 +1,16 @@
|
||||
name: 'Linkit test module'
|
||||
description: 'Support module for Linkit testing.'
|
||||
package: Testing
|
||||
type: module
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
dependencies:
|
||||
- linkit
|
||||
- field
|
||||
- text
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-03-21
|
||||
version: '8.x-4.3'
|
||||
core: '8.x'
|
||||
project: 'linkit'
|
||||
datestamp: 1490127367
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Support module for Linkit testing.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_linkit_attribute_alter().
|
||||
*/
|
||||
function linkit_test_linkit_attribute_alter(&$linkit_attribute_info) {
|
||||
if (isset($linkit_attribute_info['dummyattribute'])) {
|
||||
$linkit_attribute_info['dummyattribute']['description'] = t('Altered dummy description');
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\linkit_test\Plugin\Linkit\Attribute\ConfigurableDummyAttribute.
|
||||
*/
|
||||
|
||||
namespace Drupal\linkit_test\Plugin\Linkit\Attribute;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\linkit\ConfigurableAttributeBase;
|
||||
|
||||
/**
|
||||
* Accesskey attribute.
|
||||
*
|
||||
* @Attribute(
|
||||
* id = "configurable_dummy_attribute",
|
||||
* label = @Translation("Configurable Dummy Attribute"),
|
||||
* html_name = "configurabledummyattribute",
|
||||
* description = @Translation("Configurable Dummy Attribute")
|
||||
* )
|
||||
*/
|
||||
class ConfigurableDummyAttribute extends ConfigurableAttributeBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildFormElement($default_value) {
|
||||
return [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('DummyAttribute'),
|
||||
'#default_value' => $default_value,
|
||||
'#maxlength' => 255,
|
||||
'#size' => 40,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return parent::defaultConfiguration() + [
|
||||
'dummy_setting' => FALSE,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
|
||||
$form['dummy_setting'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Dummy setting'),
|
||||
'#default_value' => $this->configuration['dummy_setting'],
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->configuration['dummy_setting'] = $form_state->getValue('dummy_setting');
|
||||
}
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\linkit_test\Plugin\Linkit\Attribute\DummyAttribute.
|
||||
*/
|
||||
|
||||
namespace Drupal\linkit_test\Plugin\Linkit\Attribute;
|
||||
|
||||
use Drupal\linkit\AttributeBase;
|
||||
|
||||
/**
|
||||
* Accesskey attribute.
|
||||
*
|
||||
* @Attribute(
|
||||
* id = "dummy_attribute",
|
||||
* label = @Translation("Dummy Attribute"),
|
||||
* html_name = "dummyattribute",
|
||||
* description = @Translation("Dummy Attribute")
|
||||
* )
|
||||
*/
|
||||
class DummyAttribute extends AttributeBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildFormElement($default_value) {
|
||||
return [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('DummyAttribute'),
|
||||
'#default_value' => $default_value,
|
||||
'#maxlength' => 255,
|
||||
'#size' => 40,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\linkit_test\Plugin\Linkit\Matcher\ConfigurableDummyMatcher.
|
||||
*/
|
||||
|
||||
namespace Drupal\linkit_test\Plugin\Linkit\Matcher;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\linkit\ConfigurableMatcherBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
|
||||
/**
|
||||
* @Matcher(
|
||||
* id = "configurable_dummy_matcher",
|
||||
* label = @Translation("Configurable Dummy Matcher"),
|
||||
* )
|
||||
*/
|
||||
class ConfigurableDummyMatcher extends ConfigurableMatcherBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return parent::defaultConfiguration() + [
|
||||
'dummy_setting' => FALSE,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
|
||||
$form['dummy_setting'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Dummy setting'),
|
||||
'#default_value' => $this->configuration['dummy_setting'],
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->configuration['dummy_setting'] = $form_state->getValue('dummy_setting');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMatches($string) {
|
||||
$matches[] = [
|
||||
'title' => 'Configurable Dummy Matcher title',
|
||||
'description' => 'Configurable Dummy Matcher description',
|
||||
'path' => 'http://example.com',
|
||||
'group' => 'Configurable Dummy Matcher',
|
||||
];
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\linkit_test\Plugin\Linkit\Matcher\DummyMatcher.
|
||||
*/
|
||||
|
||||
namespace Drupal\linkit_test\Plugin\Linkit\Matcher;
|
||||
|
||||
use Drupal\linkit\MatcherBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
|
||||
/**
|
||||
* @Matcher(
|
||||
* id = "dummy_matcher",
|
||||
* label = @Translation("Dummy Matcher"),
|
||||
* )
|
||||
*/
|
||||
class DummyMatcher extends MatcherBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMatches($string) {
|
||||
$matches[] = [
|
||||
'title' => 'DummyMatcher title',
|
||||
'description' => 'DummyMatcher description',
|
||||
'path' => 'http://example.com',
|
||||
'group' => 'DummyMatcher',
|
||||
];
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user