MichalKleiner

I think there was a debate if HTTP 200 OK with a {'status': 'error', 'code': 404} payload isn’t too weird

Bjorn Bojumble

Hi all, Is there a simple way to return a 404 via graphql, or at least an error message with a code?

MichalKleiner

a couple of improvements…. I’d check for if (!empty(trim($htmlContent))), use DBHTMLText::create instead of new and there’s no need to explicitly enable the shortcodes processing as that class has it on by default

🎉 (1)
Anthony van Beek

@unclecheese I did this (I extended the Content Block using Silverstripe Elemental) :

  1. /**
  2.  * Class ElementContentExtension
  3.  */
  4. final class ElementContentExtension extends Extension
  5. {
  6. /**
  7.   * @param $blockSchema
  8.   */
  9. public function updateBlockSchema(&$blockSchema)
  10. {
  11.  
  12. $htmlContent = $this->owner->HTML;
  13.  
  14. if (isset($htmlContent)) {
  15. $newHTML = new DBHTMLText('HTML');
  16. $newHTML->setProcessShortcodes(true);
  17.  
  18. $newHTML->setValue($htmlContent);
  19. $htmlContent = $newHTML->forTemplate();
  20. } else {
  21. $htmlContent = '';
  22. }
  23.  
  24. $blockSchema['title'] = $this->owner->Title;
  25. $blockSchema['content'] = $htmlContent;
  26. $blockSchema['showTitle'] = $this->owner->ShowTitle;
  27. }
  28. }
(1) 🤔 (1)