vendor/pimcore/pimcore/models/Element/Dao.php line 36

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\Element;
  15. use Pimcore\Model;
  16. /**
  17. * @internal
  18. *
  19. * @property Model\Document|Model\Asset|Model\DataObject\AbstractObject $model
  20. */
  21. abstract class Dao extends Model\Dao\AbstractDao
  22. {
  23. /**
  24. * @return int[]
  25. *
  26. * @throws \Exception
  27. */
  28. public function getParentIds()
  29. {
  30. // collect properties via parent - ids
  31. $parentIds = [1];
  32. $obj = $this->model->getParent();
  33. if ($obj) {
  34. while ($obj) {
  35. if ($obj->getId() == 1) {
  36. break;
  37. }
  38. if (in_array($obj->getId(), $parentIds)) {
  39. throw new \Exception('detected infinite loop while resolving all parents from ' . $this->model->getId() . ' on ' . $obj->getId());
  40. }
  41. $parentIds[] = $obj->getId();
  42. $obj = $obj->getParent();
  43. }
  44. }
  45. return $parentIds;
  46. }
  47. /**
  48. * @param string $fullpath
  49. *
  50. * @return array
  51. */
  52. protected function extractKeyAndPath($fullpath)
  53. {
  54. $key = '';
  55. $path = $fullpath;
  56. if ($fullpath !== '/') {
  57. $lastPart = strrpos($fullpath, '/') + 1;
  58. $key = substr($fullpath, $lastPart);
  59. $path = substr($fullpath, 0, $lastPart);
  60. }
  61. return [
  62. 'key' => $key,
  63. 'path' => $path,
  64. ];
  65. }
  66. /**
  67. * @return int
  68. */
  69. abstract public function getVersionCountForUpdate(): int;
  70. }