Commit 89ea2150 authored by Eric Bremner's avatar Eric Bremner
Browse files

Merge branch 'feature/ISTWCMS-4600-ibiki-content-links-dashboard' into '8.x-1.x'

Feature/istwcms 4600 ibiki content links dashboard

See merge request !4
parents 76ccf4cb 60522682
......@@ -3,9 +3,12 @@
namespace Drupal\uw_dashboard\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\Entity\NodeType;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\views\Views;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'ContentList' block.
......@@ -15,7 +18,65 @@ use Drupal\views\Views;
* admin_label = @Translation("List content"),
* )
*/
class ContentListBlock extends BlockBase {
class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterface {
/**
* Current user.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected $currentUser;
/**
* Entity type manager from the core.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public static function create(
ContainerInterface $container,
array $configuration,
$plugin_id,
$plugin_definition
) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('current_user'),
$container->get('entity_type.manager')
);
}
/**
* ContentManagementMenuBlock constructor.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Session\AccountProxyInterface $currentUser
* Current user.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* Entity type manager.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
AccountProxyInterface $currentUser,
EntityTypeManagerInterface $entityTypeManager
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->currentUser = $currentUser;
$this->entityTypeManager = $entityTypeManager;
}
/**
* {@inheritdoc}
......@@ -46,8 +107,7 @@ class ContentListBlock extends BlockBase {
if (isset($this->configuration['display_my_content']) && $this->configuration['display_my_content']) {
// Add the current user to the arguments list.
$arguments[] = \Drupal::currentUser()->id();
$arguments[] = \Drupal::currentUser()->id();
$arguments[] = $this->currentUser->id();
// Remove the author and last updated by exposed filter,
// since we are only displaying the users content.
......@@ -118,7 +178,7 @@ class ContentListBlock extends BlockBase {
public function blockForm($form, FormStateInterface $form_state) {
// Get the node types.
$node_types = NodeType::loadMultiple();
$node_types = $this->entityTypeManager->getStorage('node_type')->loadMultiple();
// Set the all options for options array.
$options = [
......
......@@ -57,7 +57,11 @@ class ContentManagementMenuBlock extends BlockBase implements ContainerFactoryPl
// been configured. If not (else block) use secondary menu by
// default.
if (isset($configured[$id])) {
$selected_secondary = array_keys(array_filter($configured[$id] + $secondary_menu));
foreach ($secondary_menu as $key => $value) {
if (!empty($configured[$id][$key])) {
$selected_secondary[] = $key;
}
}
}
else {
$selected_secondary = array_keys($secondary_menu);
......@@ -75,7 +79,7 @@ class ContentManagementMenuBlock extends BlockBase implements ContainerFactoryPl
'class' => ['content-management-block-table'],
],
'#headers' => [
$this->t($primary_menu_item->link->getTitle()),
$primary_menu_item->link->getTitle(),
$this->t('Operations'),
],
];
......@@ -98,10 +102,12 @@ class ContentManagementMenuBlock extends BlockBase implements ContainerFactoryPl
];
foreach ($item->subtree as $sub_item) {
$build[$id]['table'][$sec_id]['operations']['#links'][$sub_item->link->getPluginId()] = [
'title' => $this->t($sub_item->link->getTitle()),
'url' => $sub_item->link->getUrlObject(),
];
if ($sub_item->access->isAllowed()) {
$build[$id]['table'][$sec_id]['operations']['#links'][$sub_item->link->getPluginId()] = [
'title' => $sub_item->link->getTitle(),
'url' => $sub_item->link->getUrlObject(),
];
}
}
}
}
......
......@@ -3,8 +3,11 @@
namespace Drupal\uw_dashboard\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\views\Views;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'WebformsList' block.
......@@ -14,7 +17,53 @@ use Drupal\views\Views;
* admin_label = @Translation("List forms"),
* )
*/
class FormsListBlock extends BlockBase {
class FormsListBlock extends BlockBase implements ContainerFactoryPluginInterface {
/**
* Entity type manager from the core.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public static function create(
ContainerInterface $container,
array $configuration,
$plugin_id,
$plugin_definition
) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('entity_type.manager')
);
}
/**
* ContentManagementMenuBlock constructor.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* Entity type manager.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
EntityTypeManagerInterface $entityTypeManager
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entityTypeManager;
}
/**
* {@inheritdoc}
......@@ -72,7 +121,7 @@ class FormsListBlock extends BlockBase {
public function blockForm($form, FormStateInterface $form_state) {
// Get the category.
$categories = \Drupal::entityTypeManager()->getStorage('webform')->getCategories(FALSE);
$categories = $this->entityTypeManager->getStorage('webform')->getCategories(FALSE);
// Set the all options for options array.
$options = [
......
......@@ -3,12 +3,12 @@ description: 'Block placement for dashboard blocks and site management menu'
type: module
core_version_requirement: '^8.8 || ^9'
dependencies:
- better_exposed_filters
- config_views
- dashboards
- layout_builder_restrictions
- node
- system
- user
- views
- views_autocomplete_filters
- drupal:better_exposed_filters
- drupal:config_views
- drupal:dashboards
- drupal:layout_builder_restrictions
- drupal:node
- drupal:system
- drupal:user
- drupal:views
- drupal:views_autocomplete_filters
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment