-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add node identifier view helpers
Resolves: #67
- Loading branch information
1 parent
a808828
commit 9c5d3e9
Showing
12 changed files
with
450 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the "schema" extension for TYPO3 CMS. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Brotkrueml\Schema\ViewHelpers; | ||
|
||
use Brotkrueml\Schema\Core\Model\BlankNodeIdentifier; | ||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
|
||
/** | ||
* ViewHelper for creating a BlankNodeIdentifier. | ||
* Best way it is to assign the value to a variable to use | ||
* it multiple times. You can use that variable to | ||
* assign it to the "-id" property of a type view helper. | ||
* The view helper has no arguments. | ||
* | ||
* = Example = | ||
* <code title="Using the view helper"> | ||
* <f:variable name="blankIdentifier1" value="{schema:blankNodeIdentifier()}"/> | ||
* <f:variable name="blankIdentifier2" value="{schema:blankNodeIdentifier()}"/> | ||
* <schema:type.person name="John Smith" -id="{blankIdentifier1}" knows="{blankIdentifier2}"/> | ||
* <schema:type.person name="Sarah Jane Smith" -id="{blankIdentifier2}" knows="{blankIdentifier1}"/> | ||
* </code> | ||
*/ | ||
final class BlankNodeIdentifierViewHelper extends AbstractViewHelper | ||
{ | ||
public static function renderStatic( | ||
array $arguments, | ||
\Closure $renderChildrenClosure, | ||
RenderingContextInterface $renderingContext | ||
): BlankNodeIdentifier { | ||
return new BlankNodeIdentifier(); | ||
} | ||
} |
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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the "schema" extension for TYPO3 CMS. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Brotkrueml\Schema\ViewHelpers; | ||
|
||
use Brotkrueml\Schema\Core\Model\NodeIdentifier; | ||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
|
||
/** | ||
* ViewHelper for creating a NodeIdentifier. | ||
* | ||
* = Examples = | ||
* <code title="Using the view helper directly"> | ||
* <schema:type.person name="John Smith" -id="{schema:nodeIdentifier(id: 'https://example.org/#john-smith')}"/> | ||
* </code> | ||
* <code title="Using the view helper via variable"> | ||
* <f:variable name="identifier1" value="{schema:nodeIdentifier(id: 'https://example.org/#john-smith')}"/> | ||
* <f:variable name="identifier2" value="{schema:nodeIdentifier(id: 'https://example.org/#sarah-jane-smith')}"/> | ||
* <schema:type.person name="John Smith" -id="{identifier1}" knows="{identifier2}"/> | ||
* <schema:type.person name="Sarah Jane Smith" -id="{identifier2}" knows="{identifier1}"/> | ||
* </code> | ||
*/ | ||
final class NodeIdentifierViewHelper extends AbstractViewHelper | ||
{ | ||
public function initializeArguments() | ||
{ | ||
parent::initializeArguments(); | ||
|
||
$this->registerArgument('id', 'string', 'The identifier for the node', true); | ||
} | ||
|
||
public static function renderStatic( | ||
array $arguments, | ||
\Closure $renderChildrenClosure, | ||
RenderingContextInterface $renderingContext | ||
): NodeIdentifier { | ||
return new NodeIdentifier($arguments['id']); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the "schema" extension for TYPO3 CMS. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Brotkrueml\Schema\Tests\Fixtures\Model\Type; | ||
|
||
use Brotkrueml\Schema\Core\Model\AbstractType; | ||
|
||
class Person extends AbstractType | ||
{ | ||
/** | ||
* @var string[] | ||
*/ | ||
protected static $propertyNames = [ | ||
'name', | ||
'knows', | ||
'url', | ||
'worksFor', | ||
]; | ||
} |
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
Oops, something went wrong.