vendor/pimcore/pimcore/models/Document/PageSnippet/Dao.php line 43

Open in your IDE?
  1. <?php
  2. /**
  3. * Pimcore
  4. *
  5. * This source file is available under two different licenses:
  6. * - GNU General Public License version 3 (GPLv3)
  7. * - Pimcore Commercial License (PCL)
  8. * Full copyright and license information is available in
  9. * LICENSE.md which is distributed with this source code.
  10. *
  11. * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12. * @license http://www.pimcore.org/license GPLv3 and PCL
  13. */
  14. namespace Pimcore\Model\Document\PageSnippet;
  15. use Pimcore\Model;
  16. use Pimcore\Model\Document;
  17. /**
  18. * @internal
  19. *
  20. * @property \Pimcore\Model\Document\PageSnippet $model
  21. */
  22. abstract class Dao extends Model\Document\Dao
  23. {
  24. use Model\Element\Traits\VersionDaoTrait;
  25. /**
  26. * Delete all editables containing the content from the database
  27. */
  28. public function deleteAllEditables()
  29. {
  30. $this->db->delete('documents_editables', ['documentId' => $this->model->getId()]);
  31. }
  32. /**
  33. * Get all editables containing the content from the database
  34. *
  35. * @return Document\Editable[]
  36. */
  37. public function getEditables()
  38. {
  39. $editablesRaw = $this->db->fetchAllAssociative('SELECT * FROM documents_editables WHERE documentId = ?', [$this->model->getId()]);
  40. $editables = [];
  41. $loader = \Pimcore::getContainer()->get(Document\Editable\Loader\EditableLoader::class);
  42. foreach ($editablesRaw as $editableRaw) {
  43. /** @var Document\Editable $editable */
  44. $editable = $loader->build($editableRaw['type']);
  45. $editable->setName($editableRaw['name']);
  46. $editable->setDocument($this->model);
  47. $editable->setDataFromResource($editableRaw['data']);
  48. $editables[$editableRaw['name']] = $editable;
  49. }
  50. return $editables;
  51. }
  52. }