Beispiel #1
0
 /**
  * Auth constructor.
  *
  * @author Morten Rugaard <*****@*****.**>
  */
 public function __construct()
 {
     // Set user model
     $this->userModel = prepare_config_instance(config('nodes.api.auth.model', null));
     // Set token table
     $this->setTokenSettings();
 }
Beispiel #2
0
 /**
  * Prepare an array of instantiable configuration instances.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param array $instances
  *
  * @return array
  */
 function prepare_config_instances(array $instances)
 {
     // Loaded instances
     $loadedInstances = [];
     foreach ($instances as $key => $value) {
         $loadedInstances[$key] = prepare_config_instance($value);
     }
     return $loadedInstances;
 }
Beispiel #3
0
 /**
  * Register authentication user model.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @return void
  */
 protected function registerAuthModel()
 {
     $this->app->singleton('nodes.backend.auth.model', function ($app) {
         // Try and instantiate nodes.backend.backend user model
         $userModel = !empty(config('nodes.backend.auth.model')) ? prepare_config_instance(config('nodes.backend.auth.model')) : app(\Nodes\Backend\Models\User\User::class);
         // Validate user model instance
         if (empty($userModel) || !$userModel instanceof User) {
             throw new InvalidUserModelException('Missing or invalid backend user model');
         }
         return $userModel;
     });
 }
Beispiel #4
0
 /**
  * registerPushProvider.
  *
  * @author Casper Rasmussen <*****@*****.**>
  * @return void
  */
 protected function registerPushProvider()
 {
     $this->app->singleton('nodes.push', function () {
         // Retrieve push provider
         $provider = prepare_config_instance(config('nodes.push.provider'));
         // Validate push provider
         if (!$provider instanceof NodesPushProviderContract) {
             throw new InvalidPushProviderException($provider);
         }
         return $provider;
     });
     $this->app->bind(NodesPushProviderContract::class, function ($app) {
         return $app['nodes.push'];
     });
 }
Beispiel #5
0
<?php

/*
|--------------------------------------------------------------------------
| Response Transformer
|--------------------------------------------------------------------------
|
| Responses can be transformed so that they are easier to format. By
| default a Fractal transformer will be used to transform any
| responses prior to formatting. You can easily replace
| this with your own transformer.
|
*/
return ['adapter' => function () {
    // Instantiate Fractal Manager
    $manager = new Nodes\Api\Transformer\Manager();
    // Set serializer
    $serializer = prepare_config_instance(config('nodes.api.transformer.fractal.serializer.class'));
    $manager->setSerializer($serializer);
    // Retrieve adapter namespace
    $adapter = env('API_TRANSFORMER', Nodes\Api\Transformer\Adapter::class);
    // Instantiate transformer
    return new $adapter($manager, config('nodes.api.transformer.fractal.includeKey', 'include'), config('nodes.api.transformer.fractal.includeSeparator', ','), config('nodes.api.transformer.fractal.eagerLoad', true));
}, 'fractal' => ['serializer' => ['class' => env('API_TRANSFORMER_SERIALIZER', Nodes\Api\Transformer\Serializer::class), 'rootKey' => 'data'], 'includeKey' => 'include', 'includeSeparator' => ',', 'eagerLoad' => true]];
Beispiel #6
0
 /**
  * Register the transformation layer.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @return void
  */
 protected function registerTransformer()
 {
     $this->app->singleton('api.transformer', function ($app) {
         return new DingoTransformerFactory($app, prepare_config_instance(config('nodes.api.transformer.adapter')));
     });
 }