Admin_WorkflowController::getLatestVersion PHP Метод

getLatestVersion() защищенный Метод

protected getLatestVersion ( Document | Asset | Concrete $element ) : Document | Asset | Concrete
$element Pimcore\Model\Document | Pimcore\Model\Asset | Pimcore\Model\Object\Concrete
Результат Pimcore\Model\Document | Pimcore\Model\Asset | Pimcore\Model\Object\Concrete
    protected function getLatestVersion($element)
    {
        //TODO move this maybe to a service method, since this is also used in ObjectController and DocumentControllers
        if ($element instanceof Document) {
            $latestVersion = $element->getLatestVersion();
            if ($latestVersion) {
                $latestDoc = $latestVersion->loadData();
                if ($latestDoc instanceof Document) {
                    $element = $latestDoc;
                    $element->setModificationDate($element->getModificationDate());
                }
            }
        }
        if ($element instanceof Object\Concrete) {
            $modificationDate = $element->getModificationDate();
            $latestVersion = $element->getLatestVersion();
            if ($latestVersion) {
                $latestObj = $latestVersion->loadData();
                if ($latestObj instanceof ConcreteObject) {
                    $element = $latestObj;
                    $element->setModificationDate($modificationDate);
                }
            }
        }
        return $element;
    }