Made two new Operations that were requested by jpetso.
The first is the string replacement, the second operations saves a string into a file.

Comments

jpetso’s picture

Status: Needs review » Needs work

Yeah, kinda. Thanks for the patch! Some points still need improvement:

  1. Operations don't return their "success/fail" status as output, instead, they call $output->setErrorMessage() in case of an error and return from the execute() method.
  2. By convention, input and output keys start with a lower-case character where possible, and use camel casing.
  3. The string replacement operation is nice, but not flexible enough - for example, it cannot replace multiple strings in one go. What I had in mind is an operation that takes 2+n inputs, the first being the string that is being translated ("Subject"), the second being a list of replacement tokens that occur in the subject ("Replacement tokens", type "transformations:list
    "), and one input for each of the inserted strings that replace the token (inputs named after the tokens provided by the replacement tokens input, e.g. "!blah", "%blah" or "[blah]").
  4. \ No newline at end of file
  5. Why is the file save operation called "TfFileSavefromStrings" if it doesn't take strings (plural) but only a single string? Also, the "from" should also be capitalized, so that it rather looks like "TfFileSaveFromString".
  6. I think the file-save operation should go into operations.file.inc, and only the string replacement operation should go into operations.string.inc.
  7. I prefer strtr() instead of str_replace() because Drupal used that function more often, plus it's got a cleaner API for the multiple-replacements-at-once use case. Also, don't state in the operation description which function is used, it doesn't make a difference here and should be irrelevant to the user.
  8. You wouldn't guess, but I again found style issues regarding trailing spaces, an "if(){" occurrence, and incorrect indentation. Please fix those.
sepgil’s picture

StatusFileSize
new3.15 KB

Had a little error in my last patch
-edit-
damn, wrong thread, is it posible to delete the post??

sepgil’s picture

StatusFileSize
new6.8 KB

I implemented all requests.

jpetso’s picture

Status: Needs work » Needs review

I just committed the File Save operation, string replace is next up.

jpetso’s picture

Status: Needs review » Fixed

The string replacement operation is now in CVS, too. I made a few adaptations still (slot renames, better descriptions, using the placeholder strings instead of "unknown" key names) but the operation itself worked fine even before. I can close this issue now as "fixed", thanks for the contributions!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.