1

I have a custom module that implements a few new REST endpoints, which is working correctly.

In my api2.xml I have the routes defined as this:

<routes>
   <route_catalog_rule>
      <route>/unir/catalogrule/:id_rule</route>
      <action_type>entity</action_type>
   </route_catalog_rule>

   <route_catalog_rules_by_any_field_id>
      <route>/unir/catalogrules/:id_name/:id_value</route>
      <action_type>collection</action_type>
   </route_catalog_rules_by_any_field_id>

   <route_catalog_rule_add>
      <route>/unir/catalogrules/add</route>
      <action_type>collection</action_type>
   </route_catalog_rule_add>
</routes>

And I have the appropriate _retrieve(), _retrieveCollection(), and _create() in the corresponding V1.php. All works as intended so far.

But... I need to add a new endpoint for this resource, hopefully handled by the same controller. It would also be a PUT/update (normally handled by _update()), but that I'd like to handle with a different method within my controller.

Basically, it comes down to either being able to specify a custom handler directly, something looking like:

<route_catalog_rule_disable>
  <route>/unir/catalogrules/disable/:id</route>
  <action_type>entity</action_type>
  <action_name>my_custom_handler</action_name>
</route_catalog_rule_disable>

Or at least to be able to pass an additional param through the route definition directly, something like:

<route_catalog_rule_disable>
  <route>/unir/catalogrules/disable/:id</route>
  <action_type>entity</action_type>
  <my_custom_param>disable</my_custom_param>

I guess that I could check do something like always going through _update checking pathinfo and decide according to that... but it doesn't seem too clean.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.