CurrentUser.php 749 Bytes
Newer Older
Open Source Developer's avatar
Open Source Developer committed
1
2
3
4
5
6
<?php
/**
 * @file
 * Contains \Drupal\query_example\Controller\QueryExampleController.
 */

Open Source Developer's avatar
Open Source Developer committed
7
8
9
10




Open Source Developer's avatar
Open Source Developer committed
11
12
13
14
15
16
17
18
19
namespace Drupal\epal\Controller;

use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;


Open Source Developer's avatar
Open Source Developer committed
20
21


Open Source Developer's avatar
Open Source Developer committed
22
23
24
class CurrentUser extends ControllerBase {

 
Open Source Developer's avatar
Open Source Developer committed
25
26
27
28
29
30
31
32
33
34
35
  public function content($token_name) {
   
   $query = \Drupal::database()->select('epal_users', 'nfd');
   $query->fields('nfd', ['name']);
   $query->condition('nfd.authtoken', $token_name);
   $field = $query->execute()->fetchAssoc();
 



    $response = new JsonResponse($field);
Open Source Developer's avatar
Open Source Developer committed
36
37
38
39
40
    return $response;

  }

}