Skip to content

Commit

Permalink
TASK: Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellienert committed Apr 18, 2019
1 parent 23ecb53 commit c6461b1
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 23 deletions.
7 changes: 2 additions & 5 deletions Classes/DataSources/AssetCollectionDataSource.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace DL\Gallery\DataSources;

Expand Down Expand Up @@ -28,21 +29,18 @@ class AssetCollectionDataSource extends AbstractDataSource
*/
static protected $identifier = 'dl-gallery-assetcollections';


/**
* @Flow\Inject
* @var PersistenceManagerInterface
*/
protected $persistenceManager;


/**
* @Flow\Inject
* @var AssetCollectionRepository
*/
protected $assetCollectionRepository;


/**
* @param NodeInterface $node
* @param array $arguments
Expand All @@ -65,5 +63,4 @@ public function getData(NodeInterface $node = null, array $arguments)

return $options;
}

}
}
20 changes: 11 additions & 9 deletions Classes/DataSources/TagDataSource.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

namespace DL\Gallery\DataSources;

/*
Expand All @@ -11,6 +13,10 @@
* source code.
*/

use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Flow\Persistence\QueryResultInterface;
use Neos\Media\Domain\Model\Tag;
use Neos\Media\Domain\Repository\TagRepository;
use Neos\Neos\Service\DataSource\AbstractDataSource;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Flow\Annotations as Flow;
Expand All @@ -23,37 +29,33 @@ class TagDataSource extends AbstractDataSource
*/
static protected $identifier = 'dl-gallery-tags';


/**
* @Flow\Inject
* @var \Neos\Flow\Persistence\PersistenceManagerInterface
* @var PersistenceManagerInterface
*/
protected $persistenceManager;


/**
* @Flow\inject
* @var \Neos\Media\Domain\Repository\TagRepository
* @var TagRepository
*/
protected $tagRepository;


/**
* @param NodeInterface|null $node
* @param array $arguments
* @return \Neos\Flow\Persistence\QueryResultInterface
* @return QueryResultInterface
*/
public function getData(NodeInterface $node = null, array $arguments)
{
$tagCollection = $this->tagRepository->findAll();
$tags['']['label'] = '-';

foreach ($tagCollection as $tag) {
/** @var \Neos\Media\Domain\Model\Tag $tag */
/** @var Tag $tag */
$tags[$this->persistenceManager->getIdentifierByObject($tag)] = $tag;
}

return $tags;
}

}
}
4 changes: 3 additions & 1 deletion Classes/DataSources/ThemeDataSource.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

namespace DL\Gallery\DataSources;

/*
Expand Down Expand Up @@ -56,4 +58,4 @@ public function getData(NodeInterface $node = null, array $arguments)
return $themes;
}

}
}
3 changes: 2 additions & 1 deletion Classes/Exceptions/InvalidConfigurationException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

namespace DL\Gallery\Exceptions;

/*
Expand All @@ -13,5 +15,4 @@

class InvalidConfigurationException extends \Exception
{

}
2 changes: 2 additions & 0 deletions Classes/ViewHelpers/GalleryViewHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

namespace DL\Gallery\ViewHelpers;

/*
Expand Down
19 changes: 13 additions & 6 deletions Classes/ViewHelpers/ImageDataViewHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace DL\Gallery\ViewHelpers;

Expand All @@ -14,9 +15,15 @@

use DL\Gallery\Exceptions\InvalidConfigurationException;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Routing\Exception\MissingActionNameException;
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
use Neos\FluidAdaptor\Core\ViewHelper\Exception;
use Neos\Media\Domain\Model\ImageInterface;
use Neos\Media\Domain\Model\ThumbnailConfiguration;
use Neos\Media\Domain\Service\AssetService;
use Neos\Media\Domain\Service\ThumbnailService;
use Neos\Media\Exception\AssetServiceException;
use Neos\Media\Exception\ThumbnailServiceException;

class ImageDataViewHelper extends AbstractViewHelper
{
Expand All @@ -27,13 +34,13 @@ class ImageDataViewHelper extends AbstractViewHelper

/**
* @Flow\Inject
* @var \Neos\Media\Domain\Service\ThumbnailService
* @var ThumbnailService
*/
protected $thumbnailService;

/**
* @Flow\Inject
* @var \Neos\Media\Domain\Service\AssetService
* @var AssetService
*/
protected $assetService;

Expand All @@ -53,9 +60,9 @@ public function injectSettings(array $settings)
$this->settings = $settings;
}


/**
* @return void
* @throws Exception
*/
public function initializeArguments()
{
Expand All @@ -65,7 +72,6 @@ public function initializeArguments()
$this->registerArgument('key', 'string', 'The key of the meta data array', false);
}


/**
* @param ImageInterface $image
* @param integer $width
Expand All @@ -76,10 +82,12 @@ public function initializeArguments()
* @param bool $allowUpScaling
* @return array|null
* @throws InvalidConfigurationException
* @throws MissingActionNameException
* @throws AssetServiceException
* @throws ThumbnailServiceException
*/
public function render(ImageInterface $image, int $width = 0, int $maximumWidth = 0, int $height = 0, int $maximumHeight = 0, bool $allowCropping = false, bool $allowUpScaling = false)
{

if ($this->hasArgument('theme') && $this->hasArgument('imageVariant')) {
$themeSettings = $this->getSettingsForCurrentTheme($this->arguments['theme']);

Expand Down Expand Up @@ -113,7 +121,6 @@ public function render(ImageInterface $image, int $width = 0, int $maximumWidth
}
}


/**
* @param string $theme
* @return mixed
Expand Down
12 changes: 12 additions & 0 deletions Classes/ViewHelpers/ImageViewHelper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

namespace DL\Gallery\ViewHelpers;

/*
Expand All @@ -12,7 +14,11 @@
*/

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Routing\Exception\MissingActionNameException;
use Neos\FluidAdaptor\Core\ViewHelper\Exception;
use Neos\Media\Domain\Model\ImageInterface;
use Neos\Media\Exception\AssetServiceException;
use Neos\Media\Exception\ThumbnailServiceException;

class ImageViewHelper extends \Neos\Media\ViewHelpers\ImageViewHelper
{
Expand All @@ -32,6 +38,7 @@ public function injectSettings(array $settings)

/**
* @return void
* @throws Exception
*/
public function initializeArguments()
{
Expand All @@ -52,7 +59,12 @@ public function initializeArguments()
* @param boolean $async Return asynchronous image URI in case the requested image does not exist already
* @param string $preset Preset used to determine image configuration
* @param integer $quality Quality of the image
* @param null $format
* @return string an <img...> html tag
*
* @throws MissingActionNameException
* @throws AssetServiceException
* @throws ThumbnailServiceException
*/
public function render(ImageInterface $image = null, $width = null, $maximumWidth = null, $height = null, $maximumHeight = null, $allowCropping = false, $allowUpScaling = false, $async = false, $preset = null, $quality = null, $format = null)
{
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"MIT"
],
"require": {
"neos/neos": ">=3.3.0 < 4.3.0"
"neos/neos": "^4.3"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit c6461b1

Please sign in to comment.