Add a repository detected version.

@param string $version
@param string $kind
@param string $repoName

@return static
347359
public function addDetectedVersion($version, $kind, $repoName)
    {
        $this->detectedVersions[$version] = [
            'kind' => $kind,
            'repoName' => $repoName,
        ];

        return $this;
    }
1318091
def add_repository(self, name, repository_type, repository_class,
                       aggregate_class, make_default, configuration):
        
        repo_mgr = self.get_registered_utility(IRepositoryManager)
        if name is None:
            # If no name was given, this is assumed to be the ROOT repository
            # for the given repository type.
            name = REPOSITORY_DOMAINS.ROOT
        repo = repo_mgr.new(repository_type, name=name,
                            make_default=make_default,
                            repository_class=repository_class,
                            aggregate_class=aggregate_class,
                            configuration=configuration)
        repo_mgr.set(repo)
590691
private function updateComposerReplacesVersion($version, array $component)
    {
        $composer = $this->rootPath() .'/composer.json';
        if (!file_exists($composer)) {
            throw new \Exception('Invalid composer.json path');
        }

        $data = json_decode(file_get_contents($composer), true);

        $data['replace'][$component['name']] = $version;

        file_put_contents($composer, json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
    }
91279
public function publishVersion($contentId, $versionNumber)
    {
        $versionInfo = $this->repository->getContentService()->loadVersionInfo(
            $this->repository->getContentService()->loadContentInfo($contentId),
            $versionNumber
        );

        if (!$versionInfo->isDraft()) {
            throw new ForbiddenException('Only version in status DRAFT can be published');
        }

        $this->repository->getContentService()->publishVersion(
            $versionInfo
        );

        return new Values\NoContent();
    }
1355288
public function withProtocolVersion($version)
    {
        Validator::checkProtocolVersion($version);
        $instance = clone $this;
        $instance->protocol = $version;

        return $instance;
    }
346122
public function install(\Composer\Repository\InstalledRepositoryInterface $repo, \Composer\Package\PackageInterface $package) {
		parent::install($repo, $package);
		
		$this->removeResources($package);
		$this->installResources($package);
		
	}
924174
protected function addMigrationHistory(string $version, ?string $namespace = null): void
    {
        $this->stdout(' > Adding migration history entry ...', Console::FG_YELLOW);

        $this->db->createCommand()->insert(
            $this->migrationTable,
            [
                'version' => ($namespace ? $namespace . '\\' : '') . $version,
                'apply_time' => time(),
            ]
        )->execute();

        $this->stdout("DONE.\n", Console::FG_GREEN);
    }
922785
public function loadVersionRelations($contentId, $versionNumber, Request $request)
    {
        $offset = $request->query->has('offset') ? (int)$request->query->get('offset') : 0;
        $limit = $request->query->has('limit') ? (int)$request->query->get('limit') : -1;

        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
        $relationList = $this->repository->getContentService()->loadRelations(
            $this->repository->getContentService()->loadVersionInfo($contentInfo, $versionNumber)
        );

        $relationList = array_slice(
            $relationList,
            $offset >= 0 ? $offset : 0,
            $limit >= 0 ? $limit : null
        );

        $relationListValue = new Values\RelationList(
            $relationList,
            $contentId,
            $versionNumber,
            $request->getPathInfo()
        );

        if ($contentInfo->mainLocationId === null) {
            return $relationListValue;
        }

        return new Values\CachedValue(
            $relationListValue,
            array('locationId' => $contentInfo->mainLocationId)
        );
    }
395554
@Override
    public void addRemoteRepo(MavenRemoteRepository repository) {
        Builder builder = new Builder(repository.getId(), repository.getType(), repository.getUrl());
        builder.setPolicy(new RepositoryPolicy(true, repository.getUpdatePolicy() == null ? null : repository
                .getUpdatePolicy().apiValue(), repository.getChecksumPolicy() == null ? null : repository
                .getChecksumPolicy().apiValue()));

        for (RemoteRepository r : this.additionalRemoteRepositories) {
            if (r.getId().equals(repository.getId())) {
                this.additionalRemoteRepositories.remove(r);
            }
        }
        this.additionalRemoteRepositories.add(builder.build());
    }
971430
public function activate($versionNumber, $oldVersionNumber = '')
    {
        $runtimeManager = $this->framework->getRuntimeManager();
        $runtimeManager->addFilterHandler('\\Zepi\\Core\\AccessControl\\Filter\\AccessLevelManager\\RemoveAccessLevel', '\\Zepi\\Core\\AccessControl\\FilterHandler\\RevokePermissionsForRemovedAccessLevel');
        $runtimeManager->addFilterHandler('\\Zepi\\Turbo\\Filter\\VerifyEventName', '\\Zepi\\Core\\AccessControl\\FilterHandler\\CheckEventAccessForSession');
        
        $runtimeManager->addEventHandler('\\Zepi\\Core\\AccessControl\\Event\\RedirectRequestWithoutSession', '\\Zepi\\Core\\AccessControl\\EventHandler\\RedirectRequestWithoutSession');
        $runtimeManager->addEventHandler('\\Zepi\\Core\\AccessControl\\Event\\DisplayNoAccessMessage', '\\Zepi\\Core\\AccessControl\\EventHandler\\DisplayNoAccessMessage');
        
        // Data Sources
        $dataSourceManager = $this->framework->getDataSourceManager();
        $dataSourceManager->addDataSource(
            '\\Zepi\\Core\\AccessControl\\DataSource\\AccessEntitiesDataSourceInterface',
            '\\Zepi\\DataSource\\Doctrine',
            '\\Zepi\\Core\\AccessControl\\DataSource\\AccessEntitiesDataSourceDoctrine'
        );
        
        $dataSourceManager->addDataSource(
            '\\Zepi\\Core\\AccessControl\\DataSource\\PermissionsDataSourceInterface',
            '\\Zepi\\DataSource\\Doctrine',
            '\\Zepi\\Core\\AccessControl\\DataSource\\PermissionsDataSourceDoctrine'
        );
        
        // Access Levels
        $accessLevelsManager = $this->framework->getInstance('\\Zepi\\Core\\AccessControl\\Manager\\AccessLevelManager');
        $accessLevelsManager->addAccessLevel(new \Zepi\Core\AccessControl\Entity\AccessLevel(
            '\\Global\\*',
            'Global Super User',
            'Super user privileges. Can do everything.',
            '\\Zepi\\Core\\AccessControl'
        ));
        
        $accessLevelsManager->addAccessLevel(new \Zepi\Core\AccessControl\Entity\AccessLevel(
            '\\Global\\Disabled',
            'Disabled User',
            'A disabled user. Can do nothing, not even login.',
            '\\Zepi\\Core\\AccessControl'
        ));
        
        $accessLevelsManager->addAccessLevel(new \Zepi\Core\AccessControl\Entity\AccessLevel(
            '\\Global\\Active',
            'Active User',
            'A active user. Can login and change the user password.',
            '\\Zepi\\Core\\AccessControl'
        ));
    }
967197
public function activate($versionNumber, $oldVersionNumber = '')
    {
        $runtimeManager = $this->framework->getRuntimeManager();
        $runtimeManager->addEventHandler('\\Zepi\\Core\\Management\\Event\\RebuildFrameworkCache', '\\Zepi\\Core\\Management\\EventHandler\\RebuildFrameworkCache');
        $runtimeManager->addEventHandler('\\Zepi\\Core\\Management\\Event\\ListModules', '\\Zepi\\Core\\Management\\EventHandler\\ListModules');
        
        $routeManager = $this->framework->getRouteManager();
        $routeManager->addRoute('core|rebuildFrameworkCache', '\\Zepi\\Core\\Management\\Event\\RebuildFrameworkCache');
        $routeManager->addRoute('core|listModules', '\\Zepi\\Core\\Management\\Event\\ListModules');
    }
1045818
private function getDepBowerJson($version)
    {
        list($repoUser, $repoName) = explode('/', $this->clearGitURL($this->url));
        $contents = $this->githubClient->api('repo')->contents();
        if ($contents->exists($repoUser, $repoName, 'bower.json', $version)) {
            $json = $contents->download($repoUser, $repoName, 'bower.json', $version);
        } else {
            $isPackageJson = true;
            if ($contents->exists($repoUser, $repoName, 'package.json', $version)) {
                $json = $contents->download($repoUser, $repoName, 'package.json', $version);
            } elseif ('master' != $version) {
                return $this->getDepBowerJson('master');
            }
            // try anyway. E.g. exists() return false for Modernizr, but then it downloads :-|
            $json = $contents->download($repoUser, $repoName, 'package.json', $version);
        }

        if ("\xef\xbb\xbf" == substr($json, 0, 3)) {
            $json = substr($json, 3);
        }

        // for package.json, remove dependencies (see the case of Modernizr)
        if (isset($isPackageJson)) {
            $array = json_decode($json, true);
            if (isset($array['dependencies'])) {
                unset($array['dependencies']);
            }
            $json = json_encode($array, JSON_PRETTY_PRINT);
        }

        return $json;
    }
33898
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        parent::install($repo, $package);
        $this->generateVendorMetaData();
    }
113105
public function addVersion($con = null)
    {
        $this->enforceVersion = false;

        $version = new ChildSkillVersion();
        $version->setId($this->getId());
        $version->setSportId($this->getSportId());
        $version->setName($this->getName());
        $version->setAlternativeName($this->getAlternativeName());
        $version->setSlug($this->getSlug());
        $version->setDescription($this->getDescription());
        $version->setHistory($this->getHistory());
        $version->setIsTranslation($this->getIsTranslation());
        $version->setIsRotation($this->getIsRotation());
        $version->setIsAcyclic($this->getIsAcyclic());
        $version->setIsCyclic($this->getIsCyclic());
        $version->setLongitudinalFlags($this->getLongitudinalFlags());
        $version->setLatitudinalFlags($this->getLatitudinalFlags());
        $version->setTransversalFlags($this->getTransversalFlags());
        $version->setMovementDescription($this->getMovementDescription());
        $version->setSequencePictureUrl($this->getSequencePictureUrl());
        $version->setVariationOfId($this->getVariationOfId());
        $version->setStartPositionId($this->getStartPositionId());
        $version->setEndPositionId($this->getEndPositionId());
        $version->setIsComposite($this->getIsComposite());
        $version->setIsMultiple($this->getIsMultiple());
        $version->setMultipleOfId($this->getMultipleOfId());
        $version->setMultiplier($this->getMultiplier());
        $version->setGeneration($this->getGeneration());
        $version->setImportance($this->getImportance());
        $version->setPictureId($this->getPictureId());
        $version->setVideoId($this->getVideoId());
        $version->setTutorialId($this->getTutorialId());
        $version->setKstrukturId($this->getKstrukturId());
        $version->setFunctionPhaseId($this->getFunctionPhaseId());
        $version->setObjectId($this->getObjectId());
        $version->setVersion($this->getVersion());
        $version->setVersionCreatedAt($this->getVersionCreatedAt());
        $version->setVersionComment($this->getVersionComment());
        $version->setSkill($this);
        if (($related = $this->getVariationOf(null, $con)) && $related->getVersion()) {
            $version->setVariationOfIdVersion($related->getVersion());
        }
        if (($related = $this->getMultipleOf(null, $con)) && $related->getVersion()) {
            $version->setMultipleOfIdVersion($related->getVersion());
        }
        if ($relateds = $this->getVariations(null, $con)->toKeyValue('Id', 'Version')) {
            $version->setKkTrixionarySkillIds(array_keys($relateds));
            $version->setKkTrixionarySkillVersions(array_values($relateds));
        }
        if ($relateds = $this->getMultiples(null, $con)->toKeyValue('Id', 'Version')) {
            $version->setKkTrixionarySkillIds(array_keys($relateds));
            $version->setKkTrixionarySkillVersions(array_values($relateds));
        }
        $version->save($con);

        return $version;
    }
451165
public function repoGetFileInfo($repo, $path, $ref = null)
    {
        $src = $this->client->api('Repositories\Src');
        /** @var \Buzz\Message\Response $response */
        $response = $this->checkResponse($src->get($this->username, $repo, $ref, $path));

        return $this->cleanSrcData(json_decode($response->getContent(), true));
    }
877792
public function createVersionInfoForContent(Content $content, $versionNo, $userId)
    {
        $versionInfo = new VersionInfo();

        $versionInfo->contentInfo = $content->versionInfo->contentInfo;
        $versionInfo->versionNo = $versionNo;
        $versionInfo->creatorId = $userId;
        $versionInfo->status = VersionInfo::STATUS_DRAFT;
        $versionInfo->initialLanguageCode = $content->versionInfo->initialLanguageCode;
        $versionInfo->creationDate = time();
        $versionInfo->modificationDate = $versionInfo->creationDate;
        $versionInfo->names = is_object($content->versionInfo) ? $content->versionInfo->names : array();
        $versionInfo->languageCodes = $content->versionInfo->languageCodes;

        return $versionInfo;
    }
57710
public function set(string $version): VersionInterface
    {
        $matches = [];
        $numbers = [];

        if (preg_match($this->regex, $version, $matches)) {
            $numbers = $this->mapMatches($matches);
        }

        if (empty($numbers)) {
            return new Version('0');
        }

        $major = (array_key_exists('major', $numbers) ? $numbers['major'] : '0');
        $minor = (array_key_exists('minor', $numbers) ? $numbers['minor'] : '0');

        if (array_key_exists('micro', $numbers)) {
            $micro      = $numbers['micro'];
            $patch      = (array_key_exists('patch', $numbers) ? $numbers['patch'] : null);
            $micropatch = (array_key_exists('micropatch', $numbers) ? $numbers['micropatch'] : null);
        } else {
            $micro      = '0';
            $patch      = null;
            $micropatch = null;
        }

        $stability = (array_key_exists('stability', $numbers)) ? $numbers['stability'] : null;

        if (null === $stability || 0 === mb_strlen($stability)) {
            $stability = 'stable';
        }

        $stability = mb_strtolower($stability);
        switch ($stability) {
            case 'rc':
                $stability = 'RC';

                break;
            case 'patch':
            case 'pl':
            case 'p':
                $stability = 'patch';

                break;
            case 'beta':
            case 'b':
                $stability = 'beta';

                break;
            case 'alpha':
            case 'a':
                $stability = 'alpha';

                break;
            case 'dev':
            case 'd':
                $stability = 'dev';

                break;
        }

        $build = (array_key_exists('build', $numbers)) ? $numbers['build'] : null;

        return new Version($major, $minor, $micro, $patch, $micropatch, $stability, $build);
    }