public function checkDownloadedDependencies(array $dependencies)
 {
     $satisfied = array();
     foreach ($dependencies as $package => $constraint) {
         if (strtolower($package) === strtolower($this->identifier)) {
             continue;
         }
         /* get latest installed package version */
         $latestQuery = $this->xpdo->newQuery('modTransportPackage', array(array("UCASE({$this->xpdo->escape('package_name')}) LIKE UCASE({$this->xpdo->quote($package)})"), 'installed:IS' => null));
         $latestQuery->sortby('installed', 'DESC');
         /** @var modTransportPackage $latest */
         $latest = $this->xpdo->getObject('modTransportPackage', $latestQuery);
         if ($latest) {
             $latest->parseSignature();
             if (xPDOTransport::satisfies($latest->version, $constraint)) {
                 $satisfied[strtolower($package)] = $latest->signature;
                 continue;
             }
         }
     }
     return $satisfied;
 }
 public function latest($identifier, $constraint = '*', array $args = array())
 {
     $latest = array();
     if (strpos($identifier, '-') === false) {
         /** @var modRestResponse $response */
         $response = $this->request('package/versions', 'GET', array_merge(array('package' => $identifier, 'constraint' => $constraint), $args));
         if ($response) {
             if (!$response->isError()) {
                 $xml = $response->toXml();
                 /** @var SimpleXMLElement $resolver */
                 foreach ($xml as $resolver) {
                     $node = array();
                     if (xPDOTransport::satisfies((string) $resolver->version, $constraint)) {
                         $this->fromXML($resolver, $node);
                         array_push($latest, $node);
                     }
                 }
             } else {
                 $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $response->getError(), '', __METHOD__, __FILE__, __LINE__);
             }
         }
     } else {
         $response = $this->request('package/update', 'GET', array_merge(array('signature' => $identifier, 'constraint' => $constraint), $args));
         if ($response) {
             if (!$response->isError()) {
                 $xml = $response->toXml();
                 foreach ($xml as $resolver) {
                     $node = array();
                     if (xPDOTransport::satisfies((string) $resolver->version, $constraint)) {
                         $this->fromXML($resolver, $node);
                         array_push($latest, $node);
                     }
                 }
             }
         }
     }
     return $latest;
 }
Beispiel #3
0
 /**
  * Test xPDOTransport::satisfies()
  *
  * @param string $version
  * @param string $constraint
  * @param bool $expected
  * @dataProvider providerSatisfies
  */
 public function testSatisfies($version, $constraint, $expected)
 {
     $this->assertEquals($expected, xPDOTransport::satisfies($version, $constraint));
 }