Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdambekalns/2585931 to your computer and use it in GitHub Desktop.
Save kdambekalns/2585931 to your computer and use it in GitHub Desktop.
Updating TYPO3.Blog to work with FLOW3 1.1
From cf0a2c479c8da4cc039215299dfe6fdf2a68432a Mon Sep 17 00:00:00 2001
From: Karsten Dambekalns <karsten@typo3.org>
Date: Thu, 3 May 2012 16:07:42 +0200
Subject: [PATCH 1/3] [TASK] Apply migration TYPO3.FLOW3-201201261636
This commit contains the result of applying migration
TYPO3.FLOW3-201201261636.
to this package.
Change-Id: I6db86b7c776208907079a43218991619fe9d097b
Migration: TYPO3.FLOW3-201201261636
---
Classes/Command/SetupCommandController.php | 2 +-
Classes/Controller/AbstractBaseController.php | 6 +++---
Classes/Controller/SetupController.php | 2 +-
Classes/ViewHelpers/GravatarViewHelper.php | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Classes/Command/SetupCommandController.php b/Classes/Command/SetupCommandController.php
index 0c3aabd..6169a3a 100644
--- a/Classes/Command/SetupCommandController.php
+++ b/Classes/Command/SetupCommandController.php
@@ -29,7 +29,7 @@ use TYPO3\FLOW3\Annotations as FLOW3;
*
* @FLOW3\Scope("singleton")
*/
-class SetupCommandController extends \TYPO3\FLOW3\MVC\Controller\CommandController {
+class SetupCommandController extends \TYPO3\FLOW3\Cli\CommandController {
/**
* @FLOW3\Inject
diff --git a/Classes/Controller/AbstractBaseController.php b/Classes/Controller/AbstractBaseController.php
index 91f0236..51763a7 100644
--- a/Classes/Controller/AbstractBaseController.php
+++ b/Classes/Controller/AbstractBaseController.php
@@ -28,7 +28,7 @@ use TYPO3\FLOW3\Annotations as FLOW3;
* the Blog package.
*
*/
-abstract class AbstractBaseController extends \TYPO3\FLOW3\MVC\Controller\ActionController {
+abstract class AbstractBaseController extends \TYPO3\FLOW3\Mvc\Controller\ActionController {
/**
* @FLOW3\Inject
@@ -50,11 +50,11 @@ abstract class AbstractBaseController extends \TYPO3\FLOW3\MVC\Controller\Action
/**
* Initializes the view before invoking an action method.
*
- * @param \TYPO3\FLOW3\MVC\View\ViewInterface $view The view to be initialized
+ * @param \TYPO3\FLOW3\Mvc\View\ViewInterface $view The view to be initialized
* @return void
* @author Robert Lemke <robert@typo3.org>
*/
- protected function initializeView(\TYPO3\FLOW3\MVC\View\ViewInterface $view) {
+ protected function initializeView(\TYPO3\FLOW3\Mvc\View\ViewInterface $view) {
$this->blog = $this->blogRepository->findActive();
if ($this->blog === NULL) {
$this->redirect('index', 'Setup');
diff --git a/Classes/Controller/SetupController.php b/Classes/Controller/SetupController.php
index fca7cc2..4b807e1 100644
--- a/Classes/Controller/SetupController.php
+++ b/Classes/Controller/SetupController.php
@@ -28,7 +28,7 @@ use TYPO3\FLOW3\Annotations as FLOW3;
* data to play with.
*
*/
-class SetupController extends \TYPO3\FLOW3\MVC\Controller\ActionController {
+class SetupController extends \TYPO3\FLOW3\Mvc\Controller\ActionController {
/**
* @FLOW3\Inject
diff --git a/Classes/ViewHelpers/GravatarViewHelper.php b/Classes/ViewHelpers/GravatarViewHelper.php
index 2ca336b..60b81be 100644
--- a/Classes/ViewHelpers/GravatarViewHelper.php
+++ b/Classes/ViewHelpers/GravatarViewHelper.php
@@ -61,7 +61,7 @@ class GravatarViewHelper extends \TYPO3\Fluid\Core\ViewHelper\AbstractTagBasedVi
* @return string The rendered link
*/
public function render() {
- $baseUri = $this->controllerContext->getRequest()->getBaseUri();
+ $baseUri = $this->controllerContext->getRequest()->getHttpRequest()->getBaseUri();
$gravatarUri = 'http://www.gravatar.com/avatar/' . md5((string)$this->arguments['email']);
$uriParts = array();
if ($this->arguments['default']) {
--
1.7.10
From d8f948646048234ada2dc4e4e3b4da805046aac8 Mon Sep 17 00:00:00 2001
From: Karsten Dambekalns <karsten@typo3.org>
Date: Thu, 3 May 2012 16:07:44 +0200
Subject: [PATCH 2/3] [TASK] Apply migration TYPO3.Fluid-201205031303
This commit contains the result of applying migration
TYPO3.Fluid-201205031303.
to this package.
Change-Id: I3eaaf77c19a178d51e59898a13b2054d9ac84833
Migration: TYPO3.Fluid-201205031303
---
Resources/Private/Templates/Account/Edit.html | 6 +++---
Resources/Private/Templates/Blog/Edit.html | 12 ++++++------
Resources/Private/Templates/Category/Edit.html | 2 +-
Resources/Private/Templates/Category/Index.html | 2 +-
Resources/Private/Templates/Login/Index.html | 2 +-
Resources/Private/Templates/Post/Edit.html | 6 +++---
Resources/Private/Templates/Post/New.html | 6 +++---
Resources/Private/Templates/Post/Show.html | 4 ++--
8 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/Resources/Private/Templates/Account/Edit.html b/Resources/Private/Templates/Account/Edit.html
index 00e3434..d5c36cc 100644
--- a/Resources/Private/Templates/Account/Edit.html
+++ b/Resources/Private/Templates/Account/Edit.html
@@ -6,11 +6,11 @@
<f:render partial="FormErrors" arguments="{for: 'account'}" />
<f:form action="update" object="{account}" name="account">
<label for="accountIdentifier">Username</label><br />
- <f:form.textbox property="accountIdentifier" id="accountIdentifier" /><br />
+ <f:form.textfield property="accountIdentifier" id="accountIdentifier" /><br />
<label for="firstname">First name</label><br />
- <f:form.textbox property="party.name.firstName" id="firstname" /><br />
+ <f:form.textfield property="party.name.firstName" id="firstname" /><br />
<label for="lastname">Last name</label><br />
- <f:form.textbox property="party.name.lastName" id="lastname" /><br />
+ <f:form.textfield property="party.name.lastName" id="lastname" /><br />
<label for="password">New password</label><br />
<f:form.password name="password" id="password" /><br />
<f:form.submit value="Update"/>
diff --git a/Resources/Private/Templates/Blog/Edit.html b/Resources/Private/Templates/Blog/Edit.html
index ee16b31..a8dde21 100644
--- a/Resources/Private/Templates/Blog/Edit.html
+++ b/Resources/Private/Templates/Blog/Edit.html
@@ -6,22 +6,22 @@
<f:render partial="FormErrors" arguments="{for: 'blog'}" />
<f:form method="blog" action="update" object="{blog}" name="blog" enctype="multipart/form-data">
<label>Title</label><br />
- <f:form.textbox property="title" id="title" /><br />
+ <f:form.textfield property="title" id="title" /><br />
<label for="description">Description</label><br />
- <f:form.textbox property="description" id="description" /><br />
+ <f:form.textfield property="description" id="description" /><br />
<label for="fullDescription">Long Description</label><br />
- <f:form.textbox property="fullDescription" id="fullDescription" /><br />
+ <f:form.textfield property="fullDescription" id="fullDescription" /><br />
<label for="keywords">Keywords (comma separated)</label><br />
- <f:form.textbox property="keywords" id="keywords" /><br />
+ <f:form.textfield property="keywords" id="keywords" /><br />
<label for="blurb">Blurb</label><br />
<f:form.textarea property="blurb" rows="5" cols="40" id="blurb" /><br />
<f:if condition="{blog.authorPicture}"><img src="{f:uri.resource(resource: blog.authorPicture)}" style="max-width: 60px; float:right;" /></f:if>
<label for="authorPicture">Author picture</label><br />
<f:form.upload property="authorPicture" id="authorPicture" /><br />
<label for="twitterUsername">Twitter username</label><br />
- <f:form.textbox property="twitterUsername" id="twitterUsername" /><br />
+ <f:form.textfield property="twitterUsername" id="twitterUsername" /><br />
<label for="googleAnalyticsAccountNumber">Google Analytics Account #</label><br />
- <f:form.textbox property="googleAnalyticsAccountNumber" id="googleAnalyticsAccountNumber" /><br />
+ <f:form.textfield property="googleAnalyticsAccountNumber" id="googleAnalyticsAccountNumber" /><br />
<f:form.submit value="Update"/>
</f:form>
diff --git a/Resources/Private/Templates/Category/Edit.html b/Resources/Private/Templates/Category/Edit.html
index e59bf3f..5230f64 100644
--- a/Resources/Private/Templates/Category/Edit.html
+++ b/Resources/Private/Templates/Category/Edit.html
@@ -6,7 +6,7 @@
<f:render partial="FormErrors" arguments="{for: 'category'}" />
<f:form action="update" object="{category}" name="category">
<label>Name</label><br />
- <f:form.textbox property="name" /><br />
+ <f:form.textfield property="name" /><br />
<f:form.submit value="Update"/>
</f:form>
</f:section>
\ No newline at end of file
diff --git a/Resources/Private/Templates/Category/Index.html b/Resources/Private/Templates/Category/Index.html
index 72097b4..f70bda3 100644
--- a/Resources/Private/Templates/Category/Index.html
+++ b/Resources/Private/Templates/Category/Index.html
@@ -18,7 +18,7 @@
<f:render partial="FormErrors" arguments="{for: 'newCategory'}" />
<f:form method="post" action="create" object="{newCategory}" name="newCategory">
<label>Name</label><br />
- <f:form.textbox property="name" /><br />
+ <f:form.textfield property="name" /><br />
<f:form.submit value="Add category"/>
</f:form>
diff --git a/Resources/Private/Templates/Login/Index.html b/Resources/Private/Templates/Login/Index.html
index 129fa0c..c971df9 100644
--- a/Resources/Private/Templates/Login/Index.html
+++ b/Resources/Private/Templates/Login/Index.html
@@ -9,7 +9,7 @@
<legend></legend>
<div class="row username">
<label id="usernameLabel" for="username" class="placeholder"><span>Username</span></label>
- <f:form.textbox name="__authentication[TYPO3][FLOW3][Security][Authentication][Token][UsernamePassword][username]" tabindex="1" />
+ <f:form.textfield name="__authentication[TYPO3][FLOW3][Security][Authentication][Token][UsernamePassword][username]" tabindex="1" />
</div>
<div class="row password">
diff --git a/Resources/Private/Templates/Post/Edit.html b/Resources/Private/Templates/Post/Edit.html
index 228a24a..e630394 100644
--- a/Resources/Private/Templates/Post/Edit.html
+++ b/Resources/Private/Templates/Post/Edit.html
@@ -6,15 +6,15 @@
<f:render partial="FormErrors" arguments="{for: 'post'}" />
<f:form method="post" action="update" object="{post}" name="post" enctype="multipart/form-data">
<label for="author">Author</label><br />
- <f:form.textbox property="author" id="author" /><br />
+ <f:form.textfield property="author" id="author" /><br />
<label for="title">Title</label><br />
- <f:form.textbox property="title" id="title" /><br />
+ <f:form.textfield property="title" id="title" /><br />
<label for="content">Content</label><br />
<f:form.textarea property="content" rows="5" cols="40" id="content" /><br />
<f:if condition="{post.image.originalResource}"><img src="{f:uri.resource(resource: post.image.originalResource)}" style="max-width: 60px; float:right;" /></f:if>
<label for="image">Image resource</label><br />
- <f:form.textbox property="image.title" />
+ <f:form.textfield property="image.title" />
<f:form.upload property="image.originalResource" id="image" />
<f:if condition="{categories}">
diff --git a/Resources/Private/Templates/Post/New.html b/Resources/Private/Templates/Post/New.html
index ca3847c..b408fa7 100644
--- a/Resources/Private/Templates/Post/New.html
+++ b/Resources/Private/Templates/Post/New.html
@@ -7,14 +7,14 @@
<f:form action="create" object="{newPost}" name="newPost" enctype="multipart/form-data">
<f:form.hidden name="blog" value="{blog}" />
<label for="author">Author</label><br />
- <f:form.textbox property="author" id="author" /><br />
+ <f:form.textfield property="author" id="author" /><br />
<label for="title">Title</label><br />
- <f:form.textbox property="title" id="title" /><br />
+ <f:form.textfield property="title" id="title" /><br />
<label for="content">Content</label><br />
<f:form.textarea property="content" rows="5" cols="40" id="content" /><br />
<label for="image">Image resource</label><br />
- <f:form.textbox property="image.title" value="My image title" />
+ <f:form.textfield property="image.title" value="My image title" />
<f:form.upload property="image.originalResource" id="image" />
<f:if condition="{categories}">
diff --git a/Resources/Private/Templates/Post/Show.html b/Resources/Private/Templates/Post/Show.html
index 5e3cbb0..3645a29 100644
--- a/Resources/Private/Templates/Post/Show.html
+++ b/Resources/Private/Templates/Post/Show.html
@@ -57,9 +57,9 @@
<f:render partial="FormErrors" arguments="{for: 'newComment'}" />
<f:form action="create" arguments="{post: post}" controller="Comment" object="{newComment}" name="newComment" class="form newcomment" section="comments">
<ul>
- <li><f:form.textbox id="comment.author" property="author" /></li>
+ <li><f:form.textfield id="comment.author" property="author" /></li>
<li><label for="comment.author">Name <span class="required">*</span></label></li>
- <li><f:form.textbox id="comment.emailaddress" property="emailAddress" /></li>
+ <li><f:form.textfield id="comment.emailaddress" property="emailAddress" /></li>
<li><label for="comment.emailaddress">Email <span class="required">*</span> (won't be displayed)</label></li>
<li><f:form.textarea id="comment.content" property="content" rows="10" cols="50"/></li>
<li><f:form.submit class="submit" value="Submit"/></li>
--
1.7.10
From 18803a1327d46af827bb545d8c7bce28bf28d038 Mon Sep 17 00:00:00 2001
From: Karsten Dambekalns <karsten@typo3.org>
Date: Thu, 3 May 2012 10:42:35 +0200
Subject: [PATCH 3/3] [TASK] Manual adjustments to FLOW3 1.1 changes
* make repositories singleton
* adjust provider configuration
* adjust widget id configuration and Routes.yaml
* add schema migration
Change-Id: Ifdb6bdade84d735dd258e3de927ddaa1ba548ef2
---
Classes/Domain/Repository/BlogRepository.php | 1 +
Classes/Domain/Repository/CategoryRepository.php | 3 ++
Classes/Domain/Repository/PostRepository.php | 4 +-
Configuration/Routes.yaml | 7 +---
Configuration/Settings.yaml | 8 ++--
Migrations/Mysql/Version20120503123640.php | 43 ++++++++++++++++++++++
Resources/Private/Templates/Post/Index.html | 2 +-
7 files changed, 57 insertions(+), 11 deletions(-)
create mode 100644 Migrations/Mysql/Version20120503123640.php
diff --git a/Classes/Domain/Repository/BlogRepository.php b/Classes/Domain/Repository/BlogRepository.php
index 4dafb37..b2a4441 100644
--- a/Classes/Domain/Repository/BlogRepository.php
+++ b/Classes/Domain/Repository/BlogRepository.php
@@ -26,6 +26,7 @@ use TYPO3\FLOW3\Annotations as FLOW3;
/**
* A repository for Blogs
*
+ * @FLOW3\Scope("singleton")
*/
class BlogRepository extends \TYPO3\FLOW3\Persistence\Repository {
diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php
index 9ddf9aa..865f671 100644
--- a/Classes/Domain/Repository/CategoryRepository.php
+++ b/Classes/Domain/Repository/CategoryRepository.php
@@ -21,9 +21,12 @@ namespace TYPO3\Blog\Domain\Repository;
* The TYPO3 project - inspiring people to share! *
* */
+use TYPO3\FLOW3\Annotations as FLOW3;
+
/**
* A repository for Categories
*
+ * @FLOW3\Scope("singleton")
*/
class CategoryRepository extends \TYPO3\FLOW3\Persistence\Repository {
diff --git a/Classes/Domain/Repository/PostRepository.php b/Classes/Domain/Repository/PostRepository.php
index f7152e9..0cb1739 100644
--- a/Classes/Domain/Repository/PostRepository.php
+++ b/Classes/Domain/Repository/PostRepository.php
@@ -21,11 +21,13 @@ namespace TYPO3\Blog\Domain\Repository;
* The TYPO3 project - inspiring people to share! *
* */
-use \TYPO3\FLOW3\Persistence\QueryInterface;
+use TYPO3\FLOW3\Persistence\QueryInterface;
+use TYPO3\FLOW3\Annotations as FLOW3;
/**
* A repository for Blog Posts
*
+ * @FLOW3\Scope("singleton")
*/
class PostRepository extends \TYPO3\FLOW3\Persistence\Repository {
diff --git a/Configuration/Routes.yaml b/Configuration/Routes.yaml
index 4134ffa..fcd1128 100644
--- a/Configuration/Routes.yaml
+++ b/Configuration/Routes.yaml
@@ -59,11 +59,11 @@
# Note: Pagination needs some special care due to the way widgets currently build URIs
-
name: 'Posts Pagination'
- uriPattern: 'posts/page/{@widget_0.currentPage}'
+ uriPattern: 'posts/page/{--paginate.currentPage}'
defaults:
'@controller': 'Post'
'@action': 'index'
- '@widget_0':
+ '--paginate':
'@controller': ''
'@package': ''
@@ -73,9 +73,6 @@
defaults:
'@controller': 'Post'
'@action': 'index'
- '@widget_0':
- '@controller': ''
- '@package': ''
-
name: 'General Posts Actions'
diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml
index 8f984d6..725d323 100644
--- a/Configuration/Settings.yaml
+++ b/Configuration/Settings.yaml
@@ -9,10 +9,10 @@ TYPO3:
authenticationStrategy: oneToken
providers:
DefaultProvider:
- providerClass: PersistedUsernamePasswordProvider
- entryPoint:
- WebRedirect:
- uri: admin/authentication
+ provider: PersistedUsernamePasswordProvider
+ entryPoint: 'WebRedirect'
+ entryPointOptions:
+ uri: admin/authentication
Blog:
notifications:
diff --git a/Migrations/Mysql/Version20120503123640.php b/Migrations/Mysql/Version20120503123640.php
new file mode 100644
index 0000000..70ceac3
--- /dev/null
+++ b/Migrations/Mysql/Version20120503123640.php
@@ -0,0 +1,43 @@
+<?php
+namespace TYPO3\FLOW3\Persistence\Doctrine\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration,
+ Doctrine\DBAL\Schema\Schema;
+
+/**
+ * Make columns non-nullable and add unique indexes.
+ */
+class Version20120503123640 extends AbstractMigration {
+
+ /**
+ * @param Schema $schema
+ * @return void
+ */
+ public function up(Schema $schema) {
+ $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
+
+ $this->addSql("ALTER TABLE typo3_blog_domain_model_comment CHANGE date date DATETIME NOT NULL, CHANGE emailaddress emailaddress VARCHAR(255) NOT NULL");
+ $this->addSql("ALTER TABLE typo3_blog_domain_model_post CHANGE date date DATETIME NOT NULL");
+
+ $this->addSql("CREATE UNIQUE INDEX flow3_identity_typo3_blog_domain_model_category ON typo3_blog_domain_model_category (name)");
+ $this->addSql("CREATE UNIQUE INDEX flow3_identity_typo3_blog_domain_model_comment ON typo3_blog_domain_model_comment (date, author)");
+ $this->addSql("CREATE UNIQUE INDEX flow3_identity_typo3_blog_domain_model_post ON typo3_blog_domain_model_post (title, date)");
+ }
+
+ /**
+ * @param Schema $schema
+ * @return void
+ */
+ public function down(Schema $schema) {
+ $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
+
+ $this->addSql("ALTER TABLE typo3_blog_domain_model_comment CHANGE date date DATETIME DEFAULT NULL, CHANGE emailaddress emailaddress VARCHAR(255) DEFAULT NULL");
+ $this->addSql("ALTER TABLE typo3_blog_domain_model_post CHANGE date date DATETIME DEFAULT NULL");
+
+ $this->addSql("DROP INDEX flow3_identity_typo3_blog_domain_model_category ON typo3_blog_domain_model_category");
+ $this->addSql("DROP INDEX flow3_identity_typo3_blog_domain_model_comment ON typo3_blog_domain_model_comment");
+ $this->addSql("DROP INDEX flow3_identity_typo3_blog_domain_model_post ON typo3_blog_domain_model_post");
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/Resources/Private/Templates/Post/Index.html b/Resources/Private/Templates/Post/Index.html
index 018390a..edb132e 100644
--- a/Resources/Private/Templates/Post/Index.html
+++ b/Resources/Private/Templates/Post/Index.html
@@ -17,7 +17,7 @@
<div class="clear"></div>
</div>
</f:security.ifHasRole>
- <f:widget.paginate configuration="{itemsPerPage:5, maximumNumberOfLinks: 5}" objects="{posts}" as="paginatedPosts">
+ <f:widget.paginate widgetId="paginate" configuration="{itemsPerPage:5, maximumNumberOfLinks: 5}" objects="{posts}" as="paginatedPosts">
<ol class="posts">
<f:for each="{paginatedPosts}" as="post">
<li class="post">
--
1.7.10
@kdambekalns
Copy link
Author

The first two commits have been generated by the code migration tool. The third contains the needed manual adjustments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment