Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load mappings from classes #4

Closed
nilportugues opened this issue Oct 9, 2015 · 1 comment
Closed

Load mappings from classes #4

nilportugues opened this issue Oct 9, 2015 · 1 comment
Assignees

Comments

@nilportugues
Copy link
Owner

Create a new loading method, as asked by many in the Laravel community, using classes.

The haljson.php file in config/ dir loads the classes in an array, this gets parsed and then cached producing the same results as now.

Good thing about this approach is that mappings can sit with code instead of sitting in the configuration side.


use Acme\Domain\Dummy\Post;

class PostModelMapping extends ApiMapping
{
     public function getClass() {
         return Post::class;
    }

     public function getAlias() {
         return "";
    }

     public function getIdProperties() {
         return ['postId'];
    }

     public function getAliasedProperties() {
         return [
           'author' => 'author',
            'title' => 'headline',
            'content' => 'body',
         ];
    }

     public function getHideProperties() {
         return [];
    }

   //etc....
}
@nilportugues
Copy link
Owner Author

Can be counted as done.

Will be supported as as soon as nilportugues/php-api-transformer@b209041 is integrated into this package...which requires Laravel Eloquel Models easy hack to get it working perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant