本文整理汇总了PHP中entity_selector::set_entity_factory方法的典型用法代码示例。如果您正苦于以下问题:PHP entity_selector::set_entity_factory方法的具体用法?PHP entity_selector::set_entity_factory怎么用?PHP entity_selector::set_entity_factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entity_selector
的用法示例。
在下文中一共展示了entity_selector::set_entity_factory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function sync_with_old_catalog($year)
{
$courses = array();
$es = new entity_selector();
$es->description = 'Selecting courses';
$factory = new CourseTemplateEntityFactory();
$es->set_entity_factory($factory);
$es->add_type(id_of('course_template_type'));
$es->set_order('course_number');
$results = $es->run_one();
connectdb('reg_catalog_new');
foreach ($results as $id => $entity) {
$query = 'SELECT id FROM course' . $year . ' WHERE visible = 1 AND course_id = "' . $entity->get_value('sourced_id') . '"';
if ($result = mysql_query($query)) {
if (mysql_num_rows($result)) {
connectdb(REASON_DB);
create_relationship($this->site_id, $entity->id(), get_borrows_relationship_id(id_of('course_template_type')));
connectdb('reg_catalog_new');
}
}
}
connectdb(REASON_DB);
}
示例2: get_courses_by_sourced_id
/**
* Find courses by their id in the source data
*
* @param array $codes Array of ids
* @param string $catalog_site Optional unique name of a catalog site. If you pass this,
* only courses associated with that site will be included.
*/
function get_courses_by_sourced_id($ids, $catalog_site = null)
{
$courses = array();
if ($catalog_site && ($site_id = id_of($catalog_site))) {
$es = new entity_selector($site_id);
} else {
$es = new entity_selector();
}
$es->description = 'Selecting courses by sourced_id';
$factory = new CourseTemplateEntityFactory();
$es->set_entity_factory($factory);
$es->add_type(id_of('course_template_type'));
$es->add_relation('sourced_id in ("' . join('","', $ids) . '")');
$es->set_order('org_id, course_number');
$results = $es->run_one();
foreach ($results as $id => $entity) {
if (isset($courses[$id])) {
continue;
}
$entity->include_source = 'subjects';
$courses[$id] = $entity;
}
return $courses;
}
示例3: init
/**
* Grabs a list of all publications and events attached to the site, offers them to
*
* The bulk of this form step.
*
*
*/
function init($args = array())
{
parent::init($args);
$site_id = (int) $_REQUEST['site_id'];
// Only do this init if we're on the step that needs it.
if ($this->controller->get_current_step() != 'SelectIncludes') {
return;
}
//////////////// PUBLICATIONS /////////////////
// Select all publications that are attached to this site.
$pub_factory = new PubHelperFactory();
$es = new entity_selector($site_id);
$es->add_type(id_of('publication_type'));
// Add the page_id to which the pub belongs (so we can get url)
$es->add_right_relationship_field('page_to_publication', 'entity', 'id', 'page_id');
$es->enable_multivalue_results();
$es->set_entity_factory($pub_factory);
$pub_helper_entities = $es->run_one();
if ($pub_helper_entities) {
$this->add_element('pub_posts_header1', 'comment', array('text' => '<h2 class="region">Publications</h2>'));
foreach ($pub_helper_entities as $ph) {
$name = $ph->get_value('name');
$entityID = $ph->get_value('id');
$page_id = $ph->get_value('page_id');
if (is_array($page_id)) {
$strlength = 0;
$page_url = '';
foreach ($page_id as $one_id) {
$page_entity = new entity($one_id);
if ($page_entity->get_value('state') == 'Live') {
$owner = $page_entity->get_owner();
if ($owner->get_value('state') == 'Live') {
$url = reason_get_page_url($one_id);
if (strlen($url) > $strlength) {
$strlength = strlen($url);
$page_url = $url;
}
}
}
}
$box_name = '<a target="_blank" href="' . $page_url . '">' . $name . '</a>';
$opts[$entityID] = $box_name;
} else {
$page_entity = new entity($page_id);
if ($page_entity->get_value('state') == 'Live') {
$owner = $page_entity->get_owner();
if ($owner->get_value('state') == 'Live') {
$page_url = reason_get_page_url($page_id);
$box_name = '<a target="_blank" href="' . $page_url . '">' . $name . '</a>';
$opts[$entityID] = $box_name;
}
}
}
}
$this->add_element('selected_publications', 'checkboxgroup', array('options' => $opts));
$this->set_value('selected_publications', array_keys($opts));
$this->set_display_name('selected_publications', 'Select the publications from which you wish to draw posts');
$this->add_element('publication_start_date', 'textDate');
$monthAgo = date("Y-m-d", strtotime("-1 month"));
$today = date("Y-m-d", time());
$this->set_value('publication_start_date', $monthAgo);
$this->set_display_name('publication_start_date', 'From this date');
$this->add_element('publication_end_date', 'textDate');
$this->set_value('publication_end_date', $today);
$this->set_display_name('publication_end_date', 'To this date');
}
//////////////// EVENTS ///////////////////
// !todo: Find any page on the site $site_id which uses the module 'events', and list
// that page title as a 'calendar' (there are apparently no calendar entities,
// only the events module which acts as a calendar.
// The extra information should be found in the page_type def for the page containing
// the events module.
/* $eh = new reasonCalendar();
$site = new entity($site_id);
$cal = new reasonCalendar(array('site'=>$site));
$cal->run();
$events = $cal->get_all_events(); */
$es = new entity_selector($site_id);
$es->add_type(id_of('event_type'));
$es->set_num(1);
$es->limit_tables();
$es->limit_fields();
$events = $es->run_one();
if ($events) {
$this->add_element('events_header1', 'comment', array('text' => '<h2 class="region">Calendars</h2>'));
$this->add_element('events_start_date', 'textDate');
$monthAhead = date("Y-m-d", strtotime("+1 month"));
$today = date("Y-m-d", time());
$this->set_value('events_start_date', $today);
$this->set_display_name('events_start_date', 'From this date');
$this->add_element('events_end_date', 'textDate');
$this->set_value('events_end_date', $monthAhead);
//.........这里部分代码省略.........