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


PHP Agent::find_or_create方法代码示例

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


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

示例1: insert_agents

 public function insert_agents($row, $parameters)
 {
     self::debug_iterations("Inserting agent");
     if ($this->archive_validator->has_error_by_line('http://eol.org/schema/agent/agent', $parameters['archive_table_definition']->location, $parameters['archive_line_number'])) {
         write_to_resource_harvesting_log("ERROR: insert_agents: has_error_by_line" . ",file_location:" . $parameters['archive_table_definition']->location . ",line_number:" . $parameters['archive_line_number']);
         return false;
     }
     $agent_id = @self::field_decode($row['http://purl.org/dc/terms/identifier']);
     // we really only need to insert the agents that relate to media
     if (!isset($this->media_agent_ids[$agent_id])) {
         return;
     }
     $params = array("full_name" => @self::field_decode($row['http://xmlns.com/foaf/spec/#term_name']), "given_name" => @self::field_decode($row['http://xmlns.com/foaf/spec/#term_firstName']), "family_name" => @self::field_decode($row['http://xmlns.com/foaf/spec/#term_familyName']), "email" => @self::field_decode($row['http://xmlns.com/foaf/spec/#term_mbox']), "homepage" => @self::field_decode($row['http://xmlns.com/foaf/spec/#term_homepage']), "logo_url" => @self::field_decode($row['http://xmlns.com/foaf/spec/#term_logo']), "project" => @self::field_decode($row['http://xmlns.com/foaf/spec/#term_currentProject']), "organization" => @self::field_decode($row['http://eol.org/schema/agent/organization']), "account_name" => @self::field_decode($row['http://xmlns.com/foaf/spec/#term_accountName']), "openid" => @self::field_decode($row['http://xmlns.com/foaf/spec/#term_openid']));
     // find or create this agent
     $agent = Agent::find_or_create($params);
     if (!$agent) {
         return;
     }
     // download the logo if there is one, and it hasn't ever been downloaded before
     if ($agent->logo_url && !$agent->logo_cache_url) {
         if ($logo_cache_url = $this->content_manager->grab_file($agent->logo_url, "partner")) {
             $agent->logo_cache_url = $logo_cache_url;
             $agent->save();
         }
     }
     $agent_role = AgentRole::find_or_create_by_translated_label(@self::field_decode($row['http://eol.org/schema/agent/agentRole']));
     $agent_role_id = @$agent_role->id ?: 0;
     foreach ($this->media_agent_ids[$agent_id] as $data_object_id => $val) {
         # TODO: intelligently delete agents for objects ONLY ONCE during an import
         # TODO: figure out view order
         $this->mysqli->insert("INSERT IGNORE INTO agents_data_objects VALUES ({$data_object_id}, {$agent->id}, {$agent_role_id}, 0)");
     }
 }
开发者ID:eliagbayani,项目名称:maps_test,代码行数:33,代码来源:ArchiveDataIngester.php

示例2: add_translated_data_object

 static function add_translated_data_object($options, $resource)
 {
     $d = $options[0];
     $parameters = $options[1];
     if ($d->EOLDataObjectID) {
         if ($existing_data_object = DataObject::find($d->EOLDataObjectID)) {
             $new_data_object = clone $existing_data_object;
             $new_data_object->id = NULL;
             $new_data_object->identifier = $d->identifier;
             $new_data_object->object_created_at = $d->object_created_at;
             $new_data_object->object_modified_at = $d->object_modified_at;
             $new_data_object->object_title = $d->object_title;
             $new_data_object->language = $d->language;
             $new_data_object->rights_statement = $d->rights_statement;
             $new_data_object->rights_holder = $d->rights_holder;
             $new_data_object->description = $d->description;
             $new_data_object->description_linked = null;
             $new_data_object->location = $d->location;
             // check to see if this translation exists by looking in data_object_translations
             // if its found, check to see if its different
             // otherwise add it, then add all associations (agents, references, hierarchy_entries)
             // then add new agents
             $content_manager = new ContentManager();
             list($data_object, $status) = DataObject::find_and_compare($resource, $new_data_object, $content_manager);
             if (@(!$data_object->id)) {
                 return false;
             }
             self::add_entries_for_translated_object($existing_data_object, $data_object, $resource);
             $resource->harvest_event->add_data_object($data_object, $status);
             if ($status != "Reused") {
                 $i = 0;
                 $data_object->delete_agents();
                 foreach ($parameters['agents'] as &$a) {
                     $agent = Agent::find_or_create($a);
                     if ($agent->logo_url && !$agent->logo_cache_url) {
                         if ($logo_cache_url = $this->content_manager->grab_file($agent->logo_url, "partner")) {
                             $agent->logo_cache_url = $logo_cache_url;
                             $agent->save();
                         }
                     }
                     $data_object->add_agent($agent->id, @$a['agent_role']->id ?: 0, $i);
                     unset($a);
                     $i++;
                 }
                 $data_object->delete_translations();
                 $data_object->add_translation($existing_data_object->id, $data_object->language_id);
                 $data_object->delete_info_items();
                 foreach ($existing_data_object->info_items as $ii) {
                     $data_object->add_info_item($ii->id);
                 }
                 // audience
                 // info items
                 // table of contents
                 // all related tables....
             }
         } else {
             echo "DataObject {$d->EOLDataObjectID} doesn't exist\n";
         }
     } else {
         return false;
     }
 }
开发者ID:eliagbayani,项目名称:maps_test,代码行数:62,代码来源:SchemaConnection.php


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