本文整理汇总了PHP中Sample::list_required_sub_items方法的典型用法代码示例。如果您正苦于以下问题:PHP Sample::list_required_sub_items方法的具体用法?PHP Sample::list_required_sub_items怎么用?PHP Sample::list_required_sub_items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sample
的用法示例。
在下文中一共展示了Sample::list_required_sub_items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listen_events
/**
* @see EventListenerInterface::listen_events()
* @param object $event_object
* @return bool
*/
public static function listen_events($event_object)
{
global $transaction;
if ($event_object instanceof ItemAddHolderEvent) {
$type = $event_object->get_type();
if ($type == "sample") {
$sample_id = $event_object->get_id();
$item_id = $event_object->get_item_id();
$gid = $event_object->get_gid();
$transaction_id = $transaction->begin();
if (self::create($sample_id, $item_id, $gid, null, null) == false) {
if ($transaction_id != null) {
$transaction->rollback($transaction_id);
}
return false;
} else {
if ($transaction_id != null) {
$transaction->commit($transaction_id);
}
}
}
}
if ($event_object instanceof ItemAddEvent) {
$get_array = $event_object->get_get_array();
$post_array = $event_object->get_post_array();
$item_holder = $event_object->get_item_holder();
$item_holder_name = $event_object->get_item_holder_name();
if ($get_array['nav'] == "sample" and is_numeric($get_array['sample_id']) and !$get_array['parent'] and !$get_array['parent_key']) {
$transaction_id = $transaction->begin();
if ($get_array['parent_sample'] == "1") {
$parent = true;
} else {
$parent = false;
}
if ($item_holder == true and $item_holder_name) {
$item_holder_class = Item::get_holder_handling_class_by_name($item_holder_name);
$item_holder_instance = $item_holder_class::get_instance_by_item_id($event_object->get_item_id());
if (self::$sample_instance_array[$get_array['sample_id']]) {
$sample = self::$sample_instance_array[$get_array['sample_id']];
} else {
$sample = new Sample($get_array['sample_id']);
self::$sample_instance_array[$get_array['sample_id']] = $sample;
}
$required_sub_item_array = $sample->list_required_sub_items($get_array['key']);
if (is_array($required_sub_item_array) and count($required_sub_item_array) >= 1) {
if ($required_sub_item_array[0] == "all") {
$sub_item_array = $item_holder_instance->get_item_holder_items(null);
if (is_array($sub_item_array) and count($sub_item_array)) {
foreach ($sub_item_array as $sub_item_key => $sub_item_value) {
if (self::create($get_array['sample_id'], $sub_item_value, null, null, null, $event_object->get_item_id()) == false) {
if ($transaction_id != null) {
$transaction->rollback($transaction_id);
}
return false;
}
if (DataEntity::is_kind_of("file", $sub_item_value) or DataEntity::is_kind_of("value", $sub_item_value) or DataEntity::is_kind_of("parameter", $sub_item_value)) {
$data_entity_id = DataEntity::get_entry_by_item_id($sub_item_value);
$folder_id = $sample->get_item_holder_value("folder_id");
$parent_data_entity_id = Folder::get_data_entity_id_by_folder_id($folder_id);
$child_data_entity = new DataEntity($data_entity_id);
if ($child_data_entity->set_as_child_of($parent_data_entity_id, true, $parent_item_id) == false) {
return false;
}
}
}
}
} else {
foreach ($required_sub_item_array as $key => $value) {
$sub_item_array = $item_holder_instance->get_item_holder_items($value);
if (is_array($sub_item_array) and count($sub_item_array)) {
foreach ($sub_item_array as $sub_item_key => $sub_item_value) {
if (self::create($get_array['sample_id'], $sub_item_value, null, null, null, $event_object->get_item_id()) == false) {
if ($transaction_id != null) {
$transaction->rollback($transaction_id);
}
return false;
}
if (DataEntity::is_kind_of("file", $sub_item_value) or DataEntity::is_kind_of("value", $sub_item_value) or DataEntity::is_kind_of("parameter", $sub_item_value)) {
$data_entity_id = DataEntity::get_entry_by_item_id($sub_item_value);
$folder_id = $sample->get_item_holder_value("folder_id");
$parent_data_entity_id = Folder::get_data_entity_id_by_folder_id($folder_id);
$child_data_entity = new DataEntity($data_entity_id);
if ($child_data_entity->set_as_child_of($parent_data_entity_id, true, $parent_item_id) == false) {
return false;
}
}
}
}
}
}
}
}
if (self::create($get_array['sample_id'], $event_object->get_item_id(), $get_array['key'], $post_array['keywords'], $post_array['description'], null, $parent) == false) {
if ($transaction_id != null) {
$transaction->rollback($transaction_id);
//.........这里部分代码省略.........