Skip to content

Commit

Permalink
[TASK] Extension creation
Browse files Browse the repository at this point in the history
  • Loading branch information
filoucrackeur committed May 10, 2019
1 parent 3db309a commit 4f4bbca
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 63 deletions.
48 changes: 37 additions & 11 deletions .travis.yml
@@ -1,25 +1,51 @@
language: php

php:
- 7.2
- 7.3
matrix:
fast_finish: true
include:
- env: TYPO3_VERSION=^9.5 COVERAGE=1
php: 7.2
- env: TYPO3_VERSION=^9.5 COVERAGE=1
php: 7.3

sudo: true

sudo: false

addons:
apt:
packages:
- parallel

cache:
directories:
- $HOME/.composer/cache

before_install:
- composer self-update
- composer --version

before_script:
- Build/Scripts/runTests.sh -s composerInstall -p $TRAVIS_PHP_VERSION
- composer require typo3/minimal=$TYPO3_VERSION
- git checkout composer.json
- export TYPO3_PATH_WEB=$PWD/.Build/Web
- mkdir -p build/logs

script:
- >
echo "Running composer validate"
Build/Scripts/runTests.sh -s composerValidate -p $TRAVIS_PHP_VERSION
if [[ "$COVERAGE" == "0" ]]; then
echo;
echo "Running unit tests";
.Build/bin/phpunit --configuration phpunit.xml.dist --colors Tests/Unit/
fi
- >
echo "Running unit tests";
Build/Scripts/runTests.sh -s unit -p $TRAVIS_PHP_VERSION
if [[ "$COVERAGE" == "1" ]]; then
echo;
echo "Running unit tests with coverage";
.Build/bin/phpunit --configuration phpunit.xml.dist --colors --coverage-text --coverage-clover build/logs/clover.xml Tests/Unit/
fi
after_script:
- >
echo "Running php lint";
Build/Scripts/runTests.sh -s lint -p $TRAVIS_PHP_VERSION
if [[ "$COVERAGE" == "1" ]]; then
travis_retry php .Build/bin/coveralls -v
fi
33 changes: 2 additions & 31 deletions Classes/Controller/Backend/StorageFrameworkManagerController.php
Expand Up @@ -81,6 +81,7 @@ public function session(ServerRequestInterface $request): ResponseInterface
* @param ServerRequestInterface $request
* @return ResponseInterface
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException
*/
public function core(ServerRequestInterface $request): ResponseInterface
{
Expand All @@ -102,6 +103,7 @@ public function core(ServerRequestInterface $request): ResponseInterface
* @param ServerRequestInterface $request
* @return ResponseInterface
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException
*/
public function extensions(ServerRequestInterface $request): ResponseInterface
{
Expand All @@ -118,37 +120,6 @@ public function extensions(ServerRequestInterface $request): ResponseInterface
]);
}


/**
* @param ServerRequestInterface $request
* @return ResponseInterface
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public function backend(ServerRequestInterface $request): ResponseInterface
{

$backend = GeneralUtility::makeInstance(CacheManagerService::class)
->getSessionBackendByIdentifier('BE');
// ->getCacheBackendByIdentifier('cache_pages');

try {
$backend->getBackend()->validateConfiguration();
} catch (\Exception $e) {
var_dump($e);
}
die;

return new JsonResponse([
'success' => true,
'backend' => [
'identifier' => $backend->getIdentifier(),
'type' => $backend->getType(),
'status' => $backend->getStatus(),
'configuration' => $backend->getConfiguration(),
],
]);
}

/**
* @param CacheManagerService $cacheManagerService
*/
Expand Down
2 changes: 1 addition & 1 deletion Classes/Type/Backend/Session.php
Expand Up @@ -14,7 +14,7 @@ class Session extends Enumeration
/**
* @return bool
*/
public function isFrontent(): bool
public function isFrontend(): bool
{
return $this->equals(self::FE);
}
Expand Down
4 changes: 4 additions & 0 deletions Classes/Utility/TreeUtility.php
Expand Up @@ -11,6 +11,10 @@ class TreeUtility
*/
public static function fromArray(array $array): string
{
if (empty($array)) {
return '';
}

$output = '<ul class="list-tree text-monospace">';

foreach ($array as $key => $value) {
Expand Down
14 changes: 4 additions & 10 deletions Classes/ViewHelpers/ConfigurationViewHelper.php
Expand Up @@ -3,7 +3,6 @@

namespace Filoucrackeur\StorageFrameworkManager\ViewHelpers;

use Exception;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

class ConfigurationViewHelper extends AbstractViewHelper
Expand All @@ -30,18 +29,13 @@ public function initializeArguments()
}

/**
* @return mixed
* @throws Exception
* @return array|null
*/
public function render()
public function render(): ?array
{
if (!isset($this->arguments['type']) || null === $this->arguments['type']) {
throw new \RuntimeException('type must be string with value session or cache');
}

if ($this->arguments['type'] === 'cache') {

if (isset($this->arguments['identifier']) && null !== $this->arguments['identifier']) {
if (isset($this->arguments['identifier']) && '' !== $this->arguments['identifier']) {
return $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$this->arguments['identifier']];
}

Expand All @@ -50,7 +44,7 @@ public function render()

if ($this->arguments['type'] === 'session') {

if (isset($this->arguments['identifier']) && null !== $this->arguments['identifier']) {
if (isset($this->arguments['identifier']) && '' !== $this->arguments['identifier']) {
return $GLOBALS['TYPO3_CONF_VARS']['SYS']['session'][$this->arguments['identifier']];
}

Expand Down
2 changes: 0 additions & 2 deletions Classes/ViewHelpers/TreeViewHelper.php
Expand Up @@ -3,7 +3,6 @@

namespace Filoucrackeur\StorageFrameworkManager\ViewHelpers;

use Exception;
use Filoucrackeur\StorageFrameworkManager\Utility\TreeUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

Expand Down Expand Up @@ -32,7 +31,6 @@ public function initializeArguments()

/**
* @return string
* @throws Exception
*/
public function render(): string
{
Expand Down
4 changes: 0 additions & 4 deletions Configuration/Backend/AjaxRoutes.php
Expand Up @@ -20,8 +20,4 @@
'path' => '/storage-framework-manager/show',
'target' => Backend\StorageFrameworkManagerController::class . '::show'
],
'backend' => [
'path' => '/storage-framework-manager/backend',
'target' => Backend\StorageFrameworkManagerController::class . '::backend'
],
];
4 changes: 0 additions & 4 deletions Configuration/Backend/Routes.php
Expand Up @@ -20,8 +20,4 @@
'path' => '/storage-framework-manager/show',
'target' => Backend\StorageFrameworkManagerController::class . '::show'
],
'backend' => [
'path' => '/storage-framework-manager/backend',
'target' => Backend\StorageFrameworkManagerController::class . '::backend'
],
];
@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);

namespace Filoucrackeur\StorageFrameworkManager\Tests\Controller\Backend;

use Nimut\TestingFramework\TestCase\UnitTestCase;

class StorageFrameworkManagerControllerTest extends UnitTestCase
{

}

0 comments on commit 4f4bbca

Please sign in to comment.