Open Data Catalog v
Drupal\common Namespace Reference

Namespaces

 Annotation
 
 Commands
 
 Controller
 
 Events
 
 Exception
 
 FileFetcher
 
 Plugin
 
 Storage
 
 StreamWrapper
 
 Util
 

Classes

class  DatasetInfo
 
class  DkanApiDocsGenerator
 
class  Resource
 
class  UrlHostTokenResolver
 

Functions

 addCacheHeaders (Response $response)
 
 setCacheMaxAge ()
 
 getResponse ($message, int $code=200)
 
 getResponseFromException (\Exception $e, int $code=400)
 
 getExceptionData (\Exception $e)
 
 setLoggerName (string $name)
 
 setLoggerFactory (LoggerChannelFactory $loggerService)
 

Variables

trait CacheableResponseTrait
 
trait JsonResponseTrait
 
trait LoggerTrait
 

Function Documentation

◆ addCacheHeaders()

Drupal\common\addCacheHeaders ( Response  $response)
protected

Adds cache headers to the response.

Todo:
implement more flexible caching and move the code out of the trait.
Parameters
\Symfony\Component\HttpFoundation\Response$responseSymfony response.
Returns
\Symfony\Component\HttpFoundation\Response Symfony response.
Exceptions

Definition at line 32 of file CacheableResponseTrait.php.

◆ getExceptionData()

Drupal\common\getExceptionData ( \Exception  $e)
protected

See if we can present more detail about the exception.

Currently, only RootedJsonData validation errors supported.

Parameters
\Exception$eException object.
Returns
array|false An array of data to explain the errors.

Definition at line 60 of file JsonResponseTrait.php.

◆ getResponse()

Drupal\common\getResponse (   $message,
int  $code = 200 
)
protected

Private.

Definition at line 21 of file JsonResponseTrait.php.

◆ getResponseFromException()

Drupal\common\getResponseFromException ( \Exception  $e,
int  $code = 400 
)
protected

Create JSON response from a caught exception.

Parameters
\Exception$eException object.
int$codeHTTP response code.
Returns
\Symfony\Component\HttpFoundation\JsonResponse A Symfony JSON response.

Definition at line 37 of file JsonResponseTrait.php.

◆ setCacheMaxAge()

Drupal\common\setCacheMaxAge ( )
protected

Sets cache max age.

Definition at line 49 of file CacheableResponseTrait.php.

◆ setLoggerFactory()

Drupal\common\setLoggerFactory ( LoggerChannelFactory  $loggerService)

Setter.

Parameters
\Drupal\Core\Logger\LoggerChannelFactory$loggerServiceInjected logger factory service.

Definition at line 53 of file LoggerTrait.php.

◆ setLoggerName()

Drupal\common\setLoggerName ( string  $name)

Setter.

Parameters
string$nameThe logger's name.

Definition at line 43 of file LoggerTrait.php.

Variable Documentation

◆ CacheableResponseTrait

trait Drupal::common\CacheableResponseTrait
Initial value:
{
protected $cacheMaxAge

Cachable Response Trait.

Definition at line 10 of file CacheableResponseTrait.php.

◆ JsonResponseTrait

trait Drupal::common\JsonResponseTrait
Initial value:

Json Response Trait.

Definition at line 15 of file JsonResponseTrait.php.

◆ LoggerTrait

trait Drupal::common\LoggerTrait
Initial value:
{
private $loggerName = 'dkan'

DKAN logger channel trait.

Definition at line 11 of file LoggerTrait.php.

Drupal\common\CacheableResponseTrait
trait CacheableResponseTrait
Definition: CacheableResponseTrait.php:10