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


PHP License::truncate方法代码示例

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


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

示例1: seedLicenses

 /**
  * Seed the licenses
  *
  * @return void
  */
 private function seedLicenses()
 {
     // Fetch the licenses from the json file
     $this->command->info('---- DCAT Licenses ----');
     $this->command->info('Trying to fetch the licenses from a local json file.');
     $licenses = json_decode(file_get_contents(app_path() . '/database/seeds/data/licenses.json'));
     if (!empty($licenses)) {
         $this->command->info('Licenses have been found, deleting the current ones, and replacing them with the new ones.');
         // Empty the licenses table
         $this->command->info('Emptying the current licenses table.');
         \License::truncate();
         foreach ($licenses as $license) {
             \License::create(array('domain_content' => $license->domain_content, 'domain_data' => $license->domain_data, 'domain_software' => $license->domain_software, 'family' => $license->family, 'license_id' => $license->license_id, 'is_generic' => @$license->is_generic, 'is_okd_compliant' => $license->is_okd_compliant, 'is_osi_compliant' => $license->is_osi_compliant, 'maintainer' => $license->maintainer, 'status' => $license->status, 'title' => $license->title, 'url' => $license->url));
         }
         $this->command->info('Added the licenses from a local json file.');
     } else {
         $this->command->info('The licenses from the json file were empty, the old ones will not be replaced.');
     }
 }
开发者ID:netsensei,项目名称:core,代码行数:24,代码来源:DcatSeeder.php

示例2: seedLicenses

 /**
  * Seed the themes
  *
  * @return @void
  */
 private function seedLicenses()
 {
     $this->info('---- Seeding new licenses ----');
     $license_name = $this->argument('name');
     $license_uri = $this->licenses_uri . $license_name;
     if (substr($license_uri, -5) != '.json') {
         $license_uri .= '.json';
     }
     // Try to get the themes from the ns.thedatatank.com (semantic data)
     try {
         $this->info('Trying to fetch triples from the uri: ' . $license_uri);
         try {
             $licenses_graph = \EasyRdf_Graph::newAndLoad($license_uri, 'jsonld');
         } catch (\EasyRdf_Http_Exception $ex) {
             $this->info('We could not fetch licenses from the URL ' . $license_uri . ', defaulting to ' . $this->DEFAULT_LICENSE . '.');
             $licenses_graph = $this->fetchDefaultGraph();
         }
         if ($licenses_graph->isEmpty()) {
             $this->info('We could not fetch licenses from the URL ' . $license_uri . ', defaulting to ' . $this->DEFAULT_LICENSE . '.');
             $licenses_graph = $this->fetchDefaultGraph();
         } else {
             $this->info('Fetched new licenses, removing the old ones.');
             // Empty the licenses table
             \License::truncate();
         }
         // Fetch the resources with a skos:conceptScheme relationship
         $licenses = $licenses_graph->allOfType('cc:License');
         $taxonomy_uris = array();
         foreach ($licenses as $license) {
             $url = '';
             $title = '';
             $identifier = '';
             $title_resource = $license->getLiteral('dc:title');
             $identifier_resource = $license->getLiteral('dc:identifier');
             if (!empty($title_resource)) {
                 $title = $title_resource->getValue();
             }
             if (!empty($identifier_resource)) {
                 $identifier = $identifier_resource->getValue();
             }
             if (!$license->isBNode()) {
                 $url = $license->getUri();
             }
             \License::create(['url' => $url, 'title' => $title, 'license_id' => $identifier]);
             $this->info('Added license "' . $identifier . '" with title "' . $title . '" and URI ' . $url);
         }
     } catch (EasyRdf_Exception $ex) {
         $this->info('An error occurred when we tried to fetch online themes.');
     }
 }
开发者ID:jalbertbowden,项目名称:core,代码行数:55,代码来源:DcatLicenses.php


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