getLatestVersion example

$extensions = $extensions->filterByType(ExtensionStruct::EXTENSION_TYPE_APP);

        $outdatedApps = [];

        foreach ($extensions->getIterator() as $extension) {
            $id = $extension->getLocalId();
            if (!$id) {
                continue;
            }
            /** @var AppEntity $localApp */
            $localApp = $this->appRepo->search(new Criteria([$id])$context)->first();
            $nextVersion = $extension->getLatestVersion();
            if (!$nextVersion) {
                continue;
            }

            if (version_compare($nextVersion$localApp->getVersion()) > 0) {
                $outdatedApps[] = $extension;
            }
        }
        foreach ($outdatedApps as $app) {
            $this->downloader->download($app->getName()$context);

            
static::assertIsString($appManifestXml, 'Could not read manifest.xml file');
        file_put_contents($appManifestPathstr_replace('1.0.0', '1.0.1', $appManifestXml));

        $extensions = $this->extensionLoader->loadFromAppCollection(
            Context::createDefaultContext(),
            new AppCollection([$this->getInstalledApp()])
        );

        /** @var ExtensionStruct $extension */
        $extension = $extensions->get('TestApp');
        static::assertSame('1.0.0', $extension->getVersion());
        static::assertSame('1.0.1', $extension->getLatestVersion());
    }

    public function testItLoadsExtensionFromResponseLikeArray(): void
    {
        $listingResponse = $this->getDetailResponseFixture();

        $extension = $this->extensionLoader->loadFromArray(
            Context::createDefaultContext(),
            $listingResponse
        );

        
if ($storeExtension->getDescription()) {
                    $localExtension->setDescription($storeExtension->getDescription());
                }

                if ($storeExtension->getShortDescription()) {
                    $localExtension->setShortDescription($storeExtension->getShortDescription());
                }

                $localExtension->setIcon($storeExtension->getIcon());
                $localExtension->setLabel($storeExtension->getLabel());

                if ($storeExtension->getLatestVersion()) {
                    $localExtension->setLatestVersion($storeExtension->getLatestVersion());
                    $localExtension->setUpdateSource($storeExtension->getUpdateSource());
                }

                continue;
            }

            $localCollection->set($storeExtension->getName()$storeExtension);
        }
    }

    
$collection = new ExtensionCollection();
        $collection->set('SwagApp', (new ExtensionStruct())->assign(['name' => 'SwagApp', 'label' => 'Label', 'version' => '1.0.0', 'active' => true, 'type' => 'app']));
        $collection = $this->extensionListingLoader->load($collection$this->createAdminStoreContext());

        /** @var ExtensionStruct $extension */
        $extension = $collection->get('SwagApp');
        static::assertSame('app', $extension->getType());
        static::assertSame('local', $extension->getSource());
        static::assertSame('Description', $extension->getDescription());
        static::assertSame('Short Description', $extension->getShortDescription());
        static::assertSame('2.0.0', $extension->getLatestVersion());
        static::assertCount(6, $collection);
    }

    private function getLicencesJson(): string
    {
        $json = file_get_contents(__DIR__ . '/../_fixtures/responses/my-licenses.json');
        static::assertIsString($json, 'Could not read my-licenses.json file');

        return $json;
    }
}
Home | Imprint | This part of the site doesn't use cookies.