Skip to content

Instantly share code, notes, and snippets.

@acrosman
Last active April 4, 2019 22:42
Show Gist options
  • Save acrosman/e86c020327f6d7ad7be7aeb8739c9c5a to your computer and use it in GitHub Desktop.
Save acrosman/e86c020327f6d7ad7be7aeb8739c9c5a to your computer and use it in GitHub Desktop.
<?php
namespace Drupal\custom_blocks\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a 'CopyrightBlock' block.
*
* @Block(
* id = "copyright_block",
* admin_label = @Translation("Copyright block"),
* )
*/
class CopyrightBlock extends BlockBase {
public function build() {
$build = [];
$year = date('Y');
$block = [
'#theme' => 'custom_blocks_copyright',
'#attributes' => [
'class' => ['copyright'],
'id' => 'copyright-block',
],
'#year' => $year,
'#cache' => [
'max-age' => strtotime('01/01/'.(date('Y')+1)) - time(),
],
];
$build['copyright_block'] = $block;
return $build;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment