Skip to content
Snippets Groups Projects

Feature/istwcms 4600 ibiki content links dashboard

Merged Igor Biki requested to merge feature/ISTWCMS-4600-ibiki-content-links-dashboard into 8.x-1.x
4 files
+ 137
22
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -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 = [
Loading