private function createCatalog()

in pp3/module/Application/src/Application/Controller/CliController.php [63:119]


    private function createCatalog(\Application\Entity\NbVersion $version, $experimental, $force) {
        if ($experimental) {
            $items = $this->_pluginVersionRepository->getNonVerifiedVersionsByNbVersion($version->getVersion(), true);
        } else {
            $items = $this->_pluginVersionRepository->getVerifiedVersionsByNbVersion($version->getVersion(), true);
        }

        $catalog = new Catalog(
                $this->_pluginVersionRepository,
                $version->getVersion(),
                $items,
                $experimental,
                $this->_config['pp3']['dtdPath'],
                $this->getDownloadBaseUrl(),
                $this->_config['pp3']['catalogSavepath']
        );

        $rebuildNeeded = $version->getCatalogRebuildRequested() != null
            && ( $version->getCatalogRebuild() == null 
                 || ($version->getCatalogRebuild()->getTimestamp() < $version->getCatalogRebuildRequested()->getTimestamp())
               );

        $rebuildNeeded |= (! $catalog->catalogFileExits());

        $rebuildNeeded |= $force;

        if (! $rebuildNeeded) {
            printf("Skipping %scatalog for %s\n", $experimental ? 'experimental ' : '', $version->getVersion());
            return;
        }

        printf("Generating %scatalog for %s\n", $experimental ? 'experimental ' : '', $version->getVersion());

        try {
            $validationErrors = array();
            $catalog->storeXml(true, $validationErrors);
            foreach($validationErrors as $pluginVersionId => $errorList) {
                $versionErrors = array();
                foreach($errorList as $errorEntry) {
                    $versionErrors[] = array(
                        'code' => $errorEntry->code, 
                        'message' => $errorEntry->message
                    );
                }
                $pluginVersion = $this->_pluginVersionRepository->find($pluginVersionId);
                $pluginVersion->setErrorMessage(json_encode($versionErrors));
                // Remove netbeans version assignments
                foreach($pluginVersion->getNbVersionsPluginVersions() as $nbvPv) {
                    $this->_nbVersionPluginVersionRepository->remove($nbvPv);
                }
                $this->_pluginVersionRepository->persist($pluginVersion);
                $this->_sendErrorInformation($pluginVersion, $errorList);
            }
        } catch (Exception $e) {
            echo($e);
        }
    }