"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/modules/statistics/src/Plugin/migrate/source/NodeCounter.php" (26 Nov 2020, 931 Bytes) of package /linux/www/drupal-8.9.10.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 "NodeCounter.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\statistics\Plugin\migrate\source;
    4 
    5 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
    6 
    7 /**
    8  * Node counter source from database.
    9  *
   10  * @MigrateSource(
   11  *   id = "node_counter",
   12  *   source_module = "statistics"
   13  * )
   14  */
   15 class NodeCounter extends DrupalSqlBase {
   16 
   17   /**
   18    * {@inheritdoc}
   19    */
   20   public function query() {
   21     return $this->select('node_counter', 'nc')->fields('nc');
   22   }
   23 
   24   /**
   25    * {@inheritdoc}
   26    */
   27   public function fields() {
   28     return [
   29       'nid' => $this->t('The node ID.'),
   30       'totalcount' => $this->t('The total number of times the node has been viewed.'),
   31       'daycount' => $this->t('The total number of times the node has been viewed today.'),
   32       'timestamp' => $this->t('The most recent time the node has been viewed.'),
   33     ];
   34   }
   35 
   36   /**
   37    * {@inheritdoc}
   38    */
   39   public function getIds() {
   40     $ids['nid']['type'] = 'integer';
   41     return $ids;
   42   }
   43 
   44 }