diff --git a/config_translation.module b/config_translation.module index 8e97209..825066e 100644 --- a/config_translation.module +++ b/config_translation.module @@ -60,24 +60,24 @@ function config_translation_menu() { } $items[$path . '/translate'] = array( 'title' => 'Translate', - 'route_name' => $group->getRouterName(), + 'route_name' => $group->getRouteName(), 'type' => $group->getMenuType(), 'weight' => 100, ); $depth = substr_count($path, '/'); $items[$path . '/translate/add/%language'] = array( 'title' => 'Translate', - 'route_name' => $group->getRouterName() . '.add', + 'route_name' => $group->getRouteName() . '.add', 'type' => MENU_CALLBACK, ); $items[$path . '/translate/edit/%language'] = array( 'title' => 'Translate', - 'route_name' => $group->getRouterName() . '.edit', + 'route_name' => $group->getRouteName() . '.edit', 'type' => MENU_CALLBACK, ); $items[$path . '/translate/delete/%language'] = array( 'title' => 'Delete', - 'route_name' => $group->getRouterName() . '.delete', + 'route_name' => $group->getRouteName() . '.delete', 'type' => MENU_CALLBACK, ); } diff --git a/lib/Drupal/config_translation/Access/ConfigNameCheck.php b/lib/Drupal/config_translation/Access/ConfigNameCheck.php index 78d18c9..0ac08a9 100644 --- a/lib/Drupal/config_translation/Access/ConfigNameCheck.php +++ b/lib/Drupal/config_translation/Access/ConfigNameCheck.php @@ -12,19 +12,19 @@ use Symfony\Component\Routing\Route; use Symfony\Component\HttpFoundation\Request; /** - * Checks access for disabling text formats. + * Checks access for displaying config translation page. */ class ConfigNameCheck implements AccessCheckInterface { /** - * Implements \Drupal\Core\Access\AccessCheckInterface::applies(). + * {@inheritdoc} */ public function applies(Route $route) { return array_key_exists('_config_translation_config_name_access', $route->getRequirements()); } /** - * Implements \Drupal\Core\Access\AccessCheckInterface::access(). + * {@inheritdoc} */ public function access(Route $route, Request $request) { $mapper = $route->getDefault('mapper'); @@ -34,10 +34,7 @@ class ConfigNameCheck implements AccessCheckInterface { $group_language = language_load($group->getLangcode()); $langcode = $request->attributes->get('langcode'); - $language = NULL; - if ($langcode) { - $language = language_load($langcode); - } + $language = empty($langcode) ? NULL : language_load($langcode); // Only allow access to translate configuration, if proper permissions are // granted, the configuration has translatable pieces, the source language diff --git a/lib/Drupal/config_translation/ConfigEntityMapper.php b/lib/Drupal/config_translation/ConfigEntityMapper.php index c90ea24..98f8097 100644 --- a/lib/Drupal/config_translation/ConfigEntityMapper.php +++ b/lib/Drupal/config_translation/ConfigEntityMapper.php @@ -66,11 +66,11 @@ class ConfigEntityMapper implements ConfigMapperInterface { /** - * Router name of the new routing system. + * Router name for this group in the routing system. * * @var bool */ - private $router_name; + private $route_name; /** * Constructor for configuration group. @@ -169,14 +169,14 @@ class ConfigEntityMapper implements ConfigMapperInterface { public function setRouteName() { $search = array('/', '-', '{', '}'); $replace = array('.', '_', '_', '_'); - $this->router_name = 'config_translation.item.' . str_replace($search, $replace, $this->base_path); + $this->route_name = 'config_translation.item.' . str_replace($search, $replace, $this->base_path); } /** * {@inheritdoc} */ - public function getRouterName() { - return $this->router_name; + public function getRouteName() { + return $this->route_name; } /** diff --git a/lib/Drupal/config_translation/ConfigGroupMapper.php b/lib/Drupal/config_translation/ConfigGroupMapper.php index 4c305c0..c7d89f0 100644 --- a/lib/Drupal/config_translation/ConfigGroupMapper.php +++ b/lib/Drupal/config_translation/ConfigGroupMapper.php @@ -50,11 +50,11 @@ class ConfigGroupMapper implements ConfigMapperInterface { private $add_edit_tab = FALSE; /** - * Router name of the new routing system. + * Router name for this group in the routing system. * * @var bool */ - private $router_name; + private $route_name; /** * Constructor for configuration group. @@ -225,14 +225,14 @@ class ConfigGroupMapper implements ConfigMapperInterface { * {@inheritdoc} */ public function setRouteName() { - $this->router_name = 'config_translation.item.' . str_replace(array('/', '-'), array('.', '_'), $this->base_path); + $this->route_name = 'config_translation.item.' . str_replace(array('/', '-'), array('.', '_'), $this->base_path); } /** * {@inheritdoc} */ - public function getRouterName() { - return $this->router_name; + public function getRouteName() { + return $this->route_name; } /** diff --git a/lib/Drupal/config_translation/ConfigMapperInterface.php b/lib/Drupal/config_translation/ConfigMapperInterface.php index 1ba60b3..4a0c4b1 100644 --- a/lib/Drupal/config_translation/ConfigMapperInterface.php +++ b/lib/Drupal/config_translation/ConfigMapperInterface.php @@ -53,7 +53,7 @@ interface ConfigMapperInterface { public function getConfigGroup($arg = NULL); /** - * Helper to provide type of the group. + * Returns entity type of the entity type mapper, NULL otherwise. * * @return mixed */ @@ -71,6 +71,6 @@ interface ConfigMapperInterface { * * @return mixed */ - public function getRouterName(); + public function getRouteName(); } diff --git a/lib/Drupal/config_translation/Controller/ConfigTranslationController.php b/lib/Drupal/config_translation/Controller/ConfigTranslationController.php index b55689a..a4c0fc8 100644 --- a/lib/Drupal/config_translation/Controller/ConfigTranslationController.php +++ b/lib/Drupal/config_translation/Controller/ConfigTranslationController.php @@ -80,7 +80,7 @@ class ConfigTranslationController implements ControllerInterface { /** * Language translations overview page for a configuration name. * - ** @param Request $request + * @param Request $request * Page request object. * @param ConfigMapperInterface $mapper * Configuration mapper. @@ -166,7 +166,7 @@ class ConfigTranslationController implements ControllerInterface { } /** - * Renders translation item manage form. + * Renders translation item manage form. * * @param Request $request * Page request object. @@ -176,7 +176,7 @@ class ConfigTranslationController implements ControllerInterface { * @param ConfigMapperInterface $mapper * Configuration mapper. * - * @return array|mixed + * @return array */ public function itemTranslatePage(Request $request, $action, ConfigMapperInterface $mapper) { $group = $this->getConfigGroup($request, $mapper); @@ -246,6 +246,7 @@ class ConfigTranslationController implements ControllerInterface { * @param ConfigMapperInterface $mapper * * @return bool|\Drupal\core\Language\Language + * Returns Language object when langcode found in request; FALSE otherwise. */ protected function getLanguage(Request $request, ConfigMapperInterface $mapper) { $langcode = $request->attributes->get('langcode'); diff --git a/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php b/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php index 3a4beed..29cf0f5 100644 --- a/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php +++ b/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php @@ -13,7 +13,7 @@ use Drupal\config_translation\ConfigMapperInterface; use Symfony\Component\Routing\Route; /** - * Builds a form to delete an action. + * Builds a form to delete config translation. */ class ConfigTranslationDeleteForm extends ConfirmFormBase { diff --git a/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php b/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php index 908577d..c8d13cc 100644 --- a/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php +++ b/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php @@ -13,32 +13,38 @@ use Drupal\config_translation\ConfigMapperInterface; use Drupal\Core\Config\Schema\Element; /** - * Provides a form for configuring an action. + * Provides a form for manage configuration translation. */ class ConfigTranslationManageForm implements FormInterface { /** - * The group of config translation to be deleted. + * The group of config translation. * - * @var \stdClass + * @var \Drupal\config_translation\ConfigMapperInterface */ protected $group; /** * The language of config translation. * - * @var \stdClass + * @var \Drupal\Core\Language\Language */ protected $language; + /** + * An array of base language configuration data keyed by configuration names. + * + * @var array + */ protected $base_config = array(); /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc}. */ public function getFormID() { return 'config_translation_form'; } + /** * Build configuration form with metadata and values. */ @@ -100,7 +106,6 @@ class ConfigTranslationManageForm implements FormInterface { $form_state['redirect'] = $this->group->getBasePath() . '/translate'; } - /** * Formats configuration schema as a form tree. * diff --git a/lib/Drupal/config_translation/Routing/RouteSubscriber.php b/lib/Drupal/config_translation/Routing/RouteSubscriber.php index 81fdd21..98aedbc 100644 --- a/lib/Drupal/config_translation/Routing/RouteSubscriber.php +++ b/lib/Drupal/config_translation/Routing/RouteSubscriber.php @@ -1,6 +1,7 @@ 'TRUE', )); - $collection->add($group->getRouterName(), $route); - + $collection->add($group->getRouteName(), $route); $route = new Route($path . '/translate/add/{langcode}', array( '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemTranslatePage', @@ -59,7 +59,7 @@ class RouteSubscriber implements EventSubscriberInterface { ),array( '_config_translation_config_name_access' => 'TRUE', )); - $collection->add($group->getRouterName() . '.add', $route); + $collection->add($group->getRouteName() . '.add', $route); $route = new Route($path . '/translate/edit/{langcode}', array( '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemTranslatePage', @@ -68,7 +68,7 @@ class RouteSubscriber implements EventSubscriberInterface { ),array( '_config_translation_config_name_access' => 'TRUE', )); - $collection->add($group->getRouterName() . '.edit', $route); + $collection->add($group->getRouteName() . '.edit', $route); $route = new Route($path . '/translate/delete/{langcode}', array( '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemDeletePage', @@ -76,7 +76,7 @@ class RouteSubscriber implements EventSubscriberInterface { ),array( '_config_translation_config_name_access' => 'TRUE', )); - $collection->add($group->getRouterName() . '.delete', $route); + $collection->add($group->getRouteName() . '.delete', $route); } } }