Coder Social home page Coder Social logo

gathercontent-laravel-fractal's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gathercontent-laravel-fractal's Issues

Service doesn't provide the ability to set a serializer.

Cannot set a custom serializer at runtime.

Typically, this won't be needed - however I've been thinking about a different Serializer for Error Transformers:

{"error":{"message":"Access Denied"}}

This would require a custom serilizer appending data to an 'error' key, similar to the DataArraySerilizer bundled with Fractal itself.

Can possibly just add it onto the service class:

Fractal::setSerializer(new \Acme\ErrorArraySerializer);

Includes not working for me?

I'm not sure if I am doing something terrible wrong or not. But are includes working? I notice the config has a place to change the includes word but I can't seem to get it to include my requests without explicitly adding $defaultIncludes.

Call to undefined method [package]

After following install instructions for this package on Laravel 5 (added alias and Service provider registrations
php artisan config:publish gathercontent/laravel-fractal gives

[BadMethodCallException]
Call to undefined method [package]

Any attempt to run the package gives the following error:

BadMethodCallException in ServiceProvider.php line 226:
Call to undefined method [package]
in ServiceProvider.php line 226
at ServiceProvider->__call('package', array('gathercontent/laravel-fractal', 'fractal')) in LaravelFractalServiceProvider.php line 22
at LaravelFractalServiceProvider->package('gathercontent/laravel-fractal', 'fractal') in LaravelFractalServiceProvider.php line 22
at LaravelFractalServiceProvider->boot()
at call_user_func_array(array(object(LaravelFractalServiceProvider), 'boot'), array()) in Container.php line 526
at Container->call(array(object(LaravelFractalServiceProvider), 'boot')) in Application.php line 703
at Application->bootProvider(object(LaravelFractalServiceProvider)) in Application.php line 685
at Application->Illuminate\Foundation{closure}(object(LaravelFractalServiceProvider), '19')
at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(ControllerServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FormRequestServiceProvider), object(FoundationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ValidationServiceProvider), object(ViewServiceProvider), object(AppServiceProvider), object(BusServiceProvider), object(ConfigServiceProvider), object(EventServiceProvider), object(RouteServiceProvider), object(LaravelFractalServiceProvider), object(BusServiceProvider)), object(Closure)) in Application.php line 686
at Application->boot() in BootProviders.php line 15
at BootProviders->bootstrap(object(Application)) in Application.php line 183
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 199
at Kernel->bootstrap() in Kernel.php line 110
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53

Depend on PaginatorInterface instead of IlluminatePaginator

In LaravelFractalService the collection and paginateCollection methods are type-hinting IlluminatePaginator. I want to use my own adapter that implements League\Fractal\Pagination\PaginatorInterface but does not extend IlluminatePaginator. As along as my adapter implements the interface it will work. Also, it is usually recommended to type-hint interfaces when possible.

When I try to use my own adapter I get an error due to the type-hint expecting an object that is an IlluminatePaginator object.

Cannot access the Fractal resource, preventing meta being set

For convenience, Item and Collection are created within the LaravelFractalService class, which acts as a Facade, hiding complexity. This is nice within our controllers since it allows:

return Fractal::item($user, new UserTransformer);

Problem is, meta is added at the resource level, which we do not have any access to.
One possible solution could be to pass a closure as a third param:

return Fractal::item($user, new UserTransformer, function ($resource) {
    $resource->setMetaValue('foo', 'bar');
});

L5 Paginator

The pagination is never executerd due to comeration to "IlluminatePaginator" Laravel 5 users LengthAwarePaginator so if statement is never executed. Fix would be appreciated :)

DefaultTranslator and EloquentTranslator to resolve Transformer

Instead of having to pass a transformer, a strategy could be defined to automatically resolve the Transformer. This strategy could be set or injected into the manager. Any sort of resolver really.

Perhaps an EloquentTranslator could also translate the model class into a translator similar to how a Command finds it's own CommandHandler. For example:

\Acme\Users\User finds \Acme\Users\UserTransformer

This must be highly configurable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.