class EnrollRequestDialogController in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/src/Controller/EnrollRequestDialogController.php \Drupal\social_event\Controller\EnrollRequestDialogController
- 10.3.x modules/social_features/social_event/src/Controller/EnrollRequestDialogController.php \Drupal\social_event\Controller\EnrollRequestDialogController
- 10.1.x modules/social_features/social_event/src/Controller/EnrollRequestDialogController.php \Drupal\social_event\Controller\EnrollRequestDialogController
- 10.2.x modules/social_features/social_event/src/Controller/EnrollRequestDialogController.php \Drupal\social_event\Controller\EnrollRequestDialogController
Contains methods for the modal form when requesting to enroll in an event.
@package Drupal\social_event\Controller
Hierarchy
- class \Drupal\Core\Controller\ControllerBase implements ContainerInjectionInterface uses LoggerChannelTrait, MessengerTrait, RedirectDestinationTrait, StringTranslationTrait
- class \Drupal\social_event\Controller\EnrollRequestDialogController
Expanded class hierarchy of EnrollRequestDialogController
File
- modules/
social_features/ social_event/ src/ Controller/ EnrollRequestDialogController.php, line 19
Namespace
Drupal\social_event\ControllerView source
class EnrollRequestDialogController extends ControllerBase {
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilder
*/
protected $formBuilder;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected $currentUser;
/**
* The ModalFormExampleController constructor.
*
* @param \Drupal\Core\Form\FormBuilder $formBuilder
* The form builder.
* @param \Drupal\Core\Session\AccountProxyInterface $currentUser
* The current user.
*/
public function __construct(FormBuilder $formBuilder, AccountProxyInterface $currentUser) {
$this->formBuilder = $formBuilder;
$this->currentUser = $currentUser;
}
/**
* {@inheritdoc}
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The Drupal service container.
*
* @return static
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('form_builder'), $container
->get('current_user'));
}
/**
* Helper method so we can have consistent dialog options.
*
* @return string[]
* An array of jQuery UI elements to pass on to our dialog form.
*/
protected static function getDataDialogOptions() {
return [
'dialogClass' => 'form--default social_event-popup',
'closeOnEscape' => TRUE,
'width' => '582',
];
}
/**
* Enroll dialog callback.
*/
public function enrollDialog() {
$response = new AjaxResponse();
// Get the modal form using the form builder.
$form = $this->formBuilder
->getForm('Drupal\\social_event\\Form\\EnrollRequestModalForm');
if ($this
->currentUser()
->isAnonymous()) {
$form = $this->formBuilder
->getForm('Drupal\\social_event\\Form\\EnrollRequestAnonymousForm');
$response
->addCommand(new OpenModalDialogCommand($this
->t('Request to enroll'), $form, [
'width' => '337px',
'closeOnEscape' => TRUE,
'dialogClass' => 'social_event-popup social_event-popup--anonymous',
]));
}
else {
$response
->addCommand(new OpenModalDialogCommand($this
->t('Request to enroll'), $form, static::getDataDialogOptions()));
}
return $response;
}
/**
* The _title_callback for the event enroll dialog route.
*
* @param \Drupal\node\NodeInterface $node
* Node.
*
* @return string
* The page title.
*/
public function enrollTitle(NodeInterface $node) {
return $this
->t('Request enrollment in @label Event', [
'@label' => $node
->label(),
]);
}
/**
* Determines if user has access to enroll form.
*/
public function enrollAccess(NodeInterface $node) {
return AccessResult::allowed();
}
}
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 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. | |
ControllerBase:: |
protected | function | Returns the state storage service. | |
EnrollRequestDialogController:: |
protected | property |
The current user. Overrides ControllerBase:: |
|
EnrollRequestDialogController:: |
protected | property |
The form builder. Overrides ControllerBase:: |
|
EnrollRequestDialogController:: |
public static | function |
Overrides ControllerBase:: |
|
EnrollRequestDialogController:: |
public | function | Determines if user has access to enroll form. | |
EnrollRequestDialogController:: |
public | function | Enroll dialog callback. | |
EnrollRequestDialogController:: |
public | function | The _title_callback for the event enroll dialog route. | |
EnrollRequestDialogController:: |
protected static | function | Helper method so we can have consistent dialog options. | |
EnrollRequestDialogController:: |
public | function | The ModalFormExampleController constructor. | |
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. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
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. | 4 |
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. |