FlagListsActionsActionListBuilder.php in Flag Lists 4.0.x
File
modules/flag_lists_actions/src/FlagListsActionsActionListBuilder.php
View source
<?php
namespace Drupal\flag_lists_actions;
use Drupal\Core\Action\ActionManager;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\action\ActionListBuilder;
use Drupal\flag_lists\FlagListsServiceInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FlagListsActionsActionListBuilder extends ActionListBuilder {
protected $flagListsService;
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, ActionManager $action_manager, FlagListsServiceInterface $flag_lists_service, ConfigFactoryInterface $config_factory) {
parent::__construct($entity_type, $storage, $action_manager);
$this->flagListsService = $flag_lists_service;
$this->configFactory = $config_factory;
}
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($entity_type, $container
->get('entity_type.manager')
->getStorage($entity_type
->id()), $container
->get('plugin.manager.action'), $container
->get('flaglists'), $container
->get('config.factory'));
}
public function buildRow(EntityInterface $entity) {
if ($this->hasConfigurableActions) {
if (!empty($entity
->get('configuration')['flag_id'])) {
if ($this->flagListsService
->getFlaggingCollectionIdByRelated($entity
->get('configuration')['flag_id'])) {
$config = $this->configFactory
->get('flag_lists.settings');
if ($config
->get('hide_actions') == 1) {
return NULL;
}
}
}
$row['type'] = $entity
->getType();
$row['label'] = $entity
->label();
$row += parent::buildRow($entity);
return $row;
}
}
}