-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add inheritance mode control
Adds an extension configuration option and corresponding Form option and option ViewHelper which allows a site to control how Flux handles inheritance of FlexForm values (specific to pages). Normally, Flux will only allow FlexForm values to be inherited from a parent page to children if the child uses the same page layout (template) as the parent page(s). This new option allows changing this inheritance mode from the default "restricted" to an "unrestricted" mode which allows FlexForm values to be inherited even if the child and parent uses different page layouts. This is useful when you have different page templates which use the same FlexForm fields (for example, a shared set of fields) and you wish to inherit such fields from parents even if you use different page layouts on the child/parent(s). There is a similar Form option which allows setting this inheritance mode on a per-template basis. Use the new ViewHelper flux:form.option.inheritanceMode for this, with either "restricted" or "unrestricted" as value. If no mode is specified on a template then the inheritance mode defined in extension configuration will be used.
- Loading branch information
1 parent
37cd93a
commit 871fcf5
Showing
10 changed files
with
189 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
Classes/ViewHelpers/Form/Option/InheritanceModeViewHelper.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace FluidTYPO3\Flux\ViewHelpers\Form\Option; | ||
|
||
/* | ||
* This file is part of the FluidTYPO3/Flux project under GPLv2 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.md file that was distributed with this source code. | ||
*/ | ||
|
||
use FluidTYPO3\Flux\Enum\FormOption; | ||
use FluidTYPO3\Flux\ViewHelpers\Form\OptionViewHelper; | ||
|
||
/** | ||
* ### Inheritance mode option | ||
* | ||
* Control how this Form will handle inheritance (page context only). | ||
* There are two possible values of this option: | ||
* | ||
* - restricted | ||
* - unrestricted | ||
* | ||
* Note that the default (the mode which is used if you do NOT specify | ||
* the mode with this ViewHelper/option) is defined by the Flux extension | ||
* configuration. If you do not change the extension configuration then | ||
* the default behavior is "restricted". Any template that wants to use | ||
* a mode other than the default *MUST* specify the mode with this option. | ||
* | ||
* When the option is set to "restricted" either by this ViewHelper or | ||
* by extension configuration, the inheritance behavior matches the | ||
* Flux behavior pre version 10.1.x, meaning that inheritance will only | ||
* happen if the parent (page) has selected the same Form (layout) as | ||
* the current page. As soon as a different Form is encountered in a | ||
* parent, the inheritance stops. In short: inheritance only works for | ||
* identical Forms. | ||
* | ||
* Alternatively, when the option is set to "unrestricted", the above | ||
* constraint is removed and inheritance can happen for Forms which are | ||
* NOT the same. | ||
* | ||
* This makes sense to use if you have different page templates which | ||
* use the same values (for example a shared set of fields) and you want | ||
* child pages to be able to inherit these values from parents even if | ||
* the child page has selected a different page layout. | ||
* | ||
* #### Example | ||
* | ||
* <flux:form.option.inheritanceMode value="unrestricted" /> | ||
* (which is the same as:) | ||
* <flux:form.option.inheritanceMode>unrestricted</flux:form.option.inheritanceMode> | ||
* | ||
* Or: | ||
* | ||
* <flux:form.option.inheritanceMode value="restricted" /> | ||
* (which is the same as:) | ||
* <flux:form.option.inheritanceMode>restricted</flux:form.option.inheritanceMode> | ||
*/ | ||
class InheritanceModeViewHelper extends OptionViewHelper | ||
{ | ||
public static string $option = FormOption::INHERITANCE_MODE; | ||
|
||
public function initializeArguments(): void | ||
{ | ||
$this->registerArgument('value', 'string', 'Mode of inheritance, either "restricted" or "unrestricted".'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Tests/Unit/ViewHelpers/Form/Option/InheritanceModeViewHelperTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
namespace FluidTYPO3\Flux\Tests\Unit\ViewHelpers\Form\Option; | ||
|
||
/* | ||
* This file is part of the FluidTYPO3/Flux project under GPLv2 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.md file that was distributed with this source code. | ||
*/ | ||
|
||
use FluidTYPO3\Flux\Tests\Unit\ViewHelpers\AbstractFormViewHelperTestCase; | ||
|
||
class InheritanceModeViewHelperTest extends AbstractFormViewHelperTestCase | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters