upgrade-functions.php 943 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. trait UpgradeFunctions
  3. {
  4. public function upgradeToVersion($version = '2.1.0')
  5. {
  6. switch ($version) {
  7. case '2.1.0':
  8. $this->upgradeSettingsTabURL();
  9. $this->upgradeHomepageTabURL();
  10. $this->setAPIResponse('success', 'Ran update function for version: ' . $version, 200);
  11. return true;
  12. default:
  13. return true;
  14. }
  15. }
  16. public function upgradeSettingsTabURL()
  17. {
  18. $response = [
  19. array(
  20. 'function' => 'query',
  21. 'query' => array(
  22. 'UPDATE tabs SET',
  23. ['url' => 'api/v2/page/settings'],
  24. 'WHERE url = ?',
  25. 'api/?v1/settings/page'
  26. )
  27. ),
  28. ];
  29. return $this->processQueries($response);
  30. }
  31. public function upgradeHomepageTabURL()
  32. {
  33. $response = [
  34. array(
  35. 'function' => 'query',
  36. 'query' => array(
  37. 'UPDATE tabs SET',
  38. ['url' => 'api/v2/page/homepage'],
  39. 'WHERE url = ?',
  40. 'api/?v1/homepage/page'
  41. )
  42. ),
  43. ];
  44. return $this->processQueries($response);
  45. }
  46. }