- Issue created by @alexberendei
- Assigned to praveen rani
- Issue was unassigned.
- Assigned to Rajan Kumar@2026
- 🇮🇳India Rajan Kumar@2026
Hello @alexberendei
i installed this module but inside src folder where controller folder is not available pls provide more details.
in info file d10 compatible missing hare i created a patch.
- Issue was unassigned.
- 🇷🇴Romania alexberendei
on the file /bee_hotel/src/Controller/SearchResult.php at line 210:
$data['destination']['img'] = Link::createFromRoute($beeHotelUnit['cover_image']['markup'], 'entity.node.canonical', [ 'node' => $beeHotelUnit['node']->Id(), 'v' => $data['v_param'], ]);
In case there is one node with no image uploaded (cover_image), the site crashes when you request a search on /RoomSearch
I propose this code:
// Check if cover image exists before accessing it if (isset($beeHotelUnit['cover_image']) && is_array($beeHotelUnit['cover_image']) && isset($beeHotelUnit['cover_image']['markup'])) { $data['destination']['img'] = Link::createFromRoute($beeHotelUnit['cover_image']['markup'], 'entity.node.canonical', [ 'node' => $beeHotelUnit['node']->Id(), 'v' => $data['v_param'], ]); } else { // Handle case where cover image is not available $data['destination']['img'] = t('No Image'); }
- Status changed to Needs review
7 months ago 11:55am 7 May 2024 - 🇮🇹Italy afagioli Rome
Thanks for pointing that out!
Next release will have something like
/** ... use Drupal\image\Entity\ImageStyle; /** * Implements hook_requirements(). */ function bee_hotel_requirements($phase) { $requirements = []; /* * Check image styles */ // Required image styles. $data['required']['styles'] = [ "cover_image_teaser", "thumbnail", ]; $styles = ImageStyle::loadMultiple(); foreach ($data['required']['styles'] as $required_style) { $key = 'bee_hotel_style_' . $required_style; $missings_styles[$required_style] = FALSE; $requirements[$key] = [ 'title' => t('Required image style'), 'description' => t('@style not fund. Please <a href="/admin/config/media/image-styles">check or create image style @style', ['@style' => $required_style]), 'severity' => REQUIREMENT_ERROR, ]; foreach (ImageStyle::loadMultiple() as $id => $object) { if ($required_style == $id ) { unset($requirements[$key]); } } } return $requirements; }
inside bee_hotel.install, reporting missing requirements, as styles.
To be noted also required styles are created by the samplehotel_beehotel module