Last active
April 4, 2019 22:42
-
-
Save acrosman/e86c020327f6d7ad7be7aeb8739c9c5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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