/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();
/** * Implements hook_entity_info(). */ function YOUR_MODULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', // Entityクラスの継承 ・・・・・・・・・ ), ); } /** * hook_entity_info()に定義された'entity class' */ class MyVocabularyEntity extends Entity{ // データ更新ロジックのオバーライド public function save() { $this->updated = time() ; // 更新時刻の設定 return parent::save(); } }
// empty($primary_keys) ? db_insert() : db_update() function drupal_write_record($table, &$record, $primary_keys = array())
/** * Implements hook_entity_info(). */ function YOUR_MOUDULE_NAME_entity_info() { return array( 'my_vocabulary' => array( 'label' => t('My Vocabulary'), 'entity class' => 'MyVocabularyEntity', 'label callback' => 'entity_class_label', // see MyVocabularyEntity class 'uri callback' => 'entity_class_uri', // see MyVocabularyEntity class 'controller class' => 'MyVocabulryController', 'base table' => 'my_vocabulary', 'fieldable' => TRUE, 'entity keys' => array( 'id' => 'entity_id', 'label' => 'vocabulary', ), 'bundles' => array( 'my_vocabulary' => array( 'label'=>'My Vocabulary', 'admin' => array( 'path' => 'admin/structure/my-vocabulary/manage', 'access arguments' => array('administer my vocabulary'), 'controller class' => 'EntityDefaultUIController', ), ), ), 'view modes' => array( 'full' => array( 'label' => t('Default'), 'custom settings' => FALSE, ), ), 'module' => 'my_vocabulary', 'access arguments' => array('administer my vocabulary'), ), ); }
/** * Implements hook_menu(). */ function YOUR_MODULE_NAME_menu() { // for my my vocabulary entity $items['my-vocabularies/add'] = array( 'title' => t('Add Vocabulary'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form') , 'access arguments' => array('update my vocabulary'), ); $items['my-vocabularies/%my_vocabulary'] = array( 'title' => 'My Vocabulary', 'page callback' => 'my_vocabulary_page_view', 'page arguments' => array(2) , 'access arguments' => array('view my vocabulary'), ); $items['my-vocabularies/%my_vocabulary/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, //メニュータブの作成 ); $items['my-vocabularies/%my_vocabulary/edit'] = array( 'title' => t('Edit'), 'page callback' => 'drupal_get_form', 'page arguments' => array('my_vocabulary_form', 2) , 'access arguments' => array('edit my vocabulary'), 'type' => MENU_LOCAL_TASK, ); return $items; }
/** * vocabulary submit handler. */ function vocabulary_form_submit($form, &$form_state) { // データ入力フォームで埋め込んだエンティティを取得 $vocabulary = $form_state['my_vocabulary']; // 新規作成の場合、$vocabularyオブジェクトがない if( $vocabulary == null ) $vocabulary= entity_create( "my_vocabulary", array() ); // 入力フォームの値を$vocabularyにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); entity_save( 'my_vocabulary', $vocabulary ); // エンティティの内容の詳細が画面に遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary); // 新規作成の場合にエラー発生 $form_state['redirect'] = $vocabulary_uri['path']; }
class MyVocabularyEntity extends Entity{ // 'label callback' => 'entity_class_label' protected function defaultLabel() { return $this->vocabulary; // vocabulary名を返す } // 'uri callback' => 'entity_class_uri', protected function defaultUri() { return array("path"=>"chinese/vocabularies/".$this->vid); // vocabulary表示URLを返す } }
/** * vocabulary submit handler. */ function my_vocabulary_form_submit($form, &$form_state) { $vocabulary = $form_state['my_vocabulary']; if( $vocabulary == null ) $vocabulary = entity_create('my_vocabulary',array()); // エンティティ入力フォームの値をエンティティにセット entity_form_submit_build_entity('my_vocabulary', $vocabulary, $form, $form_state); // Entity Metadata Wrapper の使用 $entity = entity_metadata_wrapper('my_vocabulary', $vocabulary); $entity->save(); // 新規作成したエンティティIDをエンティティオブジェクトにセット $vocabulary->entity_id = $entity->getIdentifier() ; // エンティティの詳細画面のURIを取得、遷移 $vocabulary_uri = entity_uri('my_vocabulary', $vocabulary ); $form_state['redirect'] = $vocabulary_uri['path']; }
// Unified way of getting $node->title, $user->name, ... // wrapper->label_name ではエラーになります $wrapper->label(); // Unified way of getting $node->nid, $user->uid, ... // wrapper->id ではエラーになる $wrapper->getIdentifier();