AllowedLanguagesController.php in Allowed Languages 2.x
File
src/Controller/AllowedLanguagesController.php
View source
<?php
namespace Drupal\allowed_languages\Controller;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\content_translation\Controller\ContentTranslationController;
class AllowedLanguagesController extends ContentTranslationController {
public function overview(RouteMatchInterface $route_match, $entity_type_id = NULL) {
$build = parent::overview($route_match, $entity_type_id);
$user = $this
->currentUser();
if ($user
->hasPermission('translate all languages') || empty($build['content_translation_overview']['#rows'])) {
return $build;
}
$rows =& $build['content_translation_overview']['#rows'];
$languages = $this
->languageManager()
->getLanguages();
$allowed_languages = \Drupal::service('allowed_languages.allowed_languages_manager')
->assignedLanguages();
$i = 0;
foreach ($languages as $language) {
if (!in_array($language
->getId(), $allowed_languages)) {
$target_row = $rows[$i];
end($target_row);
$operations_key = key($target_row);
unset($rows[$i][$operations_key]['data']);
}
$i++;
}
return $build;
}
}