<?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