SortOrderBuilder.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Api;
  7. /**
  8. * Builder for sort order data object.
  9. * @method SortOrder create()
  10. *
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class SortOrderBuilder extends AbstractSimpleObjectBuilder
  15. {
  16. /**
  17. * Set sorting field.
  18. *
  19. * @param string $field
  20. * @return $this
  21. */
  22. public function setField($field)
  23. {
  24. $this->_set(SortOrder::FIELD, $field);
  25. return $this;
  26. }
  27. /**
  28. * Set sorting direction.
  29. *
  30. * @param string $direction
  31. * @return $this
  32. */
  33. public function setDirection($direction)
  34. {
  35. $this->_set(SortOrder::DIRECTION, $direction);
  36. return $this;
  37. }
  38. /**
  39. * @return $this
  40. */
  41. public function setAscendingDirection()
  42. {
  43. $this->setDirection(SortOrder::SORT_ASC);
  44. return $this;
  45. }
  46. /**
  47. * @return $this
  48. */
  49. public function setDescendingDirection()
  50. {
  51. $this->setDirection(SortOrder::SORT_DESC);
  52. return $this;
  53. }
  54. }