Skip to content

Instantly share code, notes, and snippets.

@cyberlex404
Last active October 9, 2018 10:38
Show Gist options
  • Select an option

  • Save cyberlex404/bbd57e253f5c3475e14a8a5fca69df8d to your computer and use it in GitHub Desktop.

Select an option

Save cyberlex404/bbd57e253f5c3475e14a8a5fca69df8d to your computer and use it in GitHub Desktop.
<div class="logo_wrap">
<a class="navbar-brand" href="/">
<img src="/sites/www.hycm.com/files/2018-01/logo_white (1).svg" alt="HYCM">
</a>
</div>
<div class="btns d-flex">
<a href="#shortForm" class="btn open_account_btn btn_white smooth_scroll" style="display: inline-block;">{{ 'Register'|t }}</a>
<a href="/login" class="btn open_account_btn btn_transparent" style="display: inline-block;">{{ 'Login'|t }}</a>
</div>
<?php
namespace Drupal\hycm_blocks\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
/**
* Provides a 'LandingPageHeader' block.
*
* @Block(
* id = "landing_page_header",
* admin_label = @Translation("Landing Page Header"),
* )
*/
class LandingPageHeader extends BlockBase implements ContainerFactoryPluginInterface {
/**
* Drupal\Core\Render\RendererInterface definition.
*
* @var \Drupal\Core\Render\RendererInterface
*/
protected $renderer;
/**
* Drupal\Core\Config\ConfigFactoryInterface definition.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Constructs a new LandingPageHeader object.
*
* @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,
RendererInterface $renderer,
ConfigFactoryInterface $config_factory
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->renderer = $renderer;
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('renderer'),
$container->get('config.factory')
);
}
/**
* {@inheritdoc}
*/
public function build() {
$build = [];
$renderArray = [
'#theme' => 'landing_header',
'#header' => NULL
];
$build['landing_page_header']['#markup'] = \Drupal::service('renderer')->render($renderArray);
return $build;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment