Commit 51ae2439 authored by Jur de Vries's avatar Jur de Vries

Initial commit.

parents
name: Facet api
type: module
description: Facetapi test
core: 8.x
package: Other
<?php
/**
* @file
* Contains facetapi.module
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function facetapi_help($route_name, RouteMatchInterface $route_match)
{
switch ($route_name) {
// Main module help for the facetapi module.
case 'help.page.facetapi':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Facetapi test') . '</p>';
return $output;
break;
}
}
/**
* Implements hook_theme().
*/
function facetapi_theme()
{
$theme = [];
return $theme;
}
services:
facetapi.adapter:
class: Drupal\facetapi\Adapter
arguments: []
<?php
/**
* @file
* Contains Drupal\facetapi\Adapter.
*/
namespace Drupal\facetapi;
class Adapter
{
public function __construct()
{
}
}
<?php
/**
* @file
* Contains Drupal\facetapi\Plugin\Block\FacetBlock.
*/
namespace Drupal\facetapi\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\facetapi\Adapter;
/**
* Provides a 'FacetBlock' block.
*
* @Block(
* id = "facet_block",
* admin_label = @Translation("Facet block")
* )
*/
class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
/**
* Drupal\facetapi\Adapter definition.
*
* @var Drupal\facetapi\Adapter
*/
protected $facetapi_adapter;
/**
* Construct.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param string $plugin_definition
* The plugin implementation definition.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
Adapter $facetapi_adapter
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->facetapi_adapter = $facetapi_adapter;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('facetapi.adapter')
);
}
/**
* {@inheritdoc}
*/
public function build() {
return [
'#markup' => 'Facet block',
];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment