diff --git a/config_translation.module b/config_translation.module index be7cc4e..14e018f 100644 --- a/config_translation.module +++ b/config_translation.module @@ -7,10 +7,9 @@ use Drupal\Core\Config\Schema\Element; use Drupal\Core\Language\Language; -use Drupal\user\Plugin\Core\Entity\User; use Drupal\config_translation\ConfigGroupMapper; use Drupal\config_translation\ConfigEntityMapper; -use Drupal\config_translation\ConfigMapperInterface; +use Drupal\user\Plugin\Core\Entity\User; /** * Implements hook_help(). @@ -36,11 +35,11 @@ function config_translation_menu() { foreach ($config_groups as $group) { $path = $group->getBasePath(); if ($group->hasEditTab()) { - // For pages that do not have a default tab, we need a default - // local task on this level, so that the translate tab will show - // up. - // @todo: this is not very compatible with possible other alters. - // Look into other clever ways to make this happen. + // For pages that do not have a default tab, we need a default local task + // on this level, so that the translate tab will show up. + // @todo This is not very compatible with possible other alters. Look + // into other clever ways to make this happen, + // http://drupal.org/node/2011332. $items[$path . '/edit'] = array( 'title' => 'Edit', 'type' => MENU_DEFAULT_LOCAL_TASK, @@ -53,7 +52,6 @@ function config_translation_menu() { 'type' => $group->getMenuType(), 'weight' => 100, ); - $depth = substr_count($path, '/'); $items[$path . '/translate/add/%language'] = array( 'title' => 'Translate', 'route_name' => $group->getRouteName() . '.add', @@ -97,9 +95,8 @@ function config_translation_theme() { ); } - /** - * Returns HTML for translation manage element + * Returns HTML for translation manage element. * * @param array $variables * An associative array containing: @@ -124,12 +121,13 @@ function theme_config_translation_manage_form_element($variables){ } /** - * Helper function to figure out if a configuration key has schema coverage. + * Returns TRUE if a configuration key has schema coverage. * * @param string $name * Configuration key. * * @return bool + * A boolean indicating if a configuration key has schema coverage. */ function config_translation_has_schema($name) { // The schema system falls back on the Property class for unknown types. @@ -139,12 +137,13 @@ function config_translation_has_schema($name) { } /** - * Helper function to figure out if the configuration data has translatable items. + * Returns TRUE if the configuration data has translatable items. * * @param string $name * Configuration key. * * @return bool + * A boolean indicating if the configuration data has translatable items. */ function config_translation_has_translatable($name) { return config_translation_find_translatable(config_typed()->get($name)); @@ -153,14 +152,15 @@ function config_translation_has_translatable($name) { /** * Returns TRUE if at least one translatable element is found. * - * @todo - * Make this conditional on the translatable schema property from + * @todo Make this conditional on the translatable schema property from * http://drupal.org/node/1905152 - currently hardcodes label and text. * - * @param $schema - * Configuration schema definition. + * @param mixed $schema + * Configuration schema definition which is a + * \Drupal\Core\Config\Schema\Element or an array of Elements. * * @return bool + * A boolean indicating if there is at least one translatable element. */ function config_translation_find_translatable($schema) { foreach ($schema as $element) { @@ -189,7 +189,7 @@ function config_translation_original_langcode($name) { } /** - * Check whether a language has config translation. + * Checks whether a language has config translation. * * @param string $name * Configuration name. @@ -197,6 +197,7 @@ function config_translation_original_langcode($name) { * A language object. * * @return bool + * A boolean indicating if a language has config translations. */ function config_translation_exists($name, Language $language) { $config_translation = config('locale.config.' . $language->langcode . '.' . $name)->get(); @@ -204,12 +205,15 @@ function config_translation_exists($name, Language $language) { } /** - * Get group definitions from hooks and make it possible to alter groups. + * Gets group definitions from hooks and make it possible to alter groups. * * Configuration groups are used to get multiple configuration names used for * one specific configuration form together. If contributed modules alter a * form adding in additional settings stored elsewhere, the list of names * can be expanded. + * + * @return array + * An array of configuration groups. */ function config_translation_get_groups() { $config_groups = Drupal::ModuleHandler()->invokeAll('config_translation_group_info'); @@ -267,11 +271,10 @@ function config_translation_config_translation_group_info() { } /** - * Goddamn ugly operations altering since there is no operations API. + * Alters form operations since there is no operations API. * - * @todo - * Rework this in favor of an operations API. See - * http://drupal.org/node/1839516 + * @todo Rework this in favor of an operations API. See + * http://drupal.org/node/2004428 */ function config_translation_form_alter(&$form, &$form_state, $form_id) { if (!user_access('translate configuration')) { @@ -326,15 +329,13 @@ function config_translation_form_alter(&$form, &$form_state, $form_id) { } } } - } /** - * Goddamn ugly operations altering since there is no operations API. + * Alters page operations since there is no operations API. * - * @todo - * Rework this in favor of an operations API. See - * http://drupal.org/node/1839516 + * @todo Rework this in favor of an operations API. See + * http://drupal.org/node/2004428 */ function config_translation_page_alter(&$page) { if (!user_access('translate configuration')) { @@ -343,7 +344,7 @@ function config_translation_page_alter(&$page) { } if (isset($page['content'])) { - // Grab the first content item, which is the content block (hopefully :). + // Grab the first content item, which is the content block hopefully. $content_keys = array_keys($page['content']); $content = &$page['content'][reset($content_keys)]; @@ -417,10 +418,10 @@ function config_translation_page_alter(&$page) { } /** - * Use a dummy user to get overrides for a specific language. + * Uses a dummy user to get overrides for a specific language. * - * See http://drupal.org/node/1905152 for an upcoming API to access - * translations easier through typed data. + * @todo Use API from http://drupal.org/node/1905152 to access translations + * easier through typed data. * * @param \Drupal\Core\Language\Language $language * A language object.