-
☆ A M B ☆
- 450 Posts
Working on a plugin that will assign a particular resource group to a resource when the document is saved. Not quite sure what the API call would look like.
Would I use $modx->resource->addOne()?
What is the name of the object I want to add? ResourceGroupResource? (Just Guessing). Is this documented somewhere?
-
☆ A M B ☆
- 450 Posts
How about changing the function such that to be considered as an ID the input must 1) pass is_integer() and 2) contain only digits?
I hesitate because I know that starts to make the function a bit convoluted.
But on the other hand from an end-user perspective it was rather baffling that my code, which I knew was passing (what to me was for all intents and purposes) an integer, was not working properly.
I think the options are
1) leave it as it is and focus on educating end users that if they pass an ID, they have to make sure that it is of type ’integer’ and not a numeric string.
2) change the function as I suggested above - the arg will be considered an ID if it passes is_integer and contains only digits.
3) change the function so that it is ’less flexible’ - make it require an array for input "$resource->joinGroup(array(’id’=>$id))" or "$resource->joinGroup(array(’name’=>$name))"
I think #2 and #3 are better alternatives than #1. I’ll file this as a bug, and leave it up to you core folks to decide what the "right" solution is.