Skip to content

Instantly share code, notes, and snippets.

@jmolivas
Created January 29, 2013 08:25
Show Gist options
  • Save jmolivas/4662678 to your computer and use it in GitHub Desktop.
Save jmolivas/4662678 to your computer and use it in GitHub Desktop.
drupal computed field entity export
$data = array(
'bundles' => array(
'article' => (object) array(
'type' => 'article',
'name' => 'Article',
'base' => 'node_content',
'module' => 'node',
'description' => 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.',
'help' => '',
'has_title' => '1',
'title_label' => 'Title',
'custom' => '1',
'modified' => '1',
'locked' => '0',
'disabled' => '0',
'orig_type' => 'article',
'disabled_changed' => FALSE,
'bc_entity_type' => 'node',
),
),
'fields' => array(
'body' => array(
'entity_types' => array(
0 => 'node',
),
'translatable' => '0',
'settings' => array(),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_body' => array(
'value' => 'body_value',
'summary' => 'body_summary',
'format' => 'body_format',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_body' => array(
'value' => 'body_value',
'summary' => 'body_summary',
'format' => 'body_format',
),
),
),
),
),
'foreign keys' => array(
'format' => array(
'table' => 'filter_format',
'columns' => array(
'format' => 'format',
),
),
),
'indexes' => array(
'format' => array(
0 => 'format',
),
),
'field_name' => 'body',
'type' => 'text_with_summary',
'module' => 'text',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'summary' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'format' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
0 => 'page',
1 => 'article',
2 => 'video',
3 => 'gallery',
),
),
),
'field_category_1' => array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'allowed_values' => array(
1 => 'Uno',
2 => 'Dos',
3 => 'Tres',
),
'allowed_values_function' => '',
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_field_category_1' => array(
'value' => 'field_category_1_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_field_category_1' => array(
'value' => 'field_category_1_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
0 => 'value',
),
),
'field_name' => 'field_category_1',
'type' => 'list_integer',
'module' => 'list',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
0 => 'article',
),
),
),
'field_category_2' => array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'allowed_values' => array(
1 => 'Uno',
2 => 'Dos',
3 => 'Tres',
),
'allowed_values_function' => '',
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_field_category_2' => array(
'value' => 'field_category_2_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_field_category_2' => array(
'value' => 'field_category_2_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
0 => 'value',
),
),
'field_name' => 'field_category_2',
'type' => 'list_integer',
'module' => 'list',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
0 => 'article',
),
),
),
'field_computed' => array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'code' => '$entity_field[0][\'value\'] = $entity->field_category_1[$langcode][0][\'value\'] + $entity->field_category_2[$langcode][0][\'value\'];',
'display_format' => '$display_output = $entity_field_item[\'value\'];',
'store' => 1,
'database' => array(
'data_type' => 'int',
'data_length' => '32',
'data_size' => 'normal',
'data_precision' => '10',
'data_scale' => '2',
'data_default' => '',
'data_not_NULL' => 1,
'data_index' => 1,
),
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_field_computed' => array(
'value' => 'field_computed_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_field_computed' => array(
'value' => 'field_computed_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
0 => 'value',
),
),
'field_name' => 'field_computed',
'type' => 'computed',
'module' => 'computed_field',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'size' => 'normal',
'not null' => 1,
),
),
'bundles' => array(
'node' => array(
0 => 'article',
),
),
),
'field_image' => array(
'indexes' => array(
'fid' => array(
0 => 'fid',
),
),
'settings' => array(
'uri_scheme' => 'public',
'default_image' => 0,
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_field_image' => array(
'fid' => 'field_image_fid',
'alt' => 'field_image_alt',
'title' => 'field_image_title',
'width' => 'field_image_width',
'height' => 'field_image_height',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_field_image' => array(
'fid' => 'field_image_fid',
'alt' => 'field_image_alt',
'title' => 'field_image_title',
'width' => 'field_image_width',
'height' => 'field_image_height',
),
),
),
),
),
'entity_types' => array(),
'translatable' => '0',
'foreign keys' => array(
'fid' => array(
'table' => 'file_managed',
'columns' => array(
'fid' => 'fid',
),
),
),
'field_name' => 'field_image',
'type' => 'image',
'module' => 'image',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'fid' => array(
'description' => 'The {file_managed}.fid being referenced in this field.',
'type' => 'int',
'not null' => FALSE,
'unsigned' => TRUE,
),
'alt' => array(
'description' => 'Alternative image text, for the image\'s \'alt\' attribute.',
'type' => 'varchar',
'length' => 512,
'not null' => FALSE,
),
'title' => array(
'description' => 'Image title text, for the image\'s \'title\' attribute.',
'type' => 'varchar',
'length' => 1024,
'not null' => FALSE,
),
'width' => array(
'description' => 'The width of the image in pixels.',
'type' => 'int',
'unsigned' => TRUE,
),
'height' => array(
'description' => 'The height of the image in pixels.',
'type' => 'int',
'unsigned' => TRUE,
),
),
'bundles' => array(
'node' => array(
0 => 'article',
),
),
),
),
'instances' => array(
'body' => array(
0 => array(
'label' => 'Body',
'widget' => array(
'type' => 'text_textarea_with_summary',
'settings' => array(
'rows' => 20,
'summary_rows' => 5,
),
'weight' => '4',
'module' => 'text',
),
'settings' => array(
'display_summary' => TRUE,
'text_processing' => 1,
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'hidden',
'type' => 'text_default',
'weight' => '0',
'settings' => array(),
'module' => 'text',
),
'teaser' => array(
'label' => 'hidden',
'type' => 'text_summary_or_trimmed',
'weight' => '2',
'settings' => array(
'trim_length' => '300',
),
'module' => 'text',
),
'full' => array(
'label' => 'hidden',
'type' => 'text_default',
'weight' => '1',
'settings' => array(),
'module' => 'text',
),
),
'required' => FALSE,
'description' => '',
'field_name' => 'body',
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
'default_value' => NULL,
),
),
'field_category_1' => array(
0 => array(
'label' => 'Category 1',
'widget' => array(
'weight' => '6',
'type' => 'options_select',
'module' => 'options',
'active' => 1,
'settings' => array(),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'list_default',
'settings' => array(),
'module' => 'list',
'weight' => 13,
),
'full' => array(
'label' => 'above',
'type' => 'hidden',
'weight' => '7',
'settings' => array(),
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 1,
'description' => '',
'default_value' => NULL,
'field_name' => 'field_category_1',
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
),
),
'field_category_2' => array(
0 => array(
'label' => 'Category 2',
'widget' => array(
'weight' => '7',
'type' => 'options_select',
'module' => 'options',
'active' => 1,
'settings' => array(),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'list_default',
'settings' => array(),
'module' => 'list',
'weight' => 14,
),
'full' => array(
'label' => 'above',
'type' => 'hidden',
'weight' => '6',
'settings' => array(),
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 1,
'description' => '',
'default_value' => NULL,
'field_name' => 'field_category_2',
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
),
),
'field_computed' => array(
0 => array(
'label' => 'Computed',
'widget' => array(
'weight' => '8',
'type' => 'computed',
'module' => 'computed_field',
'active' => 0,
'settings' => array(),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'computed_field_plain',
'settings' => array(),
'module' => 'computed_field',
'weight' => 15,
),
'full' => array(
'label' => 'above',
'type' => 'computed_field_plain',
'weight' => '2',
'settings' => array(),
'module' => 'computed_field',
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 1,
'description' => '',
'ds_extras_field_template' => '',
'field_name' => 'field_computed',
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
),
),
'field_image' => array(
0 => array(
'label' => 'Image',
'description' => 'Upload an image to go with this article.',
'required' => 0,
'settings' => array(
'file_directory' => 'field/image',
'file_extensions' => 'png jpg jpeg',
'max_filesize' => '1MB',
'max_resolution' => '2048x1538',
'min_resolution' => '800x600',
'alt_field' => 1,
'title_field' => 1,
'default_image' => 0,
'user_register_form' => FALSE,
),
'widget' => array(
'weight' => '1',
'type' => 'image_image',
'module' => 'image',
'active' => 1,
'settings' => array(
'progress_indicator' => 'throbber',
'preview_image_style' => 'thumbnail',
),
),
'display' => array(
'default' => array(
'label' => 'hidden',
'type' => 'image',
'weight' => '-1',
'settings' => array(
'image_style' => 'large',
'image_link' => '',
),
'module' => 'image',
),
'teaser' => array(
'label' => 'hidden',
'type' => 'image',
'weight' => '1',
'settings' => array(
'image_style' => 'scale-crop-320-240',
'image_link' => 'content',
),
'module' => 'image',
),
'full' => array(
'label' => 'hidden',
'type' => 'image',
'weight' => '0',
'settings' => array(
'image_style' => 'large',
'image_link' => '',
),
'module' => 'image',
),
),
'field_name' => 'field_image',
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment