当前位置: 首页>>代码示例>>PHP>>正文


PHP Package::create方法代码示例

本文整理汇总了PHP中Package::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::create方法的具体用法?PHP Package::create怎么用?PHP Package::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Package的用法示例。


在下文中一共展示了Package::create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGeneratesXml

 public function testGeneratesXml()
 {
     $package = Package::create(self::$name)->setAuthor('VikiJel')->addExtension('com_test', self::$archive_src)->addLanguage(self::$ini_src)->addUpdateServer('http://example.com', 'testserver')->setScriptfile(self::$php_src);
     $instance = Xml::create($package)->init();
     $simple_xml = simplexml_load_string((string) $instance);
     self::assertEquals('extension', (string) $simple_xml->getName());
     self::assertEquals('2.5', (string) $simple_xml->attributes()->version);
     self::assertEquals('upgrade', (string) $simple_xml->attributes()->method);
     self::assertEquals('package', (string) $simple_xml->attributes()->type);
     self::assertEquals('1.0.0', (string) $simple_xml->version);
     self::assertEquals(self::$name, (string) $simple_xml->name);
     self::assertEquals('package_test', (string) $simple_xml->packagename);
     self::assertEquals(date('Y-m-d'), (string) $simple_xml->creationDate);
     self::assertEquals('http://example.com', (string) $simple_xml->updateservers->server);
     self::assertEquals('testserver', (string) $simple_xml->updateservers->server->attributes()->name);
     self::assertEquals(1, (int) $simple_xml->updateservers->server->attributes()->priority);
     self::assertEquals('extension', (string) $simple_xml->updateservers->server->attributes()->type);
     self::assertEquals('com_test', (string) $simple_xml->files->file->attributes()->id);
     self::assertEquals('some_file.zip', (string) $simple_xml->files->file);
     self::assertEquals('en-GB.pkg_package_test.ini', (string) $simple_xml->languages->language);
     self::assertEquals('en-GB', (string) $simple_xml->languages->language->attributes()->tag);
     self::assertEquals('pkg_package_test.php', (string) $simple_xml->scriptfile);
     self::assertContains('VikiJel', (string) $simple_xml->copyright);
     self::assertContains(date('Y'), (string) $simple_xml->copyright);
     self::assertContains('VikiJel', (string) $simple_xml->packager);
     self::assertContains('vikijel', (string) $simple_xml->packagerurl);
 }
开发者ID:vikijel,项目名称:joomla-extensions-packager,代码行数:27,代码来源:XmlTest.php

示例2: getId

 /**
  * Get the package ID by package name
  * @param string $packageName
  * @return int
  */
 public static function getId($packageName)
 {
     if (($package = static::fetchOne('name', $packageName)) === false) {
         $package = Package::create(array('name' => $packageName));
     }
     return $package->id;
 }
开发者ID:nkammah,项目名称:Crash-Analytics,代码行数:12,代码来源:Package.php

示例3: run

 public function run()
 {
     Package::truncate();
     $packages = [["name" => "Premium Month", "cost" => 9, "renew" => "1 month", "type" => "membership", "value" => "premium", "active" => "premium month", "trial" => "none"], ["name" => "Platinum Month", "cost" => 17, "renew" => "1 month", "type" => "membership", "value" => "platinum", "active" => "platinum month", "trial" => "none"], ["name" => "Premium Annual", "cost" => 90, "renew" => "1 year", "type" => "membership", "value" => "premium", "active" => "premium annual", "trial" => "none"], ["name" => "Platinum Annual", "cost" => 170, "renew" => "1 year", "type" => "membership", "value" => "platinum", "active" => "platinum annual", "trial" => "none"], ["name" => "1,000 Credits", "cost" => 5, "renew" => "none", "type" => "credit", "value" => "1000", "active" => "true", "trial" => "none"], ["name" => "2,500 Credits", "cost" => 10, "renew" => "none", "type" => "credit", "value" => "2500", "active" => "true", "trial" => "none"], ["name" => "5,000 Credits", "cost" => 15, "renew" => "none", "type" => "credit", "value" => "5000", "active" => "true", "trial" => "none"], ["name" => "10,000 Credits", "cost" => 20, "renew" => "none", "type" => "credit", "value" => "10000", "active" => "true", "trial" => "none"]];
     foreach ($packages as $package) {
         Package::create($package);
     }
 }
开发者ID:danielheyman,项目名称:TechDimeProjects,代码行数:8,代码来源:PackageSeeder.php

示例4: load

 /**
  * Loads a package and its products.
  *
  * @param int $package_id
  *   The package ID.
  *
  * @return \Drupal\uc_fulfillment\Package|null
  *   The Package object, or NULL if there isn't one with the given ID.
  */
 public static function load($package_id)
 {
     if (!isset(self::$packages[$package_id])) {
         $result = db_query('SELECT * FROM {uc_packages} WHERE package_id = :id', [':id' => $package_id]);
         if ($assoc = $result->fetchAssoc()) {
             $package = Package::create($assoc);
             $products = array();
             $description = '';
             $weight = 0;
             $units = \Drupal::config('uc_store.settings')->get('weight.units');
             $addresses = array();
             $result = db_query('SELECT op.order_product_id, pp.qty, pp.qty * op.weight__value AS weight, op.weight__units, op.nid, op.title, op.model, op.price, op.data FROM {uc_packaged_products} pp LEFT JOIN {uc_order_products} op ON op.order_product_id = pp.order_product_id WHERE pp.package_id = :id ORDER BY op.order_product_id', [':id' => $package->package_id]);
             foreach ($result as $product) {
                 $address = uc_quote_get_default_shipping_address($product->nid);
                 // TODO: Lodge complaint that array_unique() compares as strings.
                 if (!in_array($address, $addresses)) {
                     $addresses[] = $address;
                 }
                 $description .= ', ' . $product->qty . ' x ' . $product->model;
                 // Normalize all weights to default units.
                 $weight += $product->weight * uc_weight_conversion($product->weight__units, $units);
                 $product->data = unserialize($product->data);
                 $products[$product->order_product_id] = $product;
             }
             $package->addresses = $addresses;
             $package->description = substr($description, 2);
             $package->weight = $weight;
             $package->weight_units = $units;
             $package->products = $products;
             if ($package->label_image && ($image = file_load($package->label_image))) {
                 $package->label_image = $image;
             }
             self::$packages[$package_id] = $package;
             return $package;
         } else {
             return NULL;
         }
     }
     // Return package from cache.
     return self::$packages[$package_id];
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:50,代码来源:Package.php

示例5: run

 public function run()
 {
     Eloquent::unguard();
     Package::create(array('package_name' => 'Package 1', 'package_price' => '135', 'package_time' => '8', 'package_description' => 'This is the first package and a description of it'));
     Package::create(array('package_name' => 'Package 2', 'package_price' => '175', 'package_time' => '2', 'package_description' => 'This is the second package and a description of it'));
 }
开发者ID:RetinaInc,项目名称:booking-app,代码行数:6,代码来源:PackageTableSeeder.php

示例6: NotFoundError

 if ($user === NULL or !$user->isadmin and $settings["repo_mode"] == "private") {
     throw new NotFoundError();
 }
 $url_now = array();
 $ste->vars["menu"] = "upload";
 $ste->vars["title"] = "Upload new package";
 if (isset($_POST["upload_package"])) {
     if (is_uploaded_file($_FILES["pkgfile"]["tmp_name"])) {
         $raw_pkg = @file_get_contents($_FILES["pkgfile"]["tmp_name"]);
         @unlink($_FILES["pkgfile"]["tmp_name"]);
         if ($raw_pkg === False) {
             $ste->vars["error"] = "Upload failed.";
         } else {
             try {
                 $newpkg = PluginPackage::load($raw_pkg);
                 $pkg = Package::create($newpkg->name, $user);
                 $pkg->newversion($newpkg);
                 $ste->vars["success"] = "Successfully uploaded new package.";
                 $url_next = array("p", $newpkg->name);
                 return;
             } catch (InvalidPackage $e) {
                 $ste->vars["error"] = "Invalid package. Reason: " . $e->getMessage();
             } catch (NotAllowedError $e) {
                 $ste->vars["error"] = "This is not allowed. Reason: " . $e->getMessage();
             } catch (InvalidArgumentException $e) {
                 $ste->vars["error"] = $e->getMessage();
             } catch (AlreadyExistsError $e) {
                 $ste->vars["error"] = "A package with this name already exists.";
             }
         }
     } else {
开发者ID:ratatoeskr-cms,项目名称:r7r-repo,代码行数:31,代码来源:main.php


注:本文中的Package::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。