本文整理汇总了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.');
}
}
示例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.');
}
}