ContentSections.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ c8ZvSxz82PWKe8BtY+Gt/YF+Pk9yVMs1ZRCdXFMGSQA=
  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. * content sections service view helper class
  14. */
  15. namespace Ppb\View\Helper;
  16. use Cube\View\Helper\AbstractHelper,
  17. Ppb\Service\Table\Relational\ContentSections as ContentSectionsService;
  18. class ContentSections extends AbstractHelper
  19. {
  20. /**
  21. *
  22. * content sections table service
  23. *
  24. * @var \Ppb\Service\Table\Relational\ContentSections
  25. */
  26. protected $_contentSections;
  27. /**
  28. *
  29. * data resulted from a previous fetch operation
  30. *
  31. * @var array
  32. */
  33. protected $_data = array();
  34. public function __construct()
  35. {
  36. $this->setContentSections();
  37. }
  38. /**
  39. *
  40. * get content sections table service
  41. *
  42. * @return \Ppb\Service\Table\Relational\ContentSections
  43. */
  44. public function getContentSections()
  45. {
  46. return $this->_contentSections;
  47. }
  48. /**
  49. *
  50. * set content sections table service
  51. *
  52. * @param \Ppb\Service\Table\Relational\ContentSections $contentSections
  53. * @return $this
  54. */
  55. public function setContentSections(ContentSectionsService $contentSections = null)
  56. {
  57. if (!$contentSections instanceof ContentSectionsService) {
  58. $contentSections = new ContentSectionsService();
  59. }
  60. $this->_contentSections = $contentSections;
  61. return $this;
  62. }
  63. public function getData()
  64. {
  65. return $this->_data;
  66. }
  67. /**
  68. *
  69. * get all content sections having a certain parent id
  70. *
  71. * @param string|\Cube\Db\Select $where SQL where clause, or a select object
  72. * @return array
  73. */
  74. public function contentSections($where = null)
  75. {
  76. if ($where === null) {
  77. return $this;
  78. }
  79. $this->_data = $this->getContentSections()->fetchAll($where);
  80. return $this->_data;
  81. }
  82. }