Skip to content
Snippets Groups Projects

Issue #3347474: Fix Icon patch for Type Tray with the Origin URL (scheme and HTTP host) of the site

Open Issue #3347474: Fix Icon patch for Type Tray with the Origin URL (scheme and HTTP host) of the site
3 unresolved threads
Open Rajab Natshah requested to merge issue/type_tray-3347474:3347474-fix-icon-patch into 1.0.x
3 unresolved threads
@@ -183,14 +183,19 @@ class TypeTrayController extends NodeController {
])->toString();
$favorite_link_action = 'add';
}
/** @var \Symfony\Component\HttpFoundation\Request $origin_url */
    • This comment seems innacurate? Can we replace with something that explains why we calculate all this at this point? Maybe something along the lines of

              // Calculate the path of the default thumbnails in case there is nothing
              // stored in config.
Please register or sign in to reply
$origin_url = \Drupal::request()->getSchemeAndHttpHost() . \Drupal::request()->getBaseUrl();
Please register or sign in to reply
$origin_url_type_tray = $origin_url . '/' . $this->moduleList->getPath('type_tray');
    • Just for clarity, can we maybe define here directly the default URL we want to use? So instead of

      $origin_url_type_tray = $origin_url . '/' . $this->moduleList->getPath('type_tray');

      we can use

      $default_thumbnail_url = $origin_url . '/' . $this->moduleList->getPath('type_tray') . static::TYPE_TRAY_DEFAULT_THUMBNAIL_PATH;

      and then just use $default_thumbnail_url as the fallback in the ternary check down below? I think this makes things a bit clearer. Thanks!

Please register or sign in to reply
$build['#items'][$category][$type->id()] = [
'#theme' => 'type_tray_teaser',
'#content_type_link' => Link::createFromRoute($type->label(), 'node.add', ['node_type' => $type->id()]),
'#thumbnail_url' => !empty($settings['type_thumbnail']) ? $settings['type_thumbnail'] : '/' . $this->moduleList->getPath('type_tray') . static::TYPE_TRAY_DEFAULT_THUMBNAIL_PATH,
'#thumbnail_url' => !empty($settings['type_thumbnail']) ? $settings['type_thumbnail'] : $origin_url_type_tray . static::TYPE_TRAY_DEFAULT_THUMBNAIL_PATH,
'#thumbnail_alt' => $this->t('Thumbnail of a @label content type.', [
'@label' => $type->label(),
]),
'#icon_url' => !empty($settings['type_icon']) ? $settings['type_icon'] : '/' . $this->moduleList->getPath('type_tray') . static::TYPE_TRAY_DEFAULT_ICON_PATH,
'#icon_url' => !empty($settings['type_icon']) ? $settings['type_icon'] : $origin_url_type_tray . static::TYPE_TRAY_DEFAULT_ICON_PATH,
'#icon_alt' => $this->t('Icon of a @label content type.', [
'@label' => $type->label(),
]),
Loading