Closed (duplicate)
Project:
Services
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
1 Mar 2013 at 11:20 UTC
Updated:
1 Mar 2013 at 16:34 UTC
It's possible to specify a fixed value for a resource argument, but it's a bit fiddly and it produces PHP warnings (#1931080: checkNumberOfArguments() expects 'source' to be set):
'args' => array(
array(
// This is a hardcoded parameter to our callback, which requires
// a bit of hoop-jumping to work with Services.
'name' => 'entity_type',
// We have to set this as optional so the default value gets used.
// @see RESTServer::getControllerArguments()
'optional' => TRUE,
// We don't set the source.
//'source' => NULL,
'type' => 'string',
'description' => 'The entity type this operation is on.',
// The value we actually want to always pass.
'default value' => $entity_type,
),
It would be a lot better DX if there were a source type 'fixed', which simply always takes the value from 'default value'.
Obviously this probably can't be added to 3.x, as all Service servers would need to work with it so it would be an API change.
Comments
Comment #1
marcingy commentedThis is basically a dup of #1621660: support hard-coded services arguments.
Comment #2
joachim commentedYup. Sorry for the dup.
Comment #2.0
joachim commentedupdated