Widget.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Widget\Model\ResourceModel;
  7. /**
  8. * Resource model for widget.
  9. *
  10. * @deprecated 101.0.0 Data from this table was moved to xml(widget.xml).
  11. */
  12. class Widget extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
  13. {
  14. /**
  15. * Define main table
  16. *
  17. * @return void
  18. */
  19. protected function _construct()
  20. {
  21. $this->_init('widget', 'widget_id');
  22. }
  23. /**
  24. * Retrieves pre-configured parameters for widget
  25. *
  26. * @param int $widgetId
  27. * @return array|false
  28. */
  29. public function loadPreconfiguredWidget($widgetId)
  30. {
  31. $connection = $this->getConnection();
  32. $select = $connection->select()->from(
  33. $this->getMainTable()
  34. )->where(
  35. $this->getIdFieldName() . '=:' . $this->getIdFieldName()
  36. );
  37. $bind = [$this->getIdFieldName() => $widgetId];
  38. $widget = $connection->fetchRow($select, $bind);
  39. if (is_array($widget)) {
  40. if ($widget['parameters']) {
  41. $widget['parameters'] = $this->getSerializer()->unserialize($widget['parameters']);
  42. }
  43. return $widget;
  44. }
  45. return false;
  46. }
  47. }