blankstare

Untitled

Sep 28th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Drupal\hello_foo\Controller;
  4.  
  5. use Drupal\Core\Controller\ControllerBase;
  6.  
  7. /**
  8.  * Displays the string "Hello Foo".
  9.  */
  10. class HelloFooController extends ControllerBase {
  11.  
  12.   /**
  13.    * Retrieve data from the users table.
  14.    *
  15.    * @return array
  16.    *   foo
  17.    */
  18.   private function getUsers($db) {
  19.     return $db->query("SELECT * FROM {users}")->fetchAll();
  20.   }
  21.   /**
  22.    * Display the markup.
  23.    *
  24.    * @return array
  25.    *   Distributive array containing the data to render.
  26.    */
  27.   public function content() {
  28.     //$rs = \Drupal::database()->query("SELECT * FROM {users}")->fetchAll();
  29.    
  30.     foreach ($this->getUsers(\Drupal::database()) as $record) {
  31.       $user = $record->uid . ':' . $record->uuid;
  32.       \Drupal::logger('hello_foo')->notice('processing ' . $user);
  33.     }
  34.     return [
  35.       '#type' => 'markup',
  36.       '#markup' => $this->t('Hello Foo!'),
  37.     ];
  38.   }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment