Skip to content

Allow defaults setting to be set to a closure#98

Merged
brandonkelly merged 1 commit intocraftcms:v2from
carlcs:v2
Aug 1, 2019
Merged

Allow defaults setting to be set to a closure#98
brandonkelly merged 1 commit intocraftcms:v2from
carlcs:v2

Conversation

@carlcs
Copy link
Copy Markdown
Contributor

@carlcs carlcs commented Feb 11, 2019

When defining defaults I need to make use of Craft’s request service, and without having it in a callable it’s throwing errors on console requests.

return [
    'defaults' => function() {
        $request = Craft::$app->getRequest();
        return [
            'paginate' => false,
            'includes' => (array)$request->getQueryParam('include'),
            'excludes' => (array)$request->getQueryParam('exclude'),
        ];
    },
    'endpoints' => [],
];

@brandonkelly brandonkelly merged commit 6896232 into craftcms:v2 Aug 1, 2019
@brandonkelly
Copy link
Copy Markdown
Member

Good idea, thanks!

brandonkelly added a commit that referenced this pull request Aug 1, 2019
@brandonkelly
Copy link
Copy Markdown
Member

Element API 2.6.0 is out now with this change.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants