<?php
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/
namespace Pimcore\Model\Element;
use Pimcore\Model;
/**
* @internal
*
* @property Model\Document|Model\Asset|Model\DataObject\AbstractObject $model
*/
abstract class Dao extends Model\Dao\AbstractDao
{
/**
* @return int[]
*
* @throws \Exception
*/
public function getParentIds()
{
// collect properties via parent - ids
$parentIds = [1];
$obj = $this->model->getParent();
if ($obj) {
while ($obj) {
if ($obj->getId() == 1) {
break;
}
if (in_array($obj->getId(), $parentIds)) {
throw new \Exception('detected infinite loop while resolving all parents from ' . $this->model->getId() . ' on ' . $obj->getId());
}
$parentIds[] = $obj->getId();
$obj = $obj->getParent();
}
}
return $parentIds;
}
/**
* @param string $fullpath
*
* @return array
*/
protected function extractKeyAndPath($fullpath)
{
$key = '';
$path = $fullpath;
if ($fullpath !== '/') {
$lastPart = strrpos($fullpath, '/') + 1;
$key = substr($fullpath, $lastPart);
$path = substr($fullpath, 0, $lastPart);
}
return [
'key' => $key,
'path' => $path,
];
}
/**
* @return int
*/
abstract public function getVersionCountForUpdate(): int;
}