You are here

function tmgmt_translator_exists in Translation Management Tool 7

Checks whether a translator entity with the supplied name already exists.

We can't use entity_load or any of its wrapper functions for that as our translator entity controller filters out broken translator entities (e.g. if the translator plugin of the translator entity doesn't exist (anymore).

Parameters

$name: The machine-readable name of the translator entity that we are trying to save.

Return value

boolean TRUE if a translator entity with the same machine-readable name already exists FALSE otherwise.

Related topics

1 call to tmgmt_translator_exists()
tmgmt_translator_auto_create in ./tmgmt.module
Auto creates a translator from a translator plugin definition.
1 string reference to 'tmgmt_translator_exists'
tmgmt_translator_form in ui/includes/tmgmt_ui.pages.inc
Entity API form for the translator entity.

File

./tmgmt.module, line 856
Main module file for the Translation Management module.

Code

function tmgmt_translator_exists($name) {
  $query = new EntityFieldQuery();
  return (bool) $query
    ->entityCondition('entity_type', 'tmgmt_translator')
    ->propertyCondition('name', $name)
    ->count()
    ->range(0, 1)
    ->execute();
}