/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $room_info['room'] = array( 'label' => t('Room'), 'entity class' => 'Entity', 'controller class' => 'DrupalDefaultEntityController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'label' => 'room_number', 'bundle' => 'room_type', // DB上にroom_typeフィールドでバンドルを区別 ), 'bundles' => array( 'single_room'=> array( 'label' => 'Single Room', 'admin' => array( 'path' => 'admin/structure/single-room/manage', ), ), 'twin_room'=> array( 'label' => 'Twin Room', 'admin' => array( 'path' => 'admin/structure/twin-room/manage', ), ), ), 'access callback' => 'access_room', 'module' => 'entity_room', ); return $room_info; }
/** * Implements hook_field_extra_fields(). * Field管理にRoomのプロパティ項目を追加(編集不可) */ function entity_room_field_extra_fields() { $return = array(); // For Single Room Bundle $return['room']['single_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); // For Twin Room Bundle $return['room']['twin_room'] = array( 'form' => array( 'room_type' => array( 'label' => t('Room Type'), 'description' => t('The type of the room'), 'weight' => 1, ), 'room_number' => array( 'label' => t('Room Number'), 'description' => t('The number of the room'), 'weight' => 2, ), ), ); return $return; }
/** * Implements hook_menu(). */ function entity_room_menu() { // シングル ルーム 管理画面 $items['admin/structure/single-room/manage'] = array( 'title' => t('Single Room Admin'), 'description' => 'Manage Single Room structure', 'page callback' => 'room_info', 'page arguments' => array('Single Room') , 'access arguments' => array('administer rooms'), ); $items['single-room/add'] = array( 'title' => t('Add Single Room'), 'page callback' => 'room_add', 'page arguments' => array('single_room'), 'access arguments' => array('create room'), ); // ツインルーム管理が画面 $items['admin/structure/twin-room/manage'] = array( 'title' => 'Twin Room Admin', 'description' => 'Manage Twin Room structure', 'page callback' => 'room_info' , 'page arguments' => array('Twin Room'), 'access arguments' => array('administer rooms'), ); $items['twin-room/add'] = array( 'title' => t('Add Twin Room'), 'page callback' => 'room_add', 'page arguments' => array('twin_room'), 'access arguments' => array('create room'), ); // Roomの表示 $items['room/%room'] = array( 'title callback' => 'room_page_title', 'title arguments' => array(1), 'page callback' => 'room_page_view', 'page arguments' => array(1), 'access arguments' => array('view rooms'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function entity_room_permission() { return array( 'administer rooms' => array( 'title' => t('Administer rooms'), 'restrict access' => TRUE, ), 'create room' => array( 'title' => t('Create room'), ), 'view rooms' => array( 'title' => t('View Rooms'), ) ); } /** * 全員にRoomエンティティの無条件アクセス権限 */ function access_room(){ return true ; } /** * create "add room" form */ function room_add($type) { $room = (object) array ( 'rid' => '', 'room_type' => $type, 'room_number' => '', ); return drupal_get_form('room_add_form', $room); } function room_add_form($form, &$form_state, $room) { $form['room_type'] = array( '#type' => 'textfield', '#title' => t('Room Type'), '#default_value' => $room->room_type, '#disabled' => true, '#required' => TRUE, ); $form['room_number'] = array( '#type' => 'textfield', '#title' => t('Room Number'), '#required' => TRUE, ); field_attach_form('room', $room, $form, $form_state); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 10, ); return $form; } function room_add_form_validate($form, &$form_state) { $room_submisttion = (object) $form_state['values']; field_attach_form_validate($form_state['values']['room_type'], $room_submisttion, $form, $form_state); } function room_add_form_submit($form, &$form_state) { $room_submission = (object) $form_state['values']; field_attach_submit($form_state['values']['room_type'], $room_submission, $form, $form_state); $room = room_save($room_submission); $form_state['redirect'] = "room/$room->rid"; } function room_save(&$room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } function room_info($type) { return t('Welcome to the administration page for your '.$type.'!'); } function room_page_title($room){ return $room->room_number."(".$room->room_type.")"; } function room_page_view($room, $view_mode = 'full'){ $room->content = array(); // Build fields content. field_attach_prepare_view('room', array($room->rid => $room), $view_mode); entity_prepare_view('room', array($room->rid => $room)); $room->content += field_attach_view('room', $room, $view_mode); return $room->content; } function room_uri( $room ){ return array( 'path' => 'room/'.$room->rid , ); } class RoomController extends EntityAPIController{ //class RoomController extends DrupalDefaultEntityController{ public function __construct($entityType) { parent::__construct($entityType); } // Entityオブジェクト保存 public function save($room) { drupal_write_record('room', $room); field_attach_insert('room', $room); return $room; } } /** * hook_menuのURL引数のオブジェクト取得 */ function room_load($rid = NULL, $reset = FALSE){ $rids = (isset ($rid) ? array($rid) : array()); $room = room_load_multiple($rids, $reset); return $room ? reset ($room) : FALSE; } function room_load_multiple($rids = array(), $conditions = array(), $reset = FALSE){ return entity_load('room', $rids, $conditions, $reset); }
添付 | サイズ |
---|---|
entity_room.zip (2.84 KB) | 2.84 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
添付 | サイズ |
---|---|
entity_room.zip (5.08 KB) | 5.08 KB |
function room_view($room, $view_mode="full") { drupal_set_title(entity_label('room', $room)); return entity_view('room', array(entity_id('room', $room) => $room), $view_mode); }
/** * Implements hook_entity_info(). */ function entity_room_entity_info() { $return = array( 'room' => array( 'label' => t('Room'), 'entity class' => 'RoomEntity', 'label callback' => 'entity_class_label', // see RoomEntity class 'uri callback' => 'entity_class_uri', // see RoomEntity class 'controller class' => 'RoomController', 'base table' => 'room', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'rid', 'bundle' => 'room_type_sys', ), 'bundle keys' => array( 'bundle' => 'room_type_sys', ), 'bundles' => array(), 'load hook' => 'room_load', 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'entity_room', 'access callback' => 'entity_room_access', 'extra fields controller class' => 'EntityDefaultExtraFieldsController', 'metadata controller class' => 'RoomEntityMetadataController', ), ); $return['room_type'] = array( 'label' => t('Room Type'), 'entity class' => 'RoomTypeEntity', 'controller class' => 'RoomTypeController', 'base table' => 'room_type', 'fieldable' => FALSE, 'bundle of' => 'room', 'exportable' => TRUE, 'entity keys' => array( 'id' => 'rtid', 'name' => 'room_type_sys', 'label' => 'room_type_label', ), 'module' => 'entity_room', 'admin ui' => array( // Enable the entity API's admin UI. 'path' => 'admin/structure/room-types', 'file' => 'room_type.admin.inc', 'controller class' => 'RoomTypeUIController', ), 'access callback' => 'entity_room_access', ); return $return; }
class RoomEntityMetadataController extends EntityDefaultMetadataController { public function entityPropertyInfo() { $info = parent::entityPropertyInfo(); $info[$this->type]['properties']['rid']=array( 'label' => t('Room ID'), 'type' => 'integer', 'description' => t('Room Entity ID'), 'schema field' => 'rid', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_type_sys']=array( 'label' => t('Room Type Name'), 'type' => 'text', 'description' => t('Room Type Machine Name'), 'schema field' => 'room_type_sys', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_label']=array( 'label' => t('Room Name'), 'type' => 'text', 'description' => t('Room Name'), 'schema field' => 'room_label', 'setter callback' => 'entity_property_verbatim_set', ); $info[$this->type]['properties']['room_area']=array( 'label' => t('Room Area'), 'type' => 'text', 'description' => t('Room Area Name'), 'schema field' => 'room_area', 'setter callback' => 'entity_property_verbatim_set', ); return $info; } }
添付 | サイズ |
---|---|
entity_room.zip (6.47 KB) | 6.47 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |
/** * 追加されたバンドル(RoomType)に拡張フィールド操作URIの追加 * Implements hook_entity_info_alter(). */ function entity_room_entity_info_alter(&$entity_info) { foreach (room_types() as $type => $info) { $entity_info['room']['bundles'][$type] = array( 'label' => $info->room_type_label, 'admin' => array( 'path' => 'admin/structure/room-types/manage/%room_type', 'real path' => 'admin/structure/room-types/manage/' . $type, 'bundle argument' => 4, ), ); } } // room_type_sys でデータの取得 // room_type入力がなければ、全部のRoomTypeを返す function room_type_load($room_type=null){ return room_types( $room_type ) ; } function room_types( $room_type = null ){ $types = entity_load_multiple_by_name( 'room_type', isset($room_type) ? array($room_type) : false ) ; return isset( $room_type ) ? reset($types) : $types ; }
添付 | サイズ |
---|---|
custom_table_2.zip (1.67 KB) | 1.67 KB |