ParamOverriderInterface.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Webapi\Rest\Request;
  7. /**
  8. * Override parameter values
  9. *
  10. * Parameters in the webapi.xml can be forced. This ensures that on specific routes, a specific value is always used.
  11. * For instance, if there is a ".../me/..." route, the route should use only user information specific to the
  12. * currently logged in user. More specifically, if there was a "/customers/me/addresses" route, the service method
  13. * invoked could have a signature of "getAddresses($customerId)", but in the webapi.xml, the $customerId parameter
  14. * would be forced to be the customer id of the current authenticated user.
  15. *
  16. * The forced override parameter configuration is in the webapi.xml.
  17. *
  18. * <data>
  19. * <parameter name="customer.id" force="true">%customer_id%</parameter>
  20. * </data>
  21. *
  22. * Classes which implement ParamOverriderInterface would return the real value for the parameter, so a
  23. * ParamOverriderCustomerId would return the current authenticated user's customer id. If you
  24. * create new ParamOverriderInterface implementations, you can register new implementations by
  25. * adding to the parameter list for ParamsOverrider's dependency injection configuration.
  26. *
  27. * @api
  28. * @since 100.0.2
  29. */
  30. interface ParamOverriderInterface
  31. {
  32. /**
  33. * Returns the overridden value to use.
  34. *
  35. * @return string|int|null
  36. * @throws \Magento\Framework\Exception\NoSuchEntityException
  37. */
  38. public function getOverriddenValue();
  39. }