Entity Construction Kit

Vehicle Entity

Id Title Make Model Truck Bed Vehicle type Year
1 2002 Chevrolet Cavelier Chevrolet Cavelier car 2002
2 2001 Chevrolet Corvette Chevrolet Corvette car 2001
3 2002 Ford Ranger Ford Ranger Open Bed truck 2002
4 2007 Honda Accord LX Honda Accord LX car 2007
5 2013 Volkswagon Jetta SE Volkswagon Jetta SE car 2013
6 2015 Chevrolet Malibu LS Chevrolet Malibu LS car 2015
7 2017 Chevrolet Silverado 150 Chevrolet Silerado 150 Open Bed truck 2017
8 2014 Dodge Ram 1500 Quad Cab Pickup Dodge Ram 1500 Quad Cab Covered Bed truck 2014

name = Vehicle Module
description = Code used to create vehicle enitiy type
core = 7.x
package = Features
version = 7.x-1.0
dependencies[] = eck
dependencies[] = features
dependencies[] = text
features[eck_bundle][] = vehicle_car
features[eck_bundle][] = vehicle_truck
features[eck_entity_type][] = vehicle
features[features_api][] = api:2
features[field_base][] = field_truck_bed
features[field_instance][] = vehicle-truck-field_truck_bed

 

<?php
/**
 * @file
 * Code for the Vehicle Module feature.
 */

include_once 'vehicle_module.features.inc';
 

 

<?php
/**
 * @file
 * vehicle_module.features.inc
 */

/**
 * Implements hook_eck_bundle_info().
 */
function vehicle_module_eck_bundle_info() {
  $items = array(
    'vehicle_car' => array(
      'machine_name' => 'vehicle_car',
      'entity_type' => 'vehicle',
      'name' => 'car',
      'label' => 'car',
      'config' => array(),
    ),
    'vehicle_truck' => array(
      'machine_name' => 'vehicle_truck',
      'entity_type' => 'vehicle',
      'name' => 'truck',
      'label' => 'truck',
      'config' => array(),
    ),
  );
  return $items;
}

/**
 * Implements hook_eck_entity_type_info().
 */
function vehicle_module_eck_entity_type_info() {
  $items = array(
    'vehicle' => array(
      'name' => 'vehicle',
      'label' => 'Vehicle',
      'properties' => array(
        'title' => array(
          'label' => 'Title',
          'type' => 'text',
          'behavior' => 'title',
        ),
        'created' => array(
          'label' => 'Created',
          'type' => 'integer',
          'behavior' => 'created',
        ),
        'make' => array(
          'label' => 'Make',
          'type' => 'text',
          'behavior' => 'title',
        ),
        'year' => array(
          'label' => 'Year',
          'type' => 'integer',
          'behavior' => 'title',
        ),
        'model' => array(
          'label' => 'Model',
          'type' => 'text',
          'behavior' => 'title',
        ),
      ),
    ),
  );
  return $items;

 

<?php
/**
 * @file
 * vehicle_module.features.field_instance.inc
 */

/**
 * Implements hook_field_default_field_instances().
 */
function vehicle_module_field_default_field_instances() {
  $field_instances = array();

  // Exported field_instance: 'vehicle-truck-field_truck_bed'.
  $field_instances['vehicle-truck-field_truck_bed'] = array(
    'bundle' => 'truck',
    'default_value' => NULL,
    'deleted' => 0,
    'description' => '',
    'display' => array(
      'default' => array(
        'label' => 'above',
        'module' => 'text',
        'settings' => array(),
        'type' => 'text_default',
        'weight' => 0,
      ),
      'teaser' => array(
        'label' => 'above',
        'settings' => array(),
        'type' => 'hidden',
        'weight' => 0,
      ),
    ),
    'entity_type' => 'vehicle',
    'field_name' => 'field_truck_bed',
    'label' => 'Truck Bed',
    'required' => 0,
    'settings' => array(
      'text_processing' => 0,
      'user_register_form' => FALSE,
    ),
    'widget' => array(
      'active' => 1,
      'module' => 'text',
      'settings' => array(
        'size' => 60,
      ),
      'type' => 'text_textfield',
      'weight' => 31,
    ),
  );

  // Translatables
  // Included for use with string extractors like potx.
  t('Truck Bed');
 

<?php
/**
 * @file
 * vehicle_module.features.field_base.inc
 */

/**
 * Implements hook_field_default_field_bases().
 */
function vehicle_module_field_default_field_bases() {
  $field_bases = array();

  // Exported field_base: 'field_truck_bed'.
  $field_bases['field_truck_bed'] = array(
    'active' => 1,
    'cardinality' => 1,
    'deleted' => 0,
    'entity_types' => array(),
    'field_name' => 'field_truck_bed',
    'indexes' => array(
      'format' => array(
        0 => 'format',
      ),
    ),
    'locked' => 0,
    'module' => 'text',
    'settings' => array(
      'max_length' => 255,
    ),
    'translatable' => 0,
    'type' => 'text',
  );

  return $field_bases;