AbstractRow.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ nA+FcfJEqlljKnQskh69zN7RJom7AO+CWjAOWAIoYA4=
  5. *
  6. * @link http://www.phpprobid.com
  7. * @copyright Copyright (c) 2014 Online Ventures Software LTD & CodeCube SRL
  8. * @license http://www.phpprobid.com/license Commercial License
  9. *
  10. * @version 7.0
  11. */
  12. /**
  13. * abstract row class
  14. */
  15. namespace Ppb\Db\Table\Row;
  16. use Cube\Db\Table\Row\AbstractRow as CubeAbstractRow,
  17. Cube\Controller\Front;
  18. class AbstractRow extends CubeAbstractRow
  19. {
  20. /**
  21. *
  22. * logged in user model
  23. *
  24. * @var \Ppb\Db\Table\Row\User
  25. */
  26. protected $_user;
  27. /**
  28. *
  29. * settings array
  30. *
  31. * @var array
  32. */
  33. protected $_settings;
  34. /**
  35. *
  36. * get user model
  37. *
  38. * @return \Ppb\Db\Table\Row\User
  39. */
  40. public function getUser()
  41. {
  42. if (!$this->_user instanceof User) {
  43. $user = Front::getInstance()->getBootstrap()->getResource('user');
  44. if ($user instanceof User) {
  45. $this->setUser(
  46. $user);
  47. }
  48. }
  49. return $this->_user;
  50. }
  51. /**
  52. *
  53. * set the user model of the currently logged in user
  54. *
  55. * @param \Ppb\Db\Table\Row\User $user
  56. *
  57. * @return $this
  58. */
  59. public function setUser(User $user)
  60. {
  61. $this->_user = $user;
  62. return $this;
  63. }
  64. /**
  65. *
  66. * get settings array
  67. *
  68. * @return array
  69. */
  70. public function getSettings()
  71. {
  72. if (!is_array($this->_settings)) {
  73. $this->setSettings(
  74. Front::getInstance()->getBootstrap()->getResource('settings'));
  75. }
  76. return $this->_settings;
  77. }
  78. /**
  79. *
  80. * set the settings array
  81. *
  82. * @param array $settings
  83. *
  84. * @return $this
  85. */
  86. public function setSettings(array $settings)
  87. {
  88. $this->_settings = $settings;
  89. return $this;
  90. }
  91. }