Doctrine\ODM\PHPCR\UnitOfWork::getAllLinearVersions PHP Метод

getAllLinearVersions() публичный Метод

TODO: implement labels once jackalope implements them, until then labels will be an empty array. TODO: implement limit
public getAllLinearVersions ( object $document, integer $limit ) : array
$document object the document of which to get the version history
$limit integer an optional limit to only get the latest $limit information
Результат array of => array("name" => , "labels" => , "created" => ) oldest version first
    public function getAllLinearVersions($document, $limit = -1)
    {
        $path = $this->getDocumentId($document);
        $metadata = $this->dm->getClassMetadata(get_class($document));
        if (!$metadata->versionable) {
            throw new InvalidArgumentException(sprintf("The document of type '%s' is not versionable", $metadata->getName()));
        }
        $versions = $this->session->getWorkspace()->getVersionManager()->getVersionHistory($path)->getAllLinearVersions();
        $result = array();
        foreach ($versions as $version) {
            /** @var $version \PHPCR\Version\VersionInterface */
            $result[$version->getName()] = array('name' => $version->getName(), 'labels' => array(), 'created' => $version->getCreated());
        }
        return $result;
    }

Usage Example

Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function getAllLinearVersions($document, $limit = -1)
 {
     if (!is_object($document)) {
         throw new InvalidArgumentException('Parameter $document needs to be an object, ' . gettype($document) . ' given');
     }
     $this->errorIfClosed();
     return $this->unitOfWork->getAllLinearVersions($document, $limit);
 }
All Usage Examples Of Doctrine\ODM\PHPCR\UnitOfWork::getAllLinearVersions
UnitOfWork