Exemple #1
0
    /**
     * Sync action
     *
     * @return \Zend\View\Model\JsonModel
     */
    public function syncAction()
    {
        $error = '';
        try {
            $this->updatePackagesCache->syncPackagesForUpdate();
            $lastSyncData = $this->updatePackagesCache->getPackagesForUpdate();

            $this->marketplaceManager->syncPackagesForInstall();
            $packagesForInstall = $this->marketplaceManager->getPackagesForInstall();
        } catch (\Exception $e) {
            $error = $e->getMessage();
        }


        $lastSyncData['countOfInstall'] =
            isset($packagesForInstall['packages']) ? count($packagesForInstall['packages']) : 0;
        $lastSyncData['countOfUpdate'] = isset($lastSyncData['packages']) ? count($lastSyncData['packages']) : 0;

        return new \Zend\View\Model\JsonModel(
            [
                'success' => true,
                'lastSyncData' => $lastSyncData,
                'error' => $error
            ]
        );
    }
 /**
  * Sync action
  *
  * @return \Zend\View\Model\JsonModel
  */
 public function syncAction()
 {
     $this->updatePackagesCache->syncPackagesForUpdate();
     $lastSyncData = $this->updatePackagesCache->getPackagesForUpdate();
     $this->connectManager->syncPackagesForInstall();
     $packagesForInstall = $this->connectManager->getPackagesForInstall();
     $lastSyncData['countOfInstall'] = isset($packagesForInstall['packages']) ? count($packagesForInstall['packages']) : 0;
     $lastSyncData['countOfUpdate'] = isset($lastSyncData['packages']) ? count($lastSyncData['packages']) : 0;
     return new \Zend\View\Model\JsonModel(['success' => true, 'lastSyncData' => $lastSyncData]);
 }
 public function testSyncAction()
 {
     $this->updatePackagesCacheMock->expects($this->once())->method('syncPackagesForUpdate');
     $this->updatePackagesCacheMock->expects($this->once())->method('getPackagesForUpdate')->willReturn($this->lastSyncData);
     $jsonModel = $this->controller->syncAction();
     $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('success', $variables);
     $this->assertTrue($variables['success']);
     $this->assertEquals($this->lastSyncData, $variables['lastSyncData']);
 }
 /**
  * Sync action
  *
  * @return \Zend\View\Model\JsonModel
  */
 public function syncAction()
 {
     $error = '';
     try {
         $this->updatePackagesCache->syncPackagesForUpdate();
         $lastSyncData = $this->updatePackagesCache->getPackagesForUpdate();
         $this->marketplaceManager->syncPackagesForInstall();
         $packagesForInstall = $this->marketplaceManager->getPackagesForInstall();
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     $lastSyncData = $this->formatLastSyncData($packagesForInstall, $lastSyncData);
     return new \Zend\View\Model\JsonModel(['success' => true, 'lastSyncData' => $lastSyncData, 'error' => $error]);
 }