You are here

jDrupalController.php in jDrupal 8.0.x

Same filename and directory in other branches
  1. 8 src/Controller/jDrupalController.php

File

src/Controller/jDrupalController.php
View source
<?php

/**
 * @file
 * Contains \Drupal\jDrupal\Controller\jDrupalController.
 */
namespace Drupal\jDrupal\Controller;

use Drupal\Core\Controller\ControllerBase;
use GuzzleHttp\Psr7\Response;

/**
 * Returns responses for jDrupal module routes.
 */
class jDrupalController extends ControllerBase {

  /**
   * Return the jDrupal configuration page.
   *
   * @return string
   *   A render array containing our jDrupal configuration page content.
   */
  public function jDrupalConfig() {
    $output = array();
    $output['jDrupal'] = array(
      '#markup' => 'hello world',
    );
    return $output;
  }

  /**
   *
   */
  public function connect() {
    $result = new \stdClass();
    $account = \Drupal::currentUser()
      ->getAccount();
    $result->account = new \stdClass();
    $result->account->uid = $account
      ->id();
    if ($result->account->uid) {
      $result->account->name = $account
        ->getUsername();
    }
    return new Response(200, [], $result);
  }

}

Classes

Namesort descending Description
jDrupalController Returns responses for jDrupal module routes.