コード例 #1
0
 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $app['Dingo\\Api\\Transformer\\Factory']->setAdapter(function ($app) {
         $fractal = new League\Fractal\Manager();
         $fractal->setSerializer(new League\Fractal\Serializer\JsonApiSerializer());
         return new Dingo\Api\Transformer\Adapter\Fractal($fractal);
     });
     app('Dingo\\Api\\Transformer\\Factory')->register('AutoResume\\Entities\\User', 'AutoResume\\Transformers\\UserTransformer');
 }
コード例 #2
0
 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     // TODO Test this one out
     $this->app->bind('\\League\\Fractal\\Manager', function ($app) {
         $fractal = new \League\Fractal\Manager();
         $serializer = new \League\Fractal\Serializer\JsonApiSerializer(env('API_DOMAIN', null));
         $fractal->setSerializer($serializer);
         return $fractal;
     });
 }
コード例 #3
0
 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->bind('\\League\\Fractal\\Manager', function ($app) {
         $fractal = new \League\Fractal\Manager();
         $baseUrl = url('/');
         $serializer = new \League\Fractal\Serializer\JsonApiSerializer($baseUrl);
         $fractal->setSerializer($serializer);
         return $fractal;
     });
     $this->app->bind('Dingo\\Api\\Transformer\\Adapter\\Fractal', function ($app) {
         $fractal = $app->make('\\League\\Fractal\\Manager');
         return new \Dingo\Api\Transformer\Adapter\Fractal($fractal);
     });
 }
コード例 #4
0
ファイル: helpers.php プロジェクト: Bobo1239/osu-web
function fractal_api_serialize_collection($model, $transformer, $includes = null)
{
    $manager = new League\Fractal\Manager();
    if ($includes !== null) {
        $manager->parseIncludes($includes);
    }
    $manager->setSerializer(new App\Serializers\ApiSerializer());
    // we're using collection instead of item here, so we can peak at the items beforehand
    $collection = new League\Fractal\Resource\Collection($model, $transformer);
    return $manager->createData($collection)->toArray();
}
コード例 #5
0
});
/**
 * @description Phalcon - AuthManager
 */
$di->setShared(AppServices::AUTH_MANAGER, function () use($di, $config) {
    $authManager = new \PhalconRest\Auth\Manager($config->authentication->expirationTime);
    $authManager->registerAccountType(App\Auth\UsernameAccountType::NAME, new \App\Auth\UsernameAccountType());
    return $authManager;
});
/**
 * @description Phalcon - \Phalcon\Mvc\Model\Manager
 */
$di->setShared(AppServices::MODELS_MANAGER, function () use($di) {
    $modelsManager = new \Phalcon\Mvc\Model\Manager();
    return $modelsManager->setEventsManager($di->get(AppServices::EVENTS_MANAGER));
});
/**
 * @description PhalconRest - \League\Fractal\Manager
 */
$di->setShared(AppServices::FRACTAL_MANAGER, function () {
    $fractal = new \League\Fractal\Manager();
    $fractal->setSerializer(new \App\Fractal\CustomSerializer());
    return $fractal;
});
/**
 * @description App - \Library\App\Services\UserService
 */
$di->setShared(AppServices::USER_SERVICE, function () {
    return new \App\Services\UserService();
});
return $di;
コード例 #6
0
ファイル: config.php プロジェクト: PoxyDoxy/lanager
<?php

return ['vendor' => 'zeropingheroes.lanager', 'version' => 'v1', 'prefix' => 'api', 'domain' => null, 'conditional_request' => false, 'strict' => false, 'debug' => false, 'auth' => ['lanager' => function ($app) {
    return new Zeropingheroes\Lanager\Domain\Users\UserApiKeyAuthorizationProvider($app['auth']);
}], 'throttling' => [], 'transformer' => function ($app) {
    $fractal = new League\Fractal\Manager();
    $fractal->setSerializer(new League\Fractal\Serializer\ArraySerializer());
    return new Dingo\Api\Transformer\FractalTransformer($fractal);
}, 'default_format' => 'json', 'formats' => ['json' => 'Dingo\\Api\\Http\\ResponseFormat\\JsonResponseFormat']];
コード例 #7
0
ファイル: app.php プロジェクト: yeets/lumen-api
$app->register(\LucaDegasperi\OAuth2Server\Storage\FluentStorageServiceProvider::class);
$app->register(\LucaDegasperi\OAuth2Server\OAuth2ServerServiceProvider::class);
// Register tymon/jwt-auth package
$app->register(\Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class);
// Register dingo/api package
$app->register(Dingo\Api\Provider\LumenServiceProvider::class);
class_alias('Tymon\\JWTAuth\\Facades\\JWTAuth', 'JWTAuth');
/** This gives you finer control over the payloads you create if you require it.
 *  Source: https://github.com/tymondesigns/jwt-auth/wiki/Installation
 */
class_alias('Tymon\\JWTAuth\\Facades\\JWTFactory', 'JWTFactory');
// Optional
// Dingo Response Transformer
$app['Dingo\\Api\\Transformer\\Factory']->setAdapter(function ($app) {
    $fractal = new League\Fractal\Manager();
    $fractal->setSerializer(new League\Fractal\Serializer\JsonApiSerializer());
    return new Dingo\Api\Transformer\Adapter\Fractal($fractal);
});
// Dingo basic auth
$app['Dingo\\Api\\Auth\\Auth']->extend('basic', function ($app) {
    return new Dingo\Api\Auth\Provider\Basic($app['auth'], 'phone');
});
// Dingo OAuth2.0 auth
$app['Dingo\\Api\\Auth\\Auth']->extend('oauth', function ($app) {
    $provider = new Dingo\Api\Auth\Provider\OAuth2($app['oauth2-server.authorizer']->getChecker());
    $provider->setUserResolver(function ($id) {
        return App\User::findOrFail($id);
    });
    $provider->setClientResolver(function ($id) {
        // TODO
        // return OAuthClient::findOrFail($id);
コード例 #8
0
ファイル: helpers.php プロジェクト: ppy/osu-web
function json_collection($model, $transformer, $includes = null)
{
    $manager = new League\Fractal\Manager();
    if ($includes !== null) {
        $manager->parseIncludes($includes);
    }
    $manager->setSerializer(new App\Serializers\ApiSerializer());
    // da bess
    if (is_string($transformer)) {
        $transformer = 'App\\Transformers\\' . str_replace('/', '\\', $transformer) . 'Transformer';
        $transformer = new $transformer();
    }
    // we're using collection instead of item here, so we can peek at the items beforehand
    $collection = new League\Fractal\Resource\Collection($model, $transformer);
    return $manager->createData($collection)->toArray();
}