Loading src/Controller/ServerEndpointController.php +9 −12 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ namespace Drupal\cl_server\Controller; use Drupal\cl_components\Plugin\Component; use Drupal\cl_components\ComponentPluginManager; use Drupal\cl_components\Exception\ComponentNotFoundException; use Drupal\cl_components\Exception\TemplateNotFoundException; use Drupal\cl_components\Plugin\Component; use Drupal\Component\Serialization\Json; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\PageCache\ResponsePolicy\KillSwitch; Loading Loading @@ -65,19 +65,16 @@ class ServerEndpointController extends ControllerBase { $arguments = $this->getArguments($request); try { $component = $this->getComponent($request); } catch (ComponentNotFoundException $e) { throw new BadRequestHttpException('Invalid component', $e); } $variant = $request->query->get('_variant'); // Storybook will not allow empty title for the story. Let's consider // Default to be the default. $variant = $variant === 'default' ? '' : $variant ?? ''; try { $build = $this->generateRenderArray($component, $variant ?: '', $arguments); } catch (TemplateNotFoundException $e) { $build = []; catch (ComponentNotFoundException|TemplateNotFoundException $e) { $build = [ '#markup' => '<div class="messages messages--error"><h3>' . $this->t('Unable to find component') . '</h3>' . $this->t('Check that the module or theme containing the component is enabled and matches the stories file name.') . '</div>', ]; } $this->cacheKillSwitch->trigger(); return [ Loading Loading
src/Controller/ServerEndpointController.php +9 −12 Original line number Diff line number Diff line Loading @@ -2,10 +2,10 @@ namespace Drupal\cl_server\Controller; use Drupal\cl_components\Plugin\Component; use Drupal\cl_components\ComponentPluginManager; use Drupal\cl_components\Exception\ComponentNotFoundException; use Drupal\cl_components\Exception\TemplateNotFoundException; use Drupal\cl_components\Plugin\Component; use Drupal\Component\Serialization\Json; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\PageCache\ResponsePolicy\KillSwitch; Loading Loading @@ -65,19 +65,16 @@ class ServerEndpointController extends ControllerBase { $arguments = $this->getArguments($request); try { $component = $this->getComponent($request); } catch (ComponentNotFoundException $e) { throw new BadRequestHttpException('Invalid component', $e); } $variant = $request->query->get('_variant'); // Storybook will not allow empty title for the story. Let's consider // Default to be the default. $variant = $variant === 'default' ? '' : $variant ?? ''; try { $build = $this->generateRenderArray($component, $variant ?: '', $arguments); } catch (TemplateNotFoundException $e) { $build = []; catch (ComponentNotFoundException|TemplateNotFoundException $e) { $build = [ '#markup' => '<div class="messages messages--error"><h3>' . $this->t('Unable to find component') . '</h3>' . $this->t('Check that the module or theme containing the component is enabled and matches the stories file name.') . '</div>', ]; } $this->cacheKillSwitch->trigger(); return [ Loading