Skip to content

Commit 10151e7

Browse files
authored
Merge pull request #19 from kdambekalns/master
!!! FEATURE: Adjust to Neos 3.0
2 parents 49d617e + 8283986 commit 10151e7

19 files changed

+159
-134
lines changed

Classes/RobertLemke/Plugin/Blog/Command/AtomImportCommandController.php renamed to Classes/Command/AtomImportCommandController.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
* source code.
1212
*/
1313

14-
use TYPO3\Eel\FlowQuery\FlowQuery;
15-
use TYPO3\Flow\Annotations as Flow;
16-
use TYPO3\Flow\Cli\CommandController;
17-
use TYPO3\Neos\Domain\Service\ContentContextFactory;
18-
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
19-
use TYPO3\TYPO3CR\Domain\Model\NodeTemplate;
20-
use TYPO3\TYPO3CR\Domain\Service\NodeTypeManager;
21-
use TYPO3\TYPO3CR\Utility;
14+
use Neos\Eel\FlowQuery\FlowQuery;
15+
use Neos\Flow\Annotations as Flow;
16+
use Neos\Flow\Cli\CommandController;
17+
use Neos\Neos\Domain\Service\ContentContextFactory;
18+
use Neos\ContentRepository\Domain\Model\NodeInterface;
19+
use Neos\ContentRepository\Domain\Model\NodeTemplate;
20+
use Neos\ContentRepository\Domain\Service\NodeTypeManager;
21+
use Neos\ContentRepository\Utility;
2222

2323
/**
2424
* BlogCommand command controller for the RobertLemke.Plugin.Blog package
@@ -27,7 +27,6 @@
2727
*/
2828
class AtomImportCommandController extends CommandController
2929
{
30-
3130
/**
3231
* @Flow\Inject
3332
* @var NodeTypeManager
@@ -48,7 +47,7 @@ class AtomImportCommandController extends CommandController
4847
/**
4948
* @var array
5049
*/
51-
protected $tagNodes = array();
50+
protected $tagNodes = [];
5251

5352
/**
5453
* Imports atom data into the blog
@@ -79,11 +78,11 @@ public function migrateCommand($workspace, $targetNode, $atomFile)
7978

8079
$parser->set_raw_data(file_get_contents($atomFile));
8180
$parser->strip_attributes();
82-
$parser->strip_htmltags(array_merge($parser->strip_htmltags, array('span')));
81+
$parser->strip_htmltags(array_merge($parser->strip_htmltags, ['span']));
8382
$parser->init();
8483
$items = $parser->get_items();
8584

86-
$comments = array();
85+
$comments = [];
8786
/** @var $item \SimplePie_Item */
8887
foreach ($items as $item) {
8988
$categories = $item->get_categories();
@@ -102,7 +101,7 @@ public function migrateCommand($workspace, $targetNode, $atomFile)
102101
}
103102
}
104103

105-
$textNodeType = $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Text');
104+
$textNodeType = $this->nodeTypeManager->getNodeType('Neos.NodeTypes:Text');
106105
$commentNodeType = $this->nodeTypeManager->getNodeType('RobertLemke.Plugin.Blog:Comment');
107106
$counter = 0;
108107
foreach ($parser->get_items() as $item) {
@@ -111,7 +110,7 @@ public function migrateCommand($workspace, $targetNode, $atomFile)
111110
continue;
112111
}
113112

114-
$tags = array();
113+
$tags = [];
115114
$itemIsPost = false;
116115
foreach ($categories as $category) {
117116
if ($category->get_term() === 'http://schemas.google.com/blogger/2008/kind#post') {
@@ -134,13 +133,13 @@ public function migrateCommand($workspace, $targetNode, $atomFile)
134133
$nodeTemplate->setProperty('datePublished', $published);
135134
$nodeTemplate->setProperty('tags', $this->getTagNodes($tags));
136135

137-
$slug = strtolower(str_replace(array(' ', ',', ':', 'ü', 'à', 'é', '?', '!', '[', ']', '.', '\''), array('-', '', '', 'u', 'a', 'e', '', '', '', '', '-', ''), $item->get_title()));
136+
$slug = strtolower(str_replace([' ', ',', ':', 'ü', 'à', 'é', '?', '!', '[', ']', '.', '\''], ['-', '', '', 'u', 'a', 'e', '', '', '', '', '-', ''], $item->get_title()));
138137
/** @var NodeInterface $postNode */
139138
$postNode = $this->blogNode->createNodeFromTemplate($nodeTemplate, $slug);
140139
$postNode->getNode('main')->createNode(uniqid('node'), $textNodeType)->setProperty('text', $item->get_content());
141140

142-
$postComments = isset($comments[$item->get_id()]) ? $comments[$item->get_id()] : array();
143-
if ($postComments !== array()) {
141+
$postComments = isset($comments[$item->get_id()]) ? $comments[$item->get_id()] : [];
142+
if ($postComments !== []) {
144143
/** @var NodeInterface $commentsNode */
145144
$commentsNode = $postNode->getNode('comments');
146145
/** @var $postComment \SimplePie_Item */
@@ -165,15 +164,16 @@ public function migrateCommand($workspace, $targetNode, $atomFile)
165164
$this->outputLine($postNode->getProperty('title') . ' by ' . $postNode->getProperty('author'));
166165
}
167166

168-
$this->outputLine('Imported %s blog posts.', array($counter));
167+
$this->outputLine('Imported %s blog posts.', [$counter]);
169168
}
170169

171170
/**
172171
* @param array $tags
173172
* @return array<NodeInterface>
174173
*/
175-
protected function getTagNodes(array $tags) {
176-
$tagNodes = array();
174+
protected function getTagNodes(array $tags)
175+
{
176+
$tagNodes = [];
177177

178178
foreach ($tags as $tag) {
179179
if (!isset($this->tagNodes[$tag])) {

Classes/RobertLemke/Plugin/Blog/Controller/CommentController.php renamed to Classes/Controller/CommentController.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
*/
1313

1414
use RobertLemke\Akismet\Service;
15-
use TYPO3\Flow\Annotations as Flow;
16-
use TYPO3\Flow\Mvc\Controller\ActionController;
17-
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
18-
use TYPO3\TYPO3CR\Domain\Model\NodeTemplate;
15+
use Neos\Flow\Annotations as Flow;
16+
use Neos\Flow\Mvc\Controller\ActionController;
17+
use Neos\ContentRepository\Domain\Model\NodeInterface;
18+
use Neos\ContentRepository\Domain\Model\NodeTemplate;
1919

2020
/**
2121
* Comments controller for the Blog package
2222
*/
2323
class CommentController extends ActionController
2424
{
25-
2625
/**
2726
* @Flow\Inject
2827
* @var Service

Classes/RobertLemke/Plugin/Blog/Controller/PostController.php renamed to Classes/Controller/PostController.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
use RobertLemke\Rss\Channel;
1616
use RobertLemke\Rss\Feed;
1717
use RobertLemke\Rss\Item;
18-
use TYPO3\Flow\Annotations as Flow;
19-
use TYPO3\Flow\I18n\Service;
20-
use TYPO3\Flow\Mvc\Controller\ActionController;
21-
use TYPO3\Flow\Mvc\Routing\UriBuilder;
22-
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
23-
use TYPO3\TYPO3CR\Domain\Service\NodeTypeManager;
18+
use Neos\Flow\Annotations as Flow;
19+
use Neos\Flow\I18n\Service;
20+
use Neos\Flow\Mvc\Controller\ActionController;
21+
use Neos\Flow\Mvc\Routing\UriBuilder;
22+
use Neos\ContentRepository\Domain\Model\NodeInterface;
23+
use Neos\ContentRepository\Domain\Service\NodeTypeManager;
2424

2525
/**
2626
* The posts controller for the Blog package
@@ -29,7 +29,6 @@
2929
*/
3030
class PostController extends ActionController
3131
{
32-
3332
/**
3433
* @Flow\Inject
3534
* @var NodeTypeManager
@@ -75,7 +74,7 @@ public function rssAction()
7574
$feedUri = $this->request->getInternalArgument('__feedUri');
7675
} else {
7776
$uriBuilder->setFormat('xml');
78-
$feedUri = $uriBuilder->uriFor('show', array('node' => $rssDocumentNode), 'Frontend\Node', 'TYPO3.Neos');
77+
$feedUri = $uriBuilder->uriFor('show', ['node' => $rssDocumentNode], 'Frontend\Node', 'Neos.Neos');
7978
}
8079

8180
$channel = new Channel();
@@ -89,7 +88,7 @@ public function rssAction()
8988
foreach ($postsNode->getChildNodes('RobertLemke.Plugin.Blog:Post') as $postNode) {
9089

9190
$uriBuilder->setFormat('html');
92-
$postUri = $uriBuilder->uriFor('show', array('node' => $postNode), 'Frontend\Node', 'TYPO3.Neos');
91+
$postUri = $uriBuilder->uriFor('show', ['node' => $postNode], 'Frontend\Node', 'Neos.Neos');
9392

9493
$item = new Item();
9594
$item->setTitle($postNode->getProperty('title'));
@@ -105,13 +104,13 @@ public function rssAction()
105104
$item->setCreator($author);
106105

107106
if ($postNode->getProperty('categories')) {
108-
$categories = array();
107+
$categories = [];
109108
/** @var NodeInterface $categoryNode */
110109
foreach ($postNode->getProperty('categories') as $categoryNode) {
111-
$categories[] = array(
110+
$categories[] = [
112111
'category' => $categoryNode->getProperty('title'),
113112
'domain' => $categoryNode->getProperty('domain')
114-
);
113+
];
115114
}
116115
$item->setCategories($categories);
117116
}
@@ -135,5 +134,4 @@ public function rssAction()
135134

136135
return $feed->render();
137136
}
138-
139137
}

Classes/RobertLemke/Plugin/Blog/Package.php renamed to Classes/Package.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@
1111
* source code.
1212
*/
1313

14-
use TYPO3\Flow\Core\Bootstrap;
15-
use TYPO3\Flow\Package\Package as BasePackage;
14+
use Neos\Flow\Core\Bootstrap;
15+
use Neos\Flow\Package\Package as BasePackage;
1616

1717
/**
1818
* The Blog Package
1919
*
2020
*/
2121
class Package extends BasePackage
2222
{
23-
2423
/**
2524
* Invokes custom PHP code directly after the package manager has been initialized.
2625
*
@@ -32,5 +31,4 @@ public function boot(Bootstrap $bootstrap)
3231
$dispatcher = $bootstrap->getSignalSlotDispatcher();
3332
$dispatcher->connect('RobertLemke\Plugin\Blog\Controller\CommentController', 'commentCreated', 'RobertLemke\Plugin\Blog\Service\NotificationService', 'sendNewCommentNotification');
3433
}
35-
3634
}

Classes/RobertLemke/Plugin/Blog/RenderingFixingAspect.php renamed to Classes/RenderingFixingAspect.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
* source code.
1212
*/
1313

14-
use TYPO3\Flow\Annotations as Flow;
15-
use TYPO3\Flow\Aop\JoinPointInterface;
14+
use Neos\Flow\Annotations as Flow;
15+
use Neos\Flow\Aop\JoinPointInterface;
1616

1717
/**
1818
* Aspect for hotfixing rendering issues with XML content
@@ -22,13 +22,12 @@
2222
*/
2323
class RenderingFixingAspect
2424
{
25-
2625
/**
2726
* Makes sure that XML content (such as the RSS feed) is not wrapped with divs.
2827
*
2928
* @param JoinPointInterface $joinPoint
3029
* @return string
31-
* @Flow\Around("method(TYPO3\Neos\Service\ContentElementWrappingService->wrapContentObject())")
30+
* @Flow\Around("method(Neos\Neos\Service\ContentElementWrappingService->wrapContentObject())")
3231
*/
3332
public function preventContentElementWraps(JoinPointInterface $joinPoint)
3433
{
@@ -39,5 +38,4 @@ public function preventContentElementWraps(JoinPointInterface $joinPoint)
3938

4039
return $joinPoint->getAdviceChain()->proceed($joinPoint);
4140
}
42-
4341
}

Classes/RobertLemke/Plugin/Blog/Service/ContentService.php renamed to Classes/Service/ContentService.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
* source code.
1212
*/
1313

14-
use TYPO3\Flow\Annotations as Flow;
15-
use TYPO3\Flow\Resource\ResourceManager;
16-
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
14+
use Neos\Flow\Annotations as Flow;
15+
use Neos\Flow\ResourceManagement\ResourceManager;
16+
use Neos\ContentRepository\Domain\Model\NodeInterface;
1717

1818
/**
1919
* A service which can render specific views of blog related content
@@ -22,7 +22,6 @@
2222
*/
2323
class ContentService
2424
{
25-
2625
/**
2726
* @Flow\Inject
2827
* @var ResourceManager
@@ -31,7 +30,7 @@ class ContentService
3130

3231
/**
3332
* Renders a teaser text with up to $maximumLength characters, with an outermost <p> and some more tags removed,
34-
* from the given Node (fetches the first TYPO3.Neos.NodeTypes:Text childNode as a base).
33+
* from the given Node (fetches the first Neos.NodeTypes:Text childNode as a base).
3534
*
3635
* If '<!-- read more -->' is found, the teaser will be the preceding content and $maximumLength is ignored.
3736
*
@@ -44,7 +43,7 @@ public function renderTeaser(NodeInterface $node, $maximumLength = 500)
4443
$stringToTruncate = '';
4544

4645
/** @var NodeInterface $contentNode */
47-
foreach ($node->getNode('main')->getChildNodes('TYPO3.Neos.NodeTypes:Text') as $contentNode) {
46+
foreach ($node->getNode('main')->getChildNodes('Neos.NodeTypes:Text') as $contentNode) {
4847
foreach ($contentNode->getProperties() as $propertyValue) {
4948
if (!is_object($propertyValue) || method_exists($propertyValue, '__toString')) {
5049
$stringToTruncate .= $propertyValue;
@@ -79,23 +78,23 @@ public function renderContent(NodeInterface $node)
7978
$content = '';
8079

8180
/** @var NodeInterface $contentNode */
82-
foreach ($node->getNode('main')->getChildNodes('TYPO3.Neos:Content') as $contentNode) {
83-
if ($contentNode->getNodeType()->isOfType('TYPO3.Neos.NodeTypes:TextWithImage')) {
81+
foreach ($node->getNode('main')->getChildNodes('Neos.Neos:Content') as $contentNode) {
82+
if ($contentNode->getNodeType()->isOfType('Neos.NodeTypes:TextWithImage')) {
8483
$propertyValue = $contentNode->getProperty('image');
85-
$attributes = array(
84+
$attributes = [
8685
'width="' . $propertyValue->getWidth() . '"',
8786
'height="' . $propertyValue->getHeight() . '"',
8887
'src="' . $this->resourceManager->getPublicPersistentResourceUri($propertyValue->getResource()) . '"'
89-
);
88+
];
9089
$content .= $contentNode->getProperty('text');
9190
$content .= '<img ' . implode(' ', $attributes) . '/>';
92-
} elseif ($contentNode->getNodeType()->isOfType('TYPO3.Neos.NodeTypes:Image')) {
91+
} elseif ($contentNode->getNodeType()->isOfType('Neos.NodeTypes:Image')) {
9392
$propertyValue = $contentNode->getProperty('image');
94-
$attributes = array(
93+
$attributes = [
9594
'width="' . $propertyValue->getWidth() . '"',
9695
'height="' . $propertyValue->getHeight() . '"',
9796
'src="' . $this->resourceManager->getPublicPersistentResourceUri($propertyValue->getResource()) . '"'
98-
);
97+
];
9998
$content .= '<img ' . implode(' ', $attributes) . '/>';
10099
} else {
101100
foreach ($contentNode->getProperties() as $propertyValue) {

Classes/RobertLemke/Plugin/Blog/Service/NotificationService.php renamed to Classes/Service/NotificationService.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
* source code.
1212
*/
1313

14-
use TYPO3\Flow\Annotations as Flow;
15-
use TYPO3\Flow\Log\SystemLoggerInterface;
16-
use TYPO3\SwiftMailer\Message;
17-
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
14+
use Neos\Flow\Annotations as Flow;
15+
use Neos\Flow\Log\SystemLoggerInterface;
16+
use Neos\SwiftMailer\Message;
17+
use Neos\ContentRepository\Domain\Model\NodeInterface;
1818

1919
/**
2020
* A notification service
@@ -23,7 +23,6 @@
2323
*/
2424
class NotificationService
2525
{
26-
2726
/**
2827
* @var array
2928
*/
@@ -57,23 +56,23 @@ public function sendNewCommentNotification(NodeInterface $commentNode, NodeInter
5756
return;
5857
}
5958

60-
if (!class_exists('TYPO3\SwiftMailer\Message')) {
61-
$this->systemLogger->log('The package "TYPO3.SwiftMailer" is required to send notifications!');
59+
if (!class_exists('Neos\SwiftMailer\Message')) {
60+
$this->systemLogger->log('The package "Neos.SwiftMailer" is required to send notifications!');
61+
6262
return;
6363
}
6464

6565
try {
6666
$mail = new Message();
6767
$mail
68-
->setFrom(array($this->settings['notifications']['to']['email'] => $this->settings['notifications']['to']['name']))
69-
->setReplyTo(array($commentNode->getProperty('emailAddress') => $commentNode->getProperty('author')))
70-
->setTo(array($this->settings['notifications']['to']['email'] => $this->settings['notifications']['to']['name']))
68+
->setFrom([$this->settings['notifications']['to']['email'] => $this->settings['notifications']['to']['name']])
69+
->setReplyTo([$commentNode->getProperty('emailAddress') => $commentNode->getProperty('author')])
70+
->setTo([$this->settings['notifications']['to']['email'] => $this->settings['notifications']['to']['name']])
7171
->setSubject('New comment on blog post "' . $postNode->getProperty('title') . '"' . ($commentNode->getProperty('spam') ? ' (SPAM)' : ''))
7272
->setBody($commentNode->getProperty('text'))
7373
->send();
7474
} catch (\Exception $e) {
7575
$this->systemLogger->logException($e);
7676
}
7777
}
78-
7978
}

Classes/RobertLemke/Plugin/Blog/ViewHelpers/TeaserViewHelper.php renamed to Classes/ViewHelpers/TeaserViewHelper.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
*/
1313

1414
use RobertLemke\Plugin\Blog\Service\ContentService;
15-
use TYPO3\Flow\Annotations as Flow;
16-
use TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper;
17-
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
15+
use Neos\Flow\Annotations as Flow;
16+
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
17+
use Neos\ContentRepository\Domain\Model\NodeInterface;
1818

1919
/**
2020
* This view helper crops the text of a blog post in a meaningful way.
@@ -23,7 +23,6 @@
2323
*/
2424
class TeaserViewHelper extends AbstractViewHelper
2525
{
26-
2726
/**
2827
* @var boolean
2928
*/

0 commit comments

Comments
 (0)