Airship\Cabin\Bridge\Blueprint\Skyport::manualRefresh PHP Method

manualRefresh() public method

Manually refresh a package's metadata.
public manualRefresh ( string $type, string $supplier, string $pkg ) : boolean
$type string
$supplier string
$pkg string
return boolean
    public function manualRefresh(string $type, string $supplier, string $pkg) : bool
    {
        $metadata = $this->getPackageMetadata($type, $supplier, $pkg);
        if (empty($metadata)) {
            return false;
        }
        $this->db->beginTransaction();
        $this->db->update('airship_package_cache', ['skyport_metadata' => \json_encode($metadata[0]['metadata'])], ['packagetype' => $type, 'supplier' => $supplier, 'name' => $pkg]);
        return $this->db->commit();
    }

Usage Example

Esempio n. 1
0
 /**
  * @route ajax/admin/skyport/refresh
  */
 public function ajaxRefreshPackageInfo()
 {
     $expected = ['package', 'supplier', 'type'];
     if (!\Airship\all_keys_exist($expected, $_POST)) {
         echo 'Invalid POST request.', "\n";
         return;
     }
     $post = $_POST ?? [];
     $type = '';
     if (isset($post['type'])) {
         switch ($post['type']) {
             case 'cabin':
                 $type = 'Cabin';
                 break;
             case 'gadget':
                 $type = 'Gadget';
                 break;
             case 'motif':
                 $type = 'Motif';
                 break;
             default:
                 echo 'Invalid POST request.', "\n";
                 return;
         }
     }
     $this->skyport->manualRefresh($type, $_POST['supplier'], $_POST['package']);
     $this->lens('skyport/view', ['package' => $this->skyport->getDetails($_POST['type'], $_POST['supplier'], $_POST['package']), 'skyport_url' => $this->skyport->getURL($_POST['type'], $_POST['supplier'], $_POST['package'])]);
 }