Named parameters in Service config #38

Closed
opened 2019-02-13 23:16:06 +00:00 by jamie · 4 comments
jamie commented 2019-02-13 23:16:06 +00:00 (Migrated from git.hazaar.io)

At the moment, the service.json config file can have an args parameter for a service spec. This parameter is an array of parameters that will be passed to the action function when it is executed. I would like to use my little reflection trick to allow this to be an object so that the parameters can be named, instead of just numerically sequenced.

So that this:

{
  "test": {
    "enabled": true,
    "action": "doTheThing",
    "args": [ "Hello, World", 1 ]
  }
}

Can become this:

{
  "test": {
    "enabled": true,
    "action": "doTheThing",
    "args": { "message": "Hello, World", "type": 1 }
  }
}

The function could then be implemented as normal as:

public function doTheThing($message, $type){

}
At the moment, the `service.json` config file can have an `args` parameter for a service spec. This parameter is an array of parameters that will be passed to the action function when it is executed. I would like to use my little reflection trick to allow this to be an object so that the parameters can be named, instead of just numerically sequenced. So that this: ```json { "test": { "enabled": true, "action": "doTheThing", "args": [ "Hello, World", 1 ] } } ``` Can become this: ```json { "test": { "enabled": true, "action": "doTheThing", "args": { "message": "Hello, World", "type": 1 } } } ``` The function could then be implemented as normal as: ```php public function doTheThing($message, $type){ } ```
jamie commented 2019-02-13 23:17:09 +00:00 (Migrated from git.hazaar.io)

changed the description

changed the description
jamie commented 2019-02-13 23:17:51 +00:00 (Migrated from git.hazaar.io)

changed the description

changed the description
jamie commented 2019-02-18 06:03:38 +00:00 (Migrated from git.hazaar.io)

This is actually already implemented. I love it when I have a great idea twice!

This is actually already implemented. I love it when I have a great idea twice!
jamie commented 2019-02-18 06:03:39 +00:00 (Migrated from git.hazaar.io)

closed

closed
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hazaar/hazaar-warlock#38
No description provided.