class PrivateMessageController in Private Message 8
Same name and namespace in other branches
- 8.2 src/Controller/PrivateMessageController.php \Drupal\private_message\Controller\PrivateMessageController
Private message page controller. Returns render arrays for the page.
Hierarchy
- class \Drupal\Core\Controller\ControllerBase implements ContainerInjectionInterface uses LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\private_message\Controller\PrivateMessageController implements PrivateMessageControllerInterface
Expanded class hierarchy of PrivateMessageController
File
- src/
Controller/ PrivateMessageController.php, line 16
Namespace
Drupal\private_message\ControllerView source
class PrivateMessageController extends ControllerBase implements PrivateMessageControllerInterface {
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected $currentUser;
/**
* The entity manager service.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* The form builder interface.
*
* @var \Drupal\Core\Form\FormBuilderInterface
*/
protected $formBuilder;
/**
* The user data service.
*
* @var \Drupal\user\UserDataInterface
*/
protected $userData;
/**
* The private message service.
*
* @var \Drupal\private_message\Service\PrivateMessageServiceInterface
*/
protected $privateMessageService;
/**
* The user manager service.
*
* @var \Drupal\user\UserStorageInterface
*/
protected $userManager;
/**
* Constructs a PrivateMessageForm object.
*
* @param \Drupal\Core\Session\AccountProxyInterface $currentUser
* The current user.
* @param \Drupal\Core\Entity\EntityManagerInterface $entityManager
* The entity manager service.
* @param \Drupal\Core\Form\FormBuilderInterface $formBuilder
* The form builder service.
* @param \Drupal\user\UserDataInterface $userData
* The user data service.
* @param \Drupal\private_message\Service\PrivateMessageServiceInterface $privateMessageService
* The private message service.
*/
public function __construct(AccountProxyInterface $currentUser, EntityManagerInterface $entityManager, FormBuilderInterface $formBuilder, UserDataInterface $userData, PrivateMessageServiceInterface $privateMessageService) {
$this->currentUser = $currentUser;
$this->entityManager = $entityManager;
$this->formBuilder = $formBuilder;
$this->userData = $userData;
$this->privateMessageService = $privateMessageService;
$this->userManager = $entityManager
->getStorage('user');
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('current_user'), $container
->get('entity.manager'), $container
->get('form_builder'), $container
->get('user.data'), $container
->get('private_message.service'));
}
/**
* {@inheritdoc}
*/
public function privateMessagePage() {
$this->privateMessageService
->updateLastCheckTime();
$user = $this->userManager
->load($this->currentUser
->id());
$private_message_thread = $this->privateMessageService
->getFirstThreadForUser($user);
if ($private_message_thread) {
$view_builder = $this->entityManager
->getViewBuilder('private_message_thread');
// No wrapper is provided, as the full view mode of the entity already
// provides the #private-message-page wrapper.
$page = $view_builder
->view($private_message_thread);
}
else {
$page = [
'#prefix' => '<div id="private-message-page">',
'#suffix' => '</div>',
'no_threads' => [
'#prefix' => '<p>',
'#suffix' => '</p>',
'#markup' => $this
->t('You do not have any messages'),
],
];
}
return $page;
}
/**
* {@inheritdoc}
*/
public function pmSettingsPage() {
return [
'#markup' => $this
->t('Private Messages'),
];
}
/**
* {@inheritdoc}
*/
public function pmThreadSettingsPage() {
return [
'#markup' => $this
->t('Private Message Threads'),
];
}
/**
* {@inheritdoc}
*/
public function configPage() {
return [
'#prefix' => '<div id="private_message_configuration_page">',
'#suffix' => '</div>',
'form' => $this->formBuilder
->getForm('Drupal\\private_message\\Form\\ConfigForm'),
];
}
/**
* {@inheritdoc}
*/
public function adminUninstallPage() {
return [
'#prefix' => '<div id="private_message_admin_uninstall_page">',
'#suffix' => '</div>',
'form' => $this->formBuilder
->getForm('Drupal\\private_message\\Form\\AdminUninstallForm'),
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ControllerBase:: |
protected | property | The configuration factory. | |
ControllerBase:: |
protected | property | The entity form builder. | |
ControllerBase:: |
protected | property | The entity type manager. | |
ControllerBase:: |
protected | property | The key-value storage. | 1 |
ControllerBase:: |
protected | property | The language manager. | 1 |
ControllerBase:: |
protected | property | The module handler. | 2 |
ControllerBase:: |
protected | property | The state service. | |
ControllerBase:: |
protected | function | Returns the requested cache bin. | |
ControllerBase:: |
protected | function | Retrieves a configuration object. | |
ControllerBase:: |
private | function | Returns the service container. | |
ControllerBase:: |
protected | function | Returns the current user. | 1 |
ControllerBase:: |
protected | function | Retrieves the entity form builder. | |
ControllerBase:: |
protected | function | Retrieves the entity manager service. | |
ControllerBase:: |
protected | function | Retrieves the entity type manager. | |
ControllerBase:: |
protected | function | Returns the form builder service. | 2 |
ControllerBase:: |
protected | function | Returns a key/value storage collection. | 1 |
ControllerBase:: |
protected | function | Returns the language manager service. | 1 |
ControllerBase:: |
protected | function | Returns the module handler. | 2 |
ControllerBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
ControllerBase:: |
protected | function | Returns the state storage service. | |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PrivateMessageController:: |
protected | property |
The current user. Overrides ControllerBase:: |
|
PrivateMessageController:: |
protected | property |
The entity manager service. Overrides ControllerBase:: |
|
PrivateMessageController:: |
protected | property |
The form builder interface. Overrides ControllerBase:: |
|
PrivateMessageController:: |
protected | property | The private message service. | |
PrivateMessageController:: |
protected | property | The user data service. | |
PrivateMessageController:: |
protected | property | The user manager service. | |
PrivateMessageController:: |
public | function |
The page for preparing to uninstall the module. Overrides PrivateMessageControllerInterface:: |
|
PrivateMessageController:: |
public | function | ||
PrivateMessageController:: |
public static | function |
Instantiates a new instance of this class. Overrides ControllerBase:: |
|
PrivateMessageController:: |
public | function |
The private message module settings page. Overrides PrivateMessageControllerInterface:: |
|
PrivateMessageController:: |
public | function |
The settings page specific to private message threads. Overrides PrivateMessageControllerInterface:: |
|
PrivateMessageController:: |
public | function |
The Private message page. Overrides PrivateMessageControllerInterface:: |
|
PrivateMessageController:: |
public | function | Constructs a PrivateMessageForm object. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |