Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
[TASK] Release 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
romm committed Feb 15, 2017
2 parents 3395f48 + 528f5b1 commit 940fa6e
Show file tree
Hide file tree
Showing 98 changed files with 4,177 additions and 1,540 deletions.
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ matrix:
include:
- env: TYPO3_VERSION=^7.6 COVERAGE=1
php: 7.0
# TYPO3 v8 requires PHP v7+
- env: TYPO3_VERSION=^8.6 COVERAGE=0
php: 7.0
exclude:
# We must exclude TYPO3 6.2 with PHP 7, because the build just doesn't work (have no clue why).
- env: TYPO3_VERSION=^6.2 COVERAGE=0
Expand Down Expand Up @@ -44,17 +47,22 @@ before_script:
- mkdir -p build/logs

script:
- >
PHPUNIT_CONFIG_FILE="phpunit.xml.dist";
if [[ "$TYPO3_VERSION" != "^8.6" ]]; then
PHPUNIT_CONFIG_FILE="phpunit-legacy.xml.dist"
fi
- >
if [[ "$COVERAGE" == "0" ]]; then
echo;
echo "Running unit tests";
.Build/bin/phpunit --colors Tests/Unit/
.Build/bin/phpunit --configuration $PHPUNIT_CONFIG_FILE --colors Tests/Unit/
fi
- >
if [[ "$COVERAGE" == "1" ]]; then
echo;
echo "Running unit tests with coverage";
.Build/bin/phpunit --colors --coverage-text --coverage-clover build/logs/clover.xml Tests/Unit/
.Build/bin/phpunit --configuration $PHPUNIT_CONFIG_FILE --colors --coverage-text --coverage-clover build/logs/clover.xml Tests/Unit/
fi
after_script:
Expand Down
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# ![Formz](Documentation/Images/formz-icon@medium.png) Formz - Changelog

0.3.3 - 2016-01-25
0.4.0 - 2017-02-15
------------------

Support for TYPO3 8.6 has been added. It means you should now be able to use Formz with TYPO3 6.2/7.6/8.6!

----

- **[[#44](https://github.com/romm/configuration_object/pull/44)] [FEATURE] Introduce TYPO3 8.6 support (#44)**

0.3.3 - 2017-01-25
------------------

This release fixes a PHP warning (which could be thrown as an exception) when working on TYPO3 >= 7.6.13.
Expand All @@ -9,7 +18,7 @@ This release fixes a PHP warning (which could be thrown as an exception) when wo

- **[[5f119e1](https://github.com/romm/formz/commit/5f119e1be9b7510bd79378539ad02d7831cb0b15)] [TASK] Introduce legacy version of `FormViewHelper`**

0.3.2 - 2016-01-24
0.3.2 - 2017-01-24
------------------

This release introduces partial backend support for Formz, meaning you can use Formz in any backend module.
Expand All @@ -24,7 +33,7 @@ The last remaining known issue is ajax calls, which wont work for now.

**[[3cc9886](https://github.com/romm/formz/commit/3cc9886b05a26d524704f91b4f97d45d3501e01a)] [TASK] Add backend support for `TypoScriptUtility` (#36)**

0.3.1 - 2016-01-05
0.3.1 - 2017-01-05
------------------

This release fixes two issues, updating is recommended.
Expand Down
15 changes: 4 additions & 11 deletions Classes/AssetHandler/Connector/AssetHandlerConnectorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Romm\Formz\AssetHandler\AssetHandlerFactory;
use Romm\Formz\Core\Core;
use Romm\Formz\Service\CacheService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down Expand Up @@ -62,16 +63,8 @@ public function __construct(PageRenderer $pageRenderer, AssetHandlerFactory $ass
{
$this->pageRenderer = $pageRenderer;
$this->assetHandlerFactory = $assetHandlerFactory;

/** @noinspection PhpMethodParametersCountMismatchInspection */
$this->cssAssetHandlerConnector = Core::get()
->getObjectManager()
->get(CssAssetHandlerConnector::class, $this);

/** @noinspection PhpMethodParametersCountMismatchInspection */
$this->javaScriptAssetHandlerConnector = Core::get()
->getObjectManager()
->get(JavaScriptAssetHandlerConnector::class, $this);
$this->cssAssetHandlerConnector = Core::instantiate(CssAssetHandlerConnector::class, $this);
$this->javaScriptAssetHandlerConnector = Core::instantiate(JavaScriptAssetHandlerConnector::class, $this);
}

/**
Expand Down Expand Up @@ -125,7 +118,7 @@ public function getFormzGeneratedFilePath($prefix = '')
? $prefix . '-'
: '';

return Core::GENERATED_FILES_PATH . Core::get()->getCacheIdentifier('formz-' . $prefix, $formObject->getClassName() . '-' . $formObject->getName());
return CacheService::GENERATED_FILES_PATH . CacheService::get()->getCacheIdentifier('formz-' . $prefix, $formObject->getClassName() . '-' . $formObject->getName());
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Classes/AssetHandler/Connector/CssAssetHandlerConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Romm\Formz\AssetHandler\Css\ErrorContainerDisplayCssAssetHandler;
use Romm\Formz\AssetHandler\Css\FieldsActivationCssAssetHandler;
use Romm\Formz\Core\Core;
use Romm\Formz\Service\StringService;

class CssAssetHandlerConnector
{
Expand Down Expand Up @@ -51,7 +51,7 @@ public function __construct(AssetHandlerConnectorManager $assetHandlerConnectorM
public function includeDefaultCssFiles()
{
foreach ($this->cssFiles as $file) {
$filePath = Core::get()->getExtensionRelativePath('Resources/Public/StyleSheets/' . $file);
$filePath = StringService::get()->getExtensionRelativePath('Resources/Public/StyleSheets/' . $file);

$this->assetHandlerConnectorManager
->getPageRenderer()
Expand Down Expand Up @@ -96,7 +96,7 @@ function () {

$this->assetHandlerConnectorManager
->getPageRenderer()
->addCssFile(Core::get()->getResourceRelativePath($filePath));
->addCssFile(StringService::get()->getResourceRelativePath($filePath));

return $this;
}
Expand Down
38 changes: 27 additions & 11 deletions Classes/AssetHandler/Connector/JavaScriptAssetHandlerConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
use Romm\Formz\Condition\Processor\ConditionProcessorFactory;
use Romm\Formz\Core\Core;
use Romm\Formz\Form\FormObject;
use Romm\Formz\Service\ContextService;
use Romm\Formz\Service\ExtensionService;
use Romm\Formz\Service\StringService;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Service\EnvironmentService;

class JavaScriptAssetHandlerConnector
{
Expand Down Expand Up @@ -56,6 +60,10 @@ class JavaScriptAssetHandlerConnector
*/
private $assetHandlerConnectorManager;

/**
* @var EnvironmentService
*/
protected $environmentService;
/**
* @param AssetHandlerConnectorManager $assetHandlerConnectorManager
*/
Expand All @@ -73,12 +81,12 @@ public function __construct(AssetHandlerConnectorManager $assetHandlerConnectorM
*/
public function includeDefaultJavaScriptFiles()
{
if (Core::get()->isInDebugMode()) {
if (ExtensionService::get()->isInDebugMode()) {
$this->javaScriptFiles[] = 'Formz.Debug.js';
}

foreach ($this->javaScriptFiles as $file) {
$filePath = Core::get()->getExtensionRelativePath('Resources/Public/JavaScript/' . $file);
$filePath = StringService::get()->getExtensionRelativePath('Resources/Public/JavaScript/' . $file);

$this->includeJsFile($filePath);
}
Expand All @@ -97,7 +105,7 @@ public function includeDefaultJavaScriptFiles()
*/
public function includeLanguageJavaScriptFiles()
{
$filePath = $this->assetHandlerConnectorManager->getFormzGeneratedFilePath('local-' . Core::get()->getLanguageKey()) . '.js';
$filePath = $this->assetHandlerConnectorManager->getFormzGeneratedFilePath('local-' . ContextService::get()->getLanguageKey()) . '.js';

$this->assetHandlerConnectorManager->createFileInTemporaryDirectory(
$filePath,
Expand All @@ -108,7 +116,7 @@ function () {
}
);

$this->includeJsFile(Core::get()->getResourceRelativePath($filePath));
$this->includeJsFile(StringService::get()->getResourceRelativePath($filePath));

return $this;
}
Expand All @@ -132,7 +140,7 @@ function () use ($formzConfigurationJavaScriptAssetHandler) {
}
);

$this->includeJsFile(Core::get()->getResourceRelativePath($fileName));
$this->includeJsFile(StringService::get()->getResourceRelativePath($fileName));

return $this;
}
Expand Down Expand Up @@ -169,7 +177,7 @@ function () {
}
);

$this->includeJsFile(Core::get()->getResourceRelativePath($filePath));
$this->includeJsFile(StringService::get()->getResourceRelativePath($filePath));

return $this;
}
Expand All @@ -192,7 +200,7 @@ public function generateAndIncludeInlineJavaScript()
$javaScriptCode = $this->getFormRequestDataJavaScriptAssetHandler()
->getFormRequestDataJavaScriptCode();

if (Core::get()->isInDebugMode()) {
if (ExtensionService::get()->isInDebugMode()) {
$javaScriptCode .= LF . $this->getDebugActivationCode();
}

Expand Down Expand Up @@ -221,7 +229,7 @@ public function includeJavaScriptValidationAndConditionFiles()
foreach ($javaScriptValidationFiles as $file) {
if (false === in_array($file, $assetHandlerConnectorStates->getAlreadyIncludedValidationJavaScriptFiles())) {
$assetHandlerConnectorStates->registerIncludedValidationJavaScriptFiles($file);
$this->includeJsFile(Core::get()->getResourceRelativePath($file));
$this->includeJsFile(StringService::get()->getResourceRelativePath($file));
}
}

Expand Down Expand Up @@ -263,7 +271,7 @@ protected function includeJsFile($path)
{
$pageRenderer = $this->assetHandlerConnectorManager->getPageRenderer();

if (Core::get()->getEnvironmentService()->isEnvironmentInFrontendMode()) {
if ($this->environmentService->isEnvironmentInFrontendMode()) {
$pageRenderer->addJsFooterFile($path);
} else {
$pageRenderer->addJsFile($path);
Expand All @@ -280,7 +288,7 @@ protected function addInlineJs($name, $javaScriptCode)
{
$pageRenderer = $this->assetHandlerConnectorManager->getPageRenderer();

if (Core::get()->getEnvironmentService()->isEnvironmentInFrontendMode()) {
if ($this->environmentService->isEnvironmentInFrontendMode()) {
$pageRenderer->addJsFooterInlineCode($name, $javaScriptCode);
} else {
$pageRenderer->addJsInlineCode($name, $javaScriptCode);
Expand All @@ -293,7 +301,7 @@ protected function addInlineJs($name, $javaScriptCode)
protected function getAjaxUrl()
{
/** @var UriBuilder $uriBuilder */
$uriBuilder = Core::get()->getObjectManager()->get(UriBuilder::class);
$uriBuilder = Core::instantiate(UriBuilder::class);

return $uriBuilder->reset()
->setTargetPageType(1473682545)
Expand Down Expand Up @@ -390,4 +398,12 @@ protected function getFormzLocalizationJavaScriptAssetHandler()
->getAssetHandlerFactory()
->getAssetHandler(FormzLocalizationJavaScriptAssetHandler::class);
}

/**
* @param EnvironmentService $environmentService
*/
public function injectEnvironmentService(EnvironmentService $environmentService)
{
$this->environmentService = $environmentService;
}
}
39 changes: 23 additions & 16 deletions Classes/AssetHandler/Html/DataAttributesAssetHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
namespace Romm\Formz\AssetHandler\Html;

use Romm\Formz\AssetHandler\AbstractAssetHandler;
use Romm\Formz\Core\Core;
use Romm\Formz\Error\FormResult;
use Romm\Formz\Form\FormInterface;
use TYPO3\CMS\Extbase\Error\Error;
use Romm\Formz\Service\MessageService;
use Romm\Formz\Service\StringService;
use TYPO3\CMS\Extbase\Error\Result;
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;

Expand Down Expand Up @@ -117,11 +117,10 @@ public function getFieldsErrorsDataAttributes(FormResult $requestResult)
$result[self::getFieldDataErrorKey($fieldName)] = '1';

foreach ($fieldResult->getErrors() as $error) {
/** @var Error $error */
$errorTitle = ($error->getTitle())
? $error->getTitle()
: 'default';
$result[self::getFieldDataValidationErrorKey($fieldName, $errorTitle)] = '1';
$validationName = MessageService::get()->getMessageValidationName($error);
$messageKey = MessageService::get()->getMessageKey($error);

$result[self::getFieldDataValidationErrorKey($fieldName, $validationName, $messageKey)] = '1';
}
}
}
Expand Down Expand Up @@ -164,7 +163,7 @@ public function getFieldsValidDataAttributes(FormResult $requestResult)
*/
public static function getFieldDataValueKey($fieldName)
{
return 'formz-value-' . Core::get()->sanitizeString($fieldName);
return 'formz-value-' . StringService::get()->sanitizeString($fieldName);
}

/**
Expand All @@ -175,7 +174,7 @@ public static function getFieldDataValueKey($fieldName)
*/
public static function getFieldDataValidKey($fieldName)
{
return 'formz-valid-' . Core::get()->sanitizeString($fieldName);
return 'formz-valid-' . StringService::get()->sanitizeString($fieldName);
}

/**
Expand All @@ -186,21 +185,29 @@ public static function getFieldDataValidKey($fieldName)
*/
public static function getFieldDataErrorKey($fieldName)
{
return 'formz-error-' . Core::get()->sanitizeString($fieldName);
return 'formz-error-' . StringService::get()->sanitizeString($fieldName);
}

/**
* Formats the data error attribute key for a given failed validation for
* the given field name.
*
* @param string $fieldName Name of the field.
* @param string $errorTitle Title of the error.
* @param string $fieldName
* @param string $validationName
* @param string $messageKey
* @return string
*/
public static function getFieldDataValidationErrorKey($fieldName, $errorTitle)
public static function getFieldDataValidationErrorKey($fieldName, $validationName, $messageKey)
{
$core = Core::get();

return 'formz-error-' . $core->sanitizeString($fieldName) . '-' . $core->sanitizeString(str_replace(':', '-', $errorTitle));
$stringService = StringService::get();

return vsprintf(
'formz-error-%s-%s-%s',
[
$stringService->sanitizeString($fieldName),
$stringService->sanitizeString($validationName),
$stringService->sanitizeString($messageKey)
]
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Romm\Formz\Configuration\Form\Field\Field;
use Romm\Formz\Configuration\Form\Field\Validation\Validation;
use Romm\Formz\Core\Core;
use Romm\Formz\Service\ArrayService;
use Romm\Formz\Validation\Validator\AbstractValidator;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down Expand Up @@ -156,7 +156,7 @@ protected function getValidationConfiguration(Field $field, $validationName, Val

$messages = $formzLocalizationJavaScriptAssetHandler->getTranslationKeysForFieldValidation($field, $validationName);

return Core::get()->arrayToJavaScriptJson([
return ArrayService::get()->arrayToJavaScriptJson([
'options' => $validatorConfiguration->getOptions(),
'messages' => $messages,
'settings' => $validatorConfiguration->toArray(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Romm\Formz\AssetHandler\JavaScript;

use Romm\Formz\Core\Core;
use Romm\Formz\Service\ArrayService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down Expand Up @@ -64,7 +64,7 @@ protected function getFormConfiguration()
$this->removeFieldsValidationConfiguration($formConfigurationArray)
->addClassNameProperty($formConfigurationArray);

return Core::get()->arrayToJavaScriptJson($formConfigurationArray);
return ArrayService::get()->arrayToJavaScriptJson($formConfigurationArray);
}

/**
Expand Down

0 comments on commit 940fa6e

Please sign in to comment.