/*!
\return the creator of the current version.
348847
function creator()
    {
        if ( isset( $this->CreatorID ) and $this->CreatorID )
        {
            return eZContentObject::fetch( $this->CreatorID );
        }
        return null;
    }
71213
public function getNodeVersion($type)
    {
        if ($type == 'public') {
            return $this->publicNodeVersion;
        }

        $nodeVersions = $this->getNodeVersions();

        $max = count($nodeVersions);
        for ($i = $max - 1; $i >= 0; --$i) {
            /* @var NodeVersion $nodeVersion */
            $nodeVersion = $nodeVersions[$i];

            if ($type == $nodeVersion->getType()) {
                return $nodeVersion;
            }
        }

        return null;
    }
1240639
public function edit()
    {
        $builder = (new ManagementBuilder(TransactionType::EDIT))
            ->withPaymentMethod($this->transactionReference);

        if ($this->commercialIndicator !== null) {
            $builder = $builder->withModifier(TransactionModifier::LEVEL_II);
        }

        return $builder;
    }
40680
public function current()
    {
        $value = parent::current();
        if (!isset($value['file'])) {
            $value['file'] = $this->collection->createDownload(array_intersect_key($value, ['_id' => true, 'filename' => true, 'length' => true, 'chunkSize' => true]));
        }
        return $value;
    }
863506
function author($new = null, $return_entity = false)
    {
        if (isset($new)){
            if ($new instanceof Entity){
                $this->_author = $new;
                $new = $new->uri();
            }else{
                $this->_author = null; // for reloading
            }
            if ($new != $this->_attributes['author']){
                $this->change('author', $new);
            }
        }
        if ($return_entity){
            if (!isset($this->_author)){
                if (isset($this->_attributes['author'])){
                    $this->_author = Data::read($this->_attributes['author']);
                }else{
                    $this->_author = false;
                }
            }
            return $this->_author;
        }
        return $this->_attributes['author'];
    }
1038647
function Version()
	{
		$ver = (is_null($this) ? XDB_VERSION : $this->version);
		$str = sprintf("%s/%d.%d", XDB_TAGNAME, ($ver >> 5), ($ver & 0x1f));
		if (!is_null($this)) $str .= " <base={$this->hash_base}, prime={$this->hash_prime}>";
		return $str;
	}
526881
public function getUser($user)
    {
        $result = null;
        if ($user === 'current') {
            $u = new \User();
            if ($u->isRegistered()) {
                $result = $u;
            }
        } elseif (is_int($user) || (is_string($user) && is_numeric($user))) {
            $result = \User::getByUserID($user);
        } elseif ($user instanceof UserService) {
            $result = $user;
        } elseif ($user instanceof UserEntity) {
            $result = \User::getByUserID($user->getUserID());
        }

        return $result;
    }
614765
public static function make()
    {
        $stream = new Stream();
        $source = static::getSource();
        $stream->copy($source);

        if (! static::$source) {
            fclose($source);
        }

        return $stream;
    }
1316020
public function create()
    {
        /**
         * @var Manufacturer $manufacturer
         */
        $classNamespace = $this->getEntityNamespace();
        $manufacturer = new $classNamespace();
        $manufacturer
            ->setImages(new ArrayCollection())
            ->setImagesSort('')
            ->setEnabled(true)
            ->setCreatedAt($this->now());

        return $manufacturer;
    }
276806
function makeResource()
    {
        $resource = $this->resource;
        if ($this->id) $resource .= '/' . $this->id;
        return $resource;
    }
652322
private function getCreateChangeSetHandler()
    {
        return function ($key, $value, $obj) {
            if (null !== $value) {
                $obj[$key] = $value;
            }
            return $obj;
        };
    }
437767
public function getOwnerUser()
    {
        $reflection = ClassUtils::newReflectionObject($this);

        if ($reflection->hasMethod('getUser')) {
            return $this->getUser();
        }
        elseif ($reflection->hasMethod('getUserProfile')) {
            return $this->getUserProfile() ? $this->getUserProfile()->getUser() : null;
        }

        return null;
    }
506635
public function getVersionToModify(CalendarEvent $event, User $u)
    {
        if (!count($event->getVersions())) {
            return new CalendarEventVersion($event, $u->getUserInfoObject()->getEntityObject());
        }

        $recent = $event->getRecentVersion();

        $now = new \DateTime('now', new \DateTimeZone($event->getCalendar()->getTimezone()));
        $recentVersionDate = $recent->getDateAdded();
        if ($recent->getAuthor()->getUserID() == $u->getUserID() && !$recent->isApproved() && (
            ($now->getTimestamp() - $recentVersionDate->getTimestamp()) < self::INTERVAL_VERSION
            )) {
            // We can use the same version.
            return $recent;
        } else if ($recent) {
            $return = clone $recent;
            $return->setAuthor($u->getUserInfoObject()->getEntityObject());
            $return->setIsApproved(false);

            // Persist the cloned version
            $this->entityManager->persist($return);
            $this->entityManager->flush();

            // Duplicate attribute Values
            $values = $this->eventCategory->getAttributeValues($recent);
            foreach($values as $value) {
                $value = clone $value;
                $value->setVersion($return);
                $this->entityManager->persist($value);
            }
            $this->entityManager->flush();

            return $return;
        }
    }
204655
public function detectVersion(string $useragent): VersionInterface
    {
        $doMatch = preg_match('/ObigoInternetBrowser\/QO?([\d.]+)/', $useragent, $matches);

        if ($doMatch) {
            return (new VersionFactory())->set($matches[1]);
        }

        $doMatch = preg_match('/obigo\-browser\/q([\d.]+)/i', $useragent, $matches);

        if ($doMatch) {
            return (new VersionFactory())->set($matches[1]);
        }

        $doMatch = preg_match('/(?:teleca|obigo)[\-\/]q([\d.]+)/i', $useragent, $matches);

        if ($doMatch) {
            return (new VersionFactory())->set($matches[1]);
        }

        return (new VersionFactory())->set('0');
    }
1021779
protected function getArtisan()
    {
        if (is_null($this->artisan)) {
            return $this->artisan = (new Artisan(Zilf::VERSION))
                ->resolveCommands($this->commands);
        }

        return $this->artisan;
    }
563814
public function getCurrentVersion()
    {
        // We don't cache this code as the current version is pretty volatile.
        // TODO - that means they're no point in a setter then?
        // maybe we should cache and call a reset() method every time a migration is run
        $versions = $this->getVersions();
        $version = 0;

        if (!empty($versions)) {
            $version = end($versions);
        }

        $this->setCurrentVersion($version);

        return $this->currentVersion;
    }
637502
protected function getTenantCacheName($default)
    {
        if ($this->isMultiSiteTenant()) {
            $creator = $this['auth.tenant']->getTenantCreator()->getDomain();
            $owner   = $this['auth.tenant']->getTenantOwner()->getDomain();

            if ($creator && $creator != $owner) {
                return $creator;
            } else {
                return $owner;
            }
        }

        return $default;
    }