class EntityformTypeController in Entityform 7.2
Same name and namespace in other branches
- 7 entityform.module \EntityformTypeController
The Controller for Entityform entities
Hierarchy
- class \DrupalDefaultEntityController implements DrupalEntityControllerInterface
- class \EntityAPIController implements EntityAPIControllerRevisionableInterface
- class \EntityAPIControllerExportable
- class \EntityformTypeController
- class \EntityAPIControllerExportable
- class \EntityAPIController implements EntityAPIControllerRevisionableInterface
Expanded class hierarchy of EntityformTypeController
1 string reference to 'EntityformTypeController'
- entityform_entity_info in ./
entityform.module - Implements hook_entity_info().
File
- ./
entityform.module, line 1327 - Module for the Entityform Entity - a starting point to create your own Entity and associated administration interface
View source
class EntityformTypeController extends EntityAPIControllerExportable {
public function __construct($entityType) {
parent::__construct($entityType);
}
/**
* Create a entityform type - we first set up the values that are specific
* to our entityform type schema but then also go through the EntityAPIController
* function.
*
* @param $type
* The machine-readable type of the entityform.
*
* @return
* A entityform type object with all default fields initialized.
*/
public function create(array $values = array(), $load_defaults = FALSE) {
// Add values that are specific to our Entityform
$default_values = variable_get('entityform_type_defaults', array());
if (empty($default_values)) {
$default_values = array();
}
$values += $default_values;
$values += array(
'id' => '',
'is_new' => TRUE,
);
if (!isset($values['data'])) {
$values['data'] = array();
}
if ($load_defaults) {
$values['data'] += array(
'submissions_view' => 'entityforms',
'user_submissions_view' => 'user_entityforms',
'preview_page' => 0,
);
$values['data'] += $this
->get_default_text_values();
}
else {
if ($values['is_new']) {
// Don't override values even if is_new. Features will send values in for checking status.
$values['data'] += array(
'submissions_view' => 'default',
'user_submissions_view' => 'default',
);
}
}
$entityform_type = parent::create($values);
return $entityform_type;
}
/**
* Returns default text values
*/
public function get_default_text_values() {
return array(
'label' => '',
'instruction_pre' => '',
'submit_confirm_msg' => t('Your submission has been saved.'),
'submission_page_title' => t('Thank You.'),
'draft_button_text' => t('Save Draft'),
'submit_button_text' => t('Submit'),
'your_submissions' => t('Your Submissions: @label', array(
'@label' => '[entityform_type:label]',
)),
'disallow_resubmit_msg' => t('You already submitted this form'),
'delete_confirm_msg' => t('Are you sure you want to delete this Submission for @label', array(
'@label' => '[entityform_type:label]?',
)),
'draft_save_text' => '',
'page_title_view' => t('Form Submission: @label', array(
'@label' => '[entityform_type:label]',
)),
);
}
/**
* Returns text labels.
*/
public function get_text_labels() {
return array(
'label' => t('Label'),
'draft_redirect_path' => t('Draft Redirect path'),
'draft_button_text' => t('Override draft button text'),
'draft_save_text' => t('Draft save text'),
'submit_button_text' => t('Submit Button Text'),
'submit_confirm_msg' => t('Submission Confirmation Text'),
'your_submissions' => t('Your Submissions Text'),
'disallow_resubmit_msg' => t('Form Disallow Resubmit Text'),
'delete_confirm_msg' => t('Submission Delete Text'),
'submission_page_title' => t('Thank You.'),
'page_title_view' => t('Submission View Title'),
'submission_text' => t('Submission reply'),
'redirect_path' => t('Redirect path'),
'instruction_pre' => t('Intro form instructions'),
);
}
/*
* Overridden to Load file
*/
public function view($entities, $view_mode = 'full', $langcode = NULL, $page = NULL) {
$view = parent::view($entities, $view_mode, $langcode, $page);
foreach ($entities as $entity_id => $entity) {
module_load_include('inc', 'entityform', 'entityform.admin');
$view[$this->entityType][$entity->type]['form'] = entityform_form_wrapper(entityform_empty_load($entity->type), 'submit', $page ? 'page' : 'embedded');
}
return $view;
}
/**
* Overridden to load paths also
*/
public function load($ids = array(), $conditions = array()) {
$entityform_types = parent::load($ids, $conditions);
foreach ($entityform_types as $entityform_type) {
if (module_exists('path')) {
$entityform_type->paths = array();
$path_types = _entityform_type_get_path_types($entityform_type->type);
foreach ($path_types as $key => $path_type) {
//check for existing alias
$conditions = array(
'source' => $path_type['default_path'],
);
$path = path_load($conditions);
if ($path !== FALSE) {
$entityform_type->paths[$key] = $path;
}
}
}
}
return $entityform_types;
}
/**
* Overridden to clear cache.
*/
public function save($entity, DatabaseTransaction $transaction = NULL) {
$return = parent::save($entity, $transaction);
// Reset the entityform type cache. We need to do this first so
// menu changes pick up our new type.
entityform_type_cache_reset();
// Clear field info caches such that any changes to extra fields get
// reflected.
field_info_cache_clear();
return $return;
}
/**
* Overridden to delete aliases and clear cache.
*/
public function delete($ids, DatabaseTransaction $transaction = NULL) {
$entities = $ids ? $this
->load($ids) : FALSE;
if ($entities) {
if (module_exists('path')) {
foreach ($entities as $id => $entity) {
try {
$path_types = _entityform_type_get_path_types($entity->type);
foreach ($path_types as $path_type) {
path_delete(array(
'source' => $path_type['default_path'],
));
}
} catch (Exception $e) {
}
}
}
// Delete all menu module links that point to this entityform type.
$submit_paths = array();
foreach ($entities as $id => $entity) {
$submit_paths[] = _entityform_type_get_submit_url($entity->type);
}
$result = db_query("SELECT mlid FROM {menu_links} WHERE link_path IN (:path) AND module = 'entityform'", array(
':path' => $submit_paths,
), array(
'fetch' => PDO::FETCH_ASSOC,
));
foreach ($result as $m) {
menu_link_delete($m['mlid']);
}
parent::delete($ids, $transaction);
// Clear field info caches such that any changes to extra fields get
// reflected.
field_info_cache_clear();
// Reset the entityform type cache.
entityform_type_cache_reset();
}
}
/*
* Overridden to exclude pid in alias Export
*/
public function export($entity, $prefix = '') {
if (module_exists('path')) {
foreach ($entity->paths as &$path) {
unset($path['pid']);
}
}
return parent::export($entity, $prefix);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalDefaultEntityController:: |
protected | property | Whether this entity type should use the static cache. | |
DrupalDefaultEntityController:: |
protected | property | Static cache of entities, keyed by entity ID. | |
DrupalDefaultEntityController:: |
protected | property | Array of information about the entity. | |
DrupalDefaultEntityController:: |
protected | property | Entity type for this controller instance. | |
DrupalDefaultEntityController:: |
protected | property | Additional arguments to pass to hook_TYPE_load(). | |
DrupalDefaultEntityController:: |
protected | property | Name of the entity's ID field in the entity database table. | |
DrupalDefaultEntityController:: |
protected | property | Name of entity's revision database table field, if it supports revisions. | |
DrupalDefaultEntityController:: |
protected | property | The table that stores revisions, if the entity supports revisions. | |
DrupalDefaultEntityController:: |
protected | function | Ensures integer entity IDs are valid. | |
DrupalDefaultEntityController:: |
protected | function | Callback for array_filter that removes non-integer IDs. | |
EntityAPIController:: |
protected | property | ||
EntityAPIController:: |
protected | property | ||
EntityAPIController:: |
protected | property | ||
EntityAPIController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface:: |
|
EntityAPIController:: |
public | function |
Implements EntityAPIControllerRevisionableInterface::deleteRevision(). Overrides EntityAPIControllerRevisionableInterface:: |
|
EntityAPIController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerInterface:: |
|
EntityAPIController:: |
public | function | Builds and executes the query for loading. | |
EntityAPIController:: |
protected | function | Renders a single entity property. | |
EntityAPIController:: |
protected | function | Saves an entity revision. | |
EntityAPIControllerExportable:: |
protected | property | ||
EntityAPIControllerExportable:: |
protected | property | ||
EntityAPIControllerExportable:: |
protected | function | ||
EntityAPIControllerExportable:: |
protected | function |
Overridden. Overrides DrupalDefaultEntityController:: |
|
EntityAPIControllerExportable:: |
protected | function |
Support loading by name key. Overrides EntityAPIController:: |
|
EntityAPIControllerExportable:: |
protected | function |
Overridden. Overrides DrupalDefaultEntityController:: |
|
EntityAPIControllerExportable:: |
protected | function | Like cacheGet() but keyed by name. | |
EntityAPIControllerExportable:: |
protected | function |
Overridden. Overrides DrupalDefaultEntityController:: |
|
EntityAPIControllerExportable:: |
public | function |
Overridden to care about reverted bundle entities and to skip Rules. Overrides EntityAPIController:: |
|
EntityAPIControllerExportable:: |
public | function |
Overrides DrupalDefaultEntityController::resetCache(). Overrides EntityAPIController:: |
|
EntityformTypeController:: |
public | function |
Create a entityform type - we first set up the values that are specific
to our entityform type schema but then also go through the EntityAPIController
function. Overrides EntityAPIController:: |
|
EntityformTypeController:: |
public | function |
Overridden to delete aliases and clear cache. Overrides EntityAPIControllerExportable:: |
|
EntityformTypeController:: |
public | function |
Overridden. Overrides EntityAPIControllerExportable:: |
|
EntityformTypeController:: |
public | function | Returns default text values | |
EntityformTypeController:: |
public | function | Returns text labels. | |
EntityformTypeController:: |
public | function |
Overridden to load paths also Overrides EntityAPIControllerExportable:: |
|
EntityformTypeController:: |
public | function |
Overridden to clear cache. Overrides EntityAPIControllerExportable:: |
|
EntityformTypeController:: |
public | function |
Implements EntityAPIControllerInterface. Overrides EntityAPIControllerExportable:: |
|
EntityformTypeController:: |
public | function |
Overridden. Overrides EntityAPIControllerExportable:: |