You are here

public function EntityLegalDocumentController::save in Entity Legal 7

Same name and namespace in other branches
  1. 7.2 entity_legal.entity_controller.inc \EntityLegalDocumentController::save()

Overridden to care exportables that are overridden.

Overrides EntityAPIControllerExportable::save

File

./entity_legal.entity_controller.inc, line 14
Entity API controller classes for entity_legal module.

Class

EntityLegalDocumentController
Entity Legal Document controller class.

Code

public function save($entity) {

  // When creating a new legal document, add the document text to the bundle.
  if (!empty($entity->is_new)) {
    $instance = array(
      'field_name' => 'entity_legal_document_text',
      'entity_type' => ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME,
      'bundle' => $entity
        ->identifier(),
      'label' => 'Document text',
      'widget' => array(
        'type' => 'text_textarea_with_summary',
        'weight' => 1,
      ),
      'settings' => array(
        'display_summary' => TRUE,
      ),
      'display' => array(
        'default' => array(
          'label' => 'hidden',
          'type' => 'text_default',
        ),
        'teaser' => array(
          'label' => 'hidden',
          'type' => 'text_summary_or_trimmed',
        ),
      ),
    );
    field_create_instance($instance);
  }
  $success = parent::save($entity);

  // Flush the entity info cache to allow the new bundle to be registered.
  entity_info_cache_clear();
  return $success;
}