vendor/pimcore/pimcore/models/Document/Page/Dao.php line 53

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\Page;
  15. use Pimcore\Model;
  16. use Pimcore\Model\Document\Targeting\TargetingDocumentDaoInterface;
  17. /**
  18.  * @internal
  19.  *
  20.  * @property \Pimcore\Model\Document\Page $model
  21.  */
  22. class Dao extends Model\Document\PageSnippet\Dao implements TargetingDocumentDaoInterface
  23. {
  24.     use Model\Document\Targeting\TargetingDocumentDaoTrait;
  25.     /**
  26.      * Get the data for the object by the given id, or by the id which is set in the object
  27.      *
  28.      * @param int $id
  29.      *
  30.      * @throws Model\Exception\NotFoundException
  31.      */
  32.     public function getById($id null)
  33.     {
  34.         if ($id != null) {
  35.             $this->model->setId($id);
  36.         }
  37.         $data $this->db->fetchAssociative("SELECT documents.*, documents_page.*, tree_locks.locked FROM documents
  38.             LEFT JOIN documents_page ON documents.id = documents_page.id
  39.             LEFT JOIN tree_locks ON documents.id = tree_locks.id AND tree_locks.type = 'document'
  40.                 WHERE documents.id = ?", [$this->model->getId()]);
  41.         if (!empty($data['id'])) {
  42.             $data['metaData'] = @unserialize($data['metaData']);
  43.             if (!is_array($data['metaData'])) {
  44.                 $data['metaData'] = [];
  45.             }
  46.             $this->assignVariablesToModel($data);
  47.         } else {
  48.             throw new Model\Exception\NotFoundException('Page with the ID ' $this->model->getId() . " doesn't exists");
  49.         }
  50.     }
  51.     public function create()
  52.     {
  53.         parent::create();
  54.         $this->db->insert('documents_page', [
  55.             'id' => $this->model->getId(),
  56.         ]);
  57.     }
  58.     /**
  59.      * @throws \Exception
  60.      */
  61.     public function delete()
  62.     {
  63.         $this->deleteAllProperties();
  64.         parent::delete();
  65.     }
  66. }