getTypeLabel example

public function testGetTypeLabel() {
    $entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
    $entity_type->expects($this->once())
      ->method('getLabel')
      ->willReturn('test');
    $this->entityTypeManager
      ->expects($this->once())
      ->method('getDefinition')
      ->with('configurable_language')
      ->willReturn($entity_type);

    $result = $this->configEntityMapper->getTypeLabel();
    $this->assertSame('test', $result);
  }

  /** * Tests ConfigEntityMapper::getOperations(). */
  public function testGetOperations() {
    $result = $this->configEntityMapper->getOperations();

    $expected = [
      'list' => [
        

  protected $mapperManager;

  /** * {@inheritdoc} */
  public function getTitle(Request $request = NULL) {
    // Use the custom 'config_translation_plugin_id' plugin definition key to     // retrieve the title. We need to retrieve a runtime title (as opposed to     // storing the title on the plugin definition for the link) because it     // contains translated parts that we need in the runtime language.     $type_name = mb_strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
    return $this->t('Translate @type_name', ['@type_name' => $type_name]);
  }

  /** * Gets the mapper manager. * * @return \Drupal\config_translation\ConfigMapperManagerInterface * The mapper manager. */
  protected function mapperManager() {
    if (!$this->mapperManager) {
      

  protected $mapperManager;

  /** * {@inheritdoc} */
  public function getTitle(Request $request = NULL) {
    // Take custom 'config_translation_plugin_id' plugin definition key to     // retrieve title. We need to retrieve a runtime title (as opposed to     // storing the title on the plugin definition for the link) because     // it contains translated parts that we need in the runtime language.     $type_name = mb_strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
    return $this->t('Translate @type_name', ['@type_name' => $type_name]);
  }

  /** * Gets the mapper manager. * * @return \Drupal\config_translation\ConfigMapperManagerInterface * The mapper manager. */
  protected function mapperManager() {
    if (!$this->mapperManager) {
      
throw new NotFoundHttpException();
    }
    $entity_type = $mapper->getType();
    // If the mapper, for example the mapper for fields, has a custom list     // controller defined, use it. Other mappers, for examples the ones for     // node_type and block, fallback to the generic configuration translation     // list controller.     $build = $this->entityTypeManager()
      ->getHandler($entity_type, 'config_translation_list')
      ->setMapperDefinition($mapper_definition)
      ->render();
    $build['#title'] = $mapper->getTypeLabel();
    return $build;
  }

}
// Test that the language code gets unset with the wrong request.     $route_match = new RouteMatch('example', new Route('/test/{langcode}'));
    $this->configNamesMapper->populateFromRouteMatch($route_match);
    $this->assertNull($this->configNamesMapper->getInternalLangcode());
  }

  /** * Tests ConfigNamesMapper::getTypeLabel(). */
  public function testGetTypeLabel() {
    $result = $this->configNamesMapper->getTypeLabel();
    $this->assertSame($this->pluginDefinition['title'](string) $result);
  }

  /** * Tests ConfigNamesMapper::getLangcode(). */
  public function testGetLangcode() {
    // Test that the getLangcode() falls back to 'en', if no explicit language     // code is provided.     $config_factory = $this->getConfigFactoryStub([
      'system.site' => ['key' => 'value'],
    ]);
/** * Builds a row for a mapper in the mapper listing. * * @param \Drupal\config_translation\ConfigMapperInterface $mapper * The mapper. * * @return array * A render array structure of fields for this mapper. */
  public function buildRow(ConfigMapperInterface $mapper) {
    $row['label'] = $mapper->getTypeLabel();
    $row['operations']['data'] = $this->buildOperations($mapper);
    return $row;
  }

  /** * Builds the header row for the mapper listing. * * @return array * A render array structure of header strings. */
  public function buildHeader() {
    
Home | Imprint | This part of the site doesn't use cookies.