drupal-autowire-example/src/Service/ExampleService.php
2019-01-09 10:59:26 +00:00

29 lines
543 B
PHP

<?php
namespace Drupal\autowire_example\Service;
use Drupal\Core\Session\AccountProxyInterface;
class ExampleService {
/**
* @var \Drupal\Core\Session\AccountProxyInterface
*/
private $currentUser;
/**
* Bar constructor.
*
* @param \Drupal\Core\Session\AccountProxyInterface $current_user
* The current user.
*/
public function __construct(AccountProxyInterface $current_user) {
$this->currentUser = $current_user;
}
public function __invoke() {
dump($this->currentUser->id());
die;
}
}