Skip to content

Commit

Permalink
Merge branch 'feature/flow6-compatibility'
Browse files Browse the repository at this point in the history
# Conflicts:
#	Classes/Controller/DummyImageController.php
#	composer.json
  • Loading branch information
mficzel committed Sep 23, 2019
2 parents 7f38139 + d3911a0 commit bbc1325
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions Classes/Controller/DummyImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Sitegeist\Kaleidoscope\Controller;

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Package\PackageManagerInterface;
use Neos\Flow\Package\PackageManager;
use Neos\Flow\ResourceManagement\ResourceManager;
use Neos\Flow\Mvc\Controller\ActionController;

Expand All @@ -12,6 +12,7 @@
use Imagine\Image\Palette;
use Imagine\Image\Box;
use Imagine\Image\Point;
use Neos\Flow\Http\Component\SetHeaderComponent;

class DummyImageController extends ActionController
{
Expand All @@ -28,7 +29,7 @@ class DummyImageController extends ActionController
protected $resourceManager;

/**
* @var PackageManagerInterface
* @var PackageManager
* @Flow\Inject
*/
protected $packageManager;
Expand Down Expand Up @@ -115,15 +116,15 @@ public function imageAction (int $w = 600, int $h = 400, string $bg = '#000', st
if (!$result) {
throw new \Exception('Something went wrong without throwing an exception');
}

// build result
$this->response->setHeader('Cache-Control', 'max-age=883000000');
$this->response->setHeader('Content-type', 'image/' . $f);
$this->response->setComponentParameter(SetHeaderComponent::class, 'Cache-Control', 'max-age=883000000');
$this->response->setComponentParameter(SetHeaderComponent::class, 'Content-type', 'image/' . $f);
return $result;
} catch (\Exception $e) {
// something went wrong we return the error image png
$this->response->setStatusCode(500);
$this->response->setHeader('Content-type', 'image/png');
$this->response->setComponentParameter(SetHeaderComponent::class, 'Content-type', 'image/png');
return file_get_contents('resource://Sitegeist.Kaleidoscope/Public/Images/imageError.png');
}
}
Expand Down Expand Up @@ -251,8 +252,13 @@ protected function renderBorder(ImageInterface $image, ColorInterface $foregroun
protected function renderText(ImageInterface $image, ColorInterface $textColor, int $width, int $height, string $text, $center = false): void
{
$initialFontSize = 10;
$fontFile = $this->packageManager->getPackage('Neos.Neos')->getPackagePath() . "Resources/Public/Fonts/NotoSans/NotoSans-Regular.ttf";
$initialFont = $this->imagineService->font($fontFile, $initialFontSize, $textColor);
if (file_exists('resource://Neos.Neos/Public/Fonts/NotoSans/NotoSans-Regular.ttf')) {
$fontFile = $this->packageManager->getPackage('Neos.Neos')->getPackagePath() . "Resources/Public/Fonts/NotoSans/NotoSans-Regular.ttf";
$initialFont = $this->imagineService->font($fontFile, $initialFontSize, $textColor);
} elseif (file_exists('resource://Neos.Neos/Public/Fonts/NotoSans-Regular.ttf')) {
$fontFile = $this->packageManager->getPackage('Neos.Neos')->getPackagePath() . "Resources/Public/Fonts/NotoSans-Regular.ttf";
$initialFont = $this->imagineService->font($fontFile, $initialFontSize, $textColor);
}

// scale text to fit the image
$initialFontBox = $initialFont->box($text);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "sitegeist/kaleidoscope",
"license": "GPL-3.0-or-later",
"require": {
"neos/neos": "^4.3 || dev-master",
"neos/neos": "^5.0 || dev-master",
"neos/fusion-afx": "^1.2 || dev-master",
"neos/media": "*",
"neos/imagine": "*"
Expand Down

0 comments on commit bbc1325

Please sign in to comment.