"Fossies" - the Fresh Open Source Software Archive

Member "drupal-9.1.0-rc1/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php" (18 Nov 2020, 1917 Bytes) of package /linux/www/drupal-9.1.0-rc1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "UnapprovedComments.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\comment\Plugin\Menu\LocalTask;
    4 
    5 use Drupal\comment\CommentStorageInterface;
    6 use Drupal\Core\Menu\LocalTaskDefault;
    7 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
    8 use Drupal\Core\StringTranslation\StringTranslationTrait;
    9 use Symfony\Component\DependencyInjection\ContainerInterface;
   10 use Symfony\Component\HttpFoundation\Request;
   11 
   12 /**
   13  * Provides a local task that shows the amount of unapproved comments.
   14  */
   15 class UnapprovedComments extends LocalTaskDefault implements ContainerFactoryPluginInterface {
   16   use StringTranslationTrait;
   17 
   18   /**
   19    * The comment storage service.
   20    *
   21    * @var \Drupal\comment\CommentStorageInterface
   22    */
   23   protected $commentStorage;
   24 
   25   /**
   26    * Construct the UnapprovedComments object.
   27    *
   28    * @param array $configuration
   29    *   A configuration array containing information about the plugin instance.
   30    * @param string $plugin_id
   31    *   The plugin_id for the plugin instance.
   32    * @param array $plugin_definition
   33    *   The plugin implementation definition.
   34    * @param \Drupal\comment\CommentStorageInterface $comment_storage
   35    *   The comment storage service.
   36    */
   37   public function __construct(array $configuration, $plugin_id, array $plugin_definition, CommentStorageInterface $comment_storage) {
   38     parent::__construct($configuration, $plugin_id, $plugin_definition);
   39     $this->commentStorage = $comment_storage;
   40   }
   41 
   42   /**
   43    * {@inheritdoc}
   44    */
   45   public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
   46     return new static(
   47       $configuration,
   48       $plugin_id,
   49       $plugin_definition,
   50       $container->get('entity_type.manager')->getStorage('comment')
   51     );
   52   }
   53 
   54   /**
   55    * {@inheritdoc}
   56    */
   57   public function getTitle(Request $request = NULL) {
   58     return $this->t('Unapproved comments (@count)', ['@count' => $this->commentStorage->getUnapprovedCount()]);
   59   }
   60 
   61 }