eiek.install 2.81 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
<?php

use Drupal\Core\Database\Database;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\field\FieldStorageConfigInterface;
/**
 * Add a new test able
 */
/* 
function eiek_update_8210(&$sandbox) {

 $spec = array(
    'type' => 'varchar',
    'description' => "New Col",
    'length' => 20,
    'not null' => FALSE,
  ); 
 $schema = Database::getConnection()->schema();
 $schema->addField('student_entity', 'iekbek', $spec);

}
*/

/*
  $edum = \Drupal::entityDefinitionUpdateManager();
  $em = \Drupal::entityManager();


  $field_iekbek = BaseFieldDefinition::create('string')
      ->setLabel(t('IEK BEK'))
      ->setDescription(t('The IEK that created the BEK'))
      ->setRevisionable(TRUE)
      ->setSettings(array(
        'max_length' => 30,
        'text_processing' => 0,
      ))
      ->setDefaultValue('')
      ->setDisplayOptions('view', array(
        'label' => 'above',
        'type' => 'string',
        'weight' => -4,
      ))
      ->setDisplayOptions('form', array(
        'type' => 'string_textfield',
        'weight' => -4,
      ))
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);
      $edum->installFieldStorageDefinition('iekbek','student_entity','eiek',$field_iekbek);
    //  $edum->installFieldStorageDefinition($field_iekbek);

//}
/* $spec = array(
    'description' => 'My description',
    'fields' => array(
      'myfield1' => array(
        'description' => 'Myfield1 description.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'myfield2' => array(
        'description' => 'Myfield2 description',
        'type' => 'text',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array('myfield1'),
  ); 
 $schema = Database::getConnection()->schema();
 $schema->createTable('mytable2', $spec);*/
//}


//function eiek_update_8202() {
/*
 $database = \Drupal::database();
  // Retrieve existing field data.
  $entity_type = 'student_entity';
  $field = 'iekbek';



  $field_storage_configs = \Drupal::entityTypeManager()->getStorage('field_storage_config')
    ->loadByProperties([
      'field_name' => $field,
    ]);
  foreach ($field_storage_configs as $field_storage) {
    $new_field_storage = $field_storage->toArray();
    $new_field_storage['settings']['max_length'] = 100;

    $new_field_storage = FieldStorageConfig::create($new_field_storage);
    $new_field_storage->original = $new_field_storage;
    $new_field_storage->enforceIsNew(FALSE);

    $new_field_storage->save();
  }
*/
//}

//function eiek_update_8208() {
  // Update definitions and schema.
 // $manager = \Drupal::entityDefinitionUpdateManager();
  //$storage_definition = $manager->getFieldStorageDefinition('iekbek', 'student_entity');
  
 // $manager->updateFieldStorageDefinition($storage_definition);


//}