Skip to content

Commit

Permalink
Neos 8 Compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed Oct 5, 2022
1 parent 8476669 commit 1d3f691
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 79 deletions.
30 changes: 11 additions & 19 deletions Classes/Controller/AjaxFormController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

namespace Onedrop\AjaxForm\Controller;

/* *
Expand All @@ -7,41 +10,30 @@
* */

use Neos\Flow\Annotations as Flow;
use Neos\Flow\I18n\Exception\InvalidLocaleIdentifierException;
use Neos\Flow\I18n\Locale;
use Neos\Flow\I18n\Service;
use Neos\Flow\Mvc\Controller\ActionController;
use Neos\Flow\Security\Context;

class AjaxFormController extends ActionController
{
/**
* @Flow\Inject
* @var Context
*/
protected $securityContext;
protected Context $securityContext;

/**
* @Flow\Inject
* @var \Neos\Flow\I18n\Service
*/
protected $i18nService;

/**
* Injects the Security Context
*
* @param Context $securityContext
* @return void
* @var Service
*/
public function injectSecurityContext(Context $securityContext)
{
$this->securityContext = $securityContext;
}
protected Service $i18nService;

/**
* @param string $formIdentifier
* @param string $presetName
* @param string $locale
* @throws \Neos\Flow\I18n\Exception\InvalidLocaleIdentifierException
* @throws InvalidLocaleIdentifierException
*/
public function indexAction($formIdentifier, $presetName, $locale = '')
public function indexAction(string $formIdentifier, string $presetName, string $locale = ''): void
{
if (!empty($locale)) {
$currentLocale = new Locale($locale);
Expand Down
23 changes: 23 additions & 0 deletions Resources/Private/Fusion/Content/Form.fusion
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
prototype(Onedrop.AjaxForm:Form) < prototype(Neos.NodeTypes.Form:Form) {
sectionName = 'Content'
templatePath = 'resource://Onedrop.AjaxForm/Private/Templates/NodeTypes/AjaxForm.html'

@context.formIdentifier = ${this.formIdentifier}
@context.locale = ${node.context.dimensions.language[0]}
@context.presetName = ${this.presetName}

formWrapperAttributes = Neos.Fusion:Attributes {
data-ajax = 'ajax-form'
data-ajax-uri = Neos.Fusion:UriBuilder {
package = 'Onedrop.AjaxForm'
controller = 'AjaxForm'
action = 'index'
format = 'html'
arguments {
locale = ${locale}
formIdentifier = ${formIdentifier}
presetName = ${presetName}
}
}
}
}
12 changes: 12 additions & 0 deletions Resources/Private/Fusion/Override/Page.fusion
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prototype(Neos.Neos:Page) {
body.javascripts.ajaxForms = Neos.Fusion:Tag {
@position = '5100'
tagName = 'script'
attributes {
src = Neos.Fusion:ResourceUri {
path = 'resource://Onedrop.AjaxForm/Public/JavaScript/form.js'
}
}
@if.hasFormAndIsLiveAndActive = ${q(node).children('[instanceof Neos.Neos:ContentCollection]').find('[instanceof Onedrop.AjaxForm:Form]').is() && node.context.live && Configuration.setting('Onedrop.AjaxForm.includeJavascript')}
}
}
40 changes: 4 additions & 36 deletions Resources/Private/Fusion/Root.fusion
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
prototype(Onedrop.AjaxForm:Form) < prototype(Neos.NodeTypes.Form:Form) {
sectionName = 'Content'
templatePath = 'resource://Onedrop.AjaxForm/Private/Templates/NodeTypes/AjaxForm.html'

@context.formIdentifier = ${this.formIdentifier}
@context.locale = ${node.context.dimensions.language[0]}
@context.presetName = ${this.presetName}

formWrapperAttributes = Neos.Fusion:Attributes {
data-ajax = 'ajax-form'
data-ajax-uri = Neos.Fusion:UriBuilder {
package = 'Onedrop.AjaxForm'
controller = 'AjaxForm'
action = 'index'
format = 'html'
arguments {
locale = ${locale}
formIdentifier = ${formIdentifier}
presetName = ${presetName}
}
}
}
}

prototype(Neos.Neos:Page) {
body.javascripts.ajaxForms = Neos.Fusion:Tag {
@position = '5100'
tagName = 'script'
attributes {
src = Neos.Fusion:ResourceUri {
path = 'resource://Onedrop.AjaxForm/Public/JavaScript/form.js'
}
}
@if.hasFormAndIsLiveAndActive = ${q(node).children('[instanceof Neos.Neos:ContentCollection]').find('[instanceof Onedrop.AjaxForm:Form]').is() && node.context.live && Configuration.setting('Onedrop.AjaxForm.includeJavascript')}
}
}
/**
* Root Fusion for the Onedrop.AjaxForm package
*/
include: ./**/*.fusion
6 changes: 4 additions & 2 deletions Resources/Private/Templates/AjaxForm/Index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3Fluid/Fluid/ViewHelpers"
xmlns:form="http://typo3.org/ns/Neos/Form/ViewHelpers">
xmlns:form="http://typo3.org/ns/Neos/Form/ViewHelpers"
data-namespace-typo3-fluid="true"
>

<f:layout name="Default" />

Expand All @@ -11,7 +13,7 @@
<form:render persistenceIdentifier="{formIdentifier}" presetName="{presetName}"/>
</f:then>
<f:else>
<p>{f:translate(id: 'content.noValidFormIdentifier', package: 'Neos.NodeTypes', source: 'NodeTypes/Form')}</p>
<p><f:translate id="content.noValidFormIdentifier" package="Neos.NodeTypes" source="NodeTypes/Form"/></p>
</f:else>
</f:if>
</f:section>
Expand Down
36 changes: 20 additions & 16 deletions Resources/Private/Translations/de/NodeTypes/Form.xlf
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file original="" product-name="Onedrop.AjaxForm" source-language="en" datatype="plaintext" target-language="de">
<body>
<trans-unit id="ui.label" xml:space="preserve" approved="yes">
<source>Ajax Form</source>
<target xml:lang="de">Ajax Formular</target></trans-unit>
<trans-unit id="groups.form" xml:space="preserve" approved="yes">
<source>Form</source>
<target xml:lang="de">Formular</target></trans-unit>
<trans-unit id="properties.formIdentifier" xml:space="preserve" approved="yes">
<source>Form Identifier</source>
<target xml:lang="de">Formular-ID</target></trans-unit>
<trans-unit id="properties.formIdentifier.selectBoxEditor.placeholder" xml:space="preserve" approved="yes">
<source>Select the Form identifier</source>
<target xml:lang="de">Formular-ID auswählen</target></trans-unit>
</body>
</file>
<file original="" product-name="Onedrop.AjaxForm" source-language="en" datatype="plaintext" target-language="de">
<body>
<trans-unit id="ui.label" approved="yes">
<source>Ajax Form</source>
<target xml:lang="de">Ajax Formular</target>
</trans-unit>
<trans-unit id="groups.form" approved="yes">
<source>Form</source>
<target xml:lang="de">Formular</target>
</trans-unit>
<trans-unit id="properties.formIdentifier" approved="yes">
<source>Form Identifier</source>
<target xml:lang="de">Formular-ID</target>
</trans-unit>
<trans-unit id="properties.formIdentifier.selectBoxEditor.placeholder" approved="yes">
<source>Select the Form identifier</source>
<target xml:lang="de">Formular-ID auswählen</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 4 additions & 4 deletions Resources/Private/Translations/en/NodeTypes/Form.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file original="" product-name="Onedrop.AjaxForm" source-language="en" datatype="plaintext">
<body>
<trans-unit id="ui.label" xml:space="preserve">
<trans-unit id="ui.label">
<source>Ajax Form</source>
</trans-unit>
<trans-unit id="groups.form" xml:space="preserve">
<trans-unit id="groups.form">
<source>Form</source>
</trans-unit>
<trans-unit id="properties.formIdentifier" xml:space="preserve">
<trans-unit id="properties.formIdentifier">
<source>Form Identifier</source>
</trans-unit>
<trans-unit id="properties.formIdentifier.selectBoxEditor.placeholder" xml:space="preserve">
<trans-unit id="properties.formIdentifier.selectBoxEditor.placeholder">
<source>Select the Form identifier</source>
</trans-unit>
</body>
Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"MIT"
],
"require": {
"neos/neos": "~3.0 || ^4.0 || ^5.0 || ^7.0",
"neos/nodetypes-form": "~3.0 || ^4.0 || ^5.0 || ^7.0"
"neos/neos": "~3.0 || ^4.0 || ^5.0 || ^7.0 || ^8.0",
"neos/nodetypes-form": "~3.0 || ^4.0 || ^5.0 || ^7.0 || ^8.0"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -93,5 +93,10 @@
"Neos.Neos-20180907103800",
"Neos.Neos.Ui-20190319094900"
]
},
"config": {
"allow-plugins": {
"neos/composer-plugin": true
}
}
}

0 comments on commit 1d3f691

Please sign in to comment.