-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #5
- Loading branch information
Marvin Kuhn
committed
Sep 29, 2018
1 parent
c3df7b6
commit 0640483
Showing
10 changed files
with
228 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
namespace Breadlesscode\Blog\FlowQuery\Operations; | ||
|
||
use Neos\ContentRepository\Domain\Model\NodeInterface; | ||
use Neos\Eel\FlowQuery\FlowQuery; | ||
use Neos\Eel\FlowQuery\FlowQueryException; | ||
use Neos\Eel\FlowQuery\Operations\AbstractOperation; | ||
|
||
class FilterByAuthorOperation extends AbstractOperation | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var string | ||
*/ | ||
static protected $shortName = 'filterByAuthor'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @param FlowQuery $flowQuery the FlowQuery object | ||
* @param array $arguments the arguments for this operation | ||
* @return void | ||
* @throws FlowQueryException | ||
*/ | ||
public function evaluate(FlowQuery $flowQuery, array $arguments) | ||
{ | ||
if (!is_string($arguments[0])) { | ||
throw new FlowQueryException('The first parameter of '.self::$shortName.' should be a string'); | ||
} | ||
|
||
$context = \array_filter($flowQuery->getContext(), function(NodeInterface $node) use ($arguments) { | ||
return $node->getProperty('author') === $arguments[0]; | ||
}); | ||
$flowQuery->setContext($context); | ||
} | ||
} |
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,56 @@ | ||
<?php | ||
namespace Breadlesscode\Blog\NodeCreationHandler; | ||
|
||
/* | ||
* This file is part of the Neos.Neos.Ui package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
use Breadlesscode\Blog\Service\PostNodePreparationService; | ||
use Neos\ContentRepository\Domain\Model\NodeInterface; | ||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Neos\Domain\Model\User; | ||
use Neos\Neos\Ui\NodeCreationHandler\NodeCreationHandlerInterface; | ||
use Neos\Neos\Domain\Repository\UserRepository; | ||
use Neos\Neos\Utility\NodeUriPathSegmentGenerator; | ||
|
||
class AuthorNodeCreationHandler implements NodeCreationHandlerInterface | ||
{ | ||
/** | ||
* @var UserRepository | ||
* @Flow\Inject() | ||
*/ | ||
protected $userRepo; | ||
|
||
/** | ||
* @Flow\Inject | ||
* @var NodeUriPathSegmentGenerator | ||
*/ | ||
protected $nodeUriPathSegmentGenerator; | ||
|
||
/** | ||
* Set the node title for the newly created Document node | ||
* | ||
* @param NodeInterface $node The newly created node | ||
* @param array $data incoming data from the creationDialog | ||
* @return void | ||
* @throws \Neos\Neos\Exception | ||
*/ | ||
public function handle(NodeInterface $node, array $data) | ||
{ | ||
if (!$node->getNodeType()->isOfType(PostNodePreparationService::DOCUMENT_AUTHOR_TYPE)) { | ||
return; | ||
} | ||
/** @var User $user */ | ||
$user = $this->userRepo->findByIdentifier($data['user']); | ||
|
||
$node->setProperty('user', $data['user']); | ||
$node->setProperty('title', $user->getLabel()); | ||
$node->setProperty('uriPathSegment', $this->nodeUriPathSegmentGenerator->generateUriPathSegment($node, $user->getLabel())); | ||
} | ||
} |
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,49 @@ | ||
'Breadlesscode.Blog:Document.Author': | ||
superTypes: | ||
'Neos.Neos:Document': true | ||
|
||
ui: | ||
label: 'i18n' | ||
group: 'blog' | ||
position: 500 | ||
icon: 'far fa-user-circle' | ||
inspector: | ||
groups: | ||
author: | ||
label: 'i18n' | ||
icon: 'far fa-user-circle' | ||
|
||
creationDialog: | ||
elements: | ||
title: ~ | ||
user: | ||
type: string | ||
ui: | ||
label: 'i18n' | ||
editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor' | ||
editorOptions: | ||
dataSourceIdentifier: 'breadlesscode-blog-user-datasource' | ||
minimumResultsForSearch: 3 | ||
validation: | ||
'Neos.Flow\Validation\Validator\NumberRangeValidator': ~ | ||
|
||
options: | ||
documentTitle: ~ | ||
nodeCreationHandlers: | ||
user: | ||
nodeCreationHandler: 'Breadlesscode\Blog\NodeCreationHandler\AuthorNodeCreationHandler' | ||
|
||
properties: | ||
user: | ||
type: string | ||
ui: | ||
label: 'i18n' | ||
inspector: | ||
position: 10 | ||
group: author | ||
editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor' | ||
editorOptions: | ||
dataSourceIdentifier: 'breadlesscode-blog-user-datasource' | ||
minimumResultsForSearch: 3 | ||
validation: | ||
'Neos.Flow\Validation\Validator\NumberRangeValidator': ~ |
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,18 @@ | ||
prototype(Breadlesscode.Blog:Document.Author) > | ||
prototype(Breadlesscode.Blog:Document.Author) < prototype(Neos.Neos:Page) { | ||
body > | ||
body = Neos.Fusion:Tag { | ||
attributes.class = 'blog-tag' | ||
content = Neos.Fusion:Array { | ||
headline = Neos.Fusion:Tag { | ||
tagName = 'h1' | ||
content = ${ Translation.translate('Breadlesscode.Blog:Main:author.title') + ': ' + q(documentNode).property('title')} | ||
} | ||
list = Breadlesscode.Blog:Component.PostList { | ||
paginated = true | ||
itemsPerPage = 10 | ||
collection = ${ q(site).find('[instanceof Breadlesscode.Blog:Document.Post]').filterByAuthor(q(documentNode).property('user')).get() } | ||
} | ||
} | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
Resources/Private/Translations/de/NodeTypes/Document/Author.xlf
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> | ||
<file original="" product-name="Breadlesscode.Blog" source-language="en" target-language="de" datatype="plaintext"> | ||
<body> | ||
<trans-unit id="ui.label" xml:space="preserve"> | ||
<source>Author</source> | ||
<target xml:lang="de">Autor</target> | ||
</trans-unit> | ||
<trans-unit id="groups.author" xml:space="preserve"> | ||
<source>Author</source> | ||
<target xml:lang="de">Autor</target> | ||
</trans-unit> | ||
<trans-unit id="properties.user" xml:space="preserve"> | ||
<source>User</source> | ||
<target xml:lang="de">Benutzer</target> | ||
</trans-unit> | ||
<trans-unit id="creationDialog.user" xml:space="preserve"> | ||
<source>User</source> | ||
<target xml:lang="de">Benutzer</target> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
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
19 changes: 19 additions & 0 deletions
19
Resources/Private/Translations/en/NodeTypes/Document/Author.xlf
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,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> | ||
<file original="" product-name="Breadlesscode.Blog" source-language="en" datatype="plaintext"> | ||
<body> | ||
<trans-unit id="ui.label" xml:space="preserve"> | ||
<source>Author</source> | ||
</trans-unit> | ||
<trans-unit id="groups.author" xml:space="preserve"> | ||
<source>Author</source> | ||
</trans-unit> | ||
<trans-unit id="properties.user" xml:space="preserve"> | ||
<source>User</source> | ||
</trans-unit> | ||
<trans-unit id="creationDialog.user" xml:space="preserve"> | ||
<source>User</source> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |