class PanelizerUser in Panelizer 8.3
Same name and namespace in other branches
- 8.5 src/Plugin/PanelizerEntity/PanelizerUser.php \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerUser
- 8.4 src/Plugin/PanelizerEntity/PanelizerUser.php \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerUser
Panelizer entity plugin for integrating with users.
Plugin annotation
@PanelizerEntity("user");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\panelizer\Plugin\PanelizerEntityBase implements ContainerFactoryPluginInterface, PanelizerEntityInterface uses StringTranslationTrait
- class \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerUser
- class \Drupal\panelizer\Plugin\PanelizerEntityBase implements ContainerFactoryPluginInterface, PanelizerEntityInterface uses StringTranslationTrait
Expanded class hierarchy of PanelizerUser
File
- src/
Plugin/ PanelizerEntity/ PanelizerUser.php, line 16
Namespace
Drupal\panelizer\Plugin\PanelizerEntityView source
class PanelizerUser extends PanelizerEntityBase {
/**
* {@inheritdoc}
*/
public function getDefaultDisplay(EntityViewDisplayInterface $display, $bundle, $view_mode) {
$panels_display = parent::getDefaultDisplay($display, $bundle, $view_mode)
->setPageTitle('[user:name]');
// Remove the 'name' block because it's covered already.
foreach ($panels_display
->getRegionAssignments() as $region => $blocks) {
/** @var \Drupal\Core\Block\BlockPluginInterface[] $blocks */
foreach ($blocks as $block_id => $block) {
if ($block
->getPluginId() == 'entity_field:user:name') {
$panels_display
->removeBlock($block_id);
}
}
}
if ($display
->getComponent('member_for')) {
// @todo: add block for 'Member for'.
}
return $panels_display;
}
/**
* {@inheritdoc}
*/
public function alterBuild(array &$build, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) {
/** @var $entity \Drupal\user\Entity\User */
parent::alterBuild($build, $entity, $panels_display, $view_mode);
if ($entity
->id()) {
$build['#contextual_links']['user'] = [
'route_parameters' => [
'user' => $entity
->id(),
],
'metadata' => [
'changed' => $entity
->getChangedTime(),
],
];
}
// This function adds a default alt tag to the user_picture field to
// maintain accessibility.
if (user_picture_enabled() && !empty($build['content']['middle'])) {
foreach (Element::children($build['content']['middle']) as $key) {
if (isset($build['content']['middle'][$key]['content']['field'])) {
foreach (Element::children($build['content']['middle'][$key]['content']['field']) as $field_key) {
if ($build['content']['middle'][$key]['content']['field']['#field_name'] == 'user_picture') {
if (empty($build['content']['middle'][$key]['content']['field'][$field_key]['#item_attributes'])) {
$build['content']['middle'][$key]['content']['field'][$field_key]['#item_attributes'] = [
'alt' => \Drupal::translation()
->translate('Profile picture for user @username', [
'@username' => $entity
->getUsername(),
]),
];
}
}
}
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PanelizerEntityBase:: |
protected | property | ||
PanelizerEntityBase:: |
protected | property | ||
PanelizerEntityBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
PanelizerEntityBase:: |
public | function |
Preprocess the variables for the view mode template. Overrides PanelizerEntityInterface:: |
1 |
PanelizerEntityBase:: |
public | function |
Overrides PluginBase:: |
|
PanelizerUser:: |
public | function |
Alter the built entity view in an entity specific way before rendering. Overrides PanelizerEntityBase:: |
|
PanelizerUser:: |
public | function |
Creates a default Panels display from the core Entity display. Overrides PanelizerEntityBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
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. |