Signal / Slots in Extbase

Posted: November 30th, 2011 | Author: | Tags: , , | 3 Comments »

A nice thing to have at hand is definately Signal and Slots. I heard Felix talking about them quite often and I finally found a nice usecase and came to play with them a little bit this afternoon. And just to avoid that others have to look around too much to find how they can get them to work here’s how it’s working for me.

First of all you should understand the concept. This nice little “definition” (from flow3.typo3.org) sums it up pretty well:

A signal, which contains event information as it makes sense in the case at hand, can be emitted (sent) by any part of the code and is received by one or more slots, which can be any function in FLOW3 in extbase.

To get this running in extbase, you’ve to get hold of the Tx_Extbase_SignalSlot_Dispatcher, which is the central instance to manage all of it. Within Extbase that’s done easily with this snippet within your classes:

   ...
	/**
	 * @var Tx_Extbase_SignalSlot_Dispatcher
	 */
	protected $signalSlotDispatcher;
   
	/**
	 * @param Tx_Extbase_SignalSlot_Dispatcher $signalSlotDispatcher
	 */
	public function injectSignalSlotDispatcher(Tx_Extbase_SignalSlot_Dispatcher $signalSlotDispatcher) {
		$this->signalSlotDispatcher = $signalSlotDispatcher;
	}
   ...

Next thing is to make use of it. The Slot (listener) part could look like one of following blocks. In all cases you define the Signal by it’s class (not necessarily a PHP Class) and it’s name. Next to that the Slot can either be defined by a Closure, an object with a method name or a PHP-Class and a method name.

   ...
// Using a closure
$this->signalSlotDispatcher->connect(
      'Crunching', 'emitDataReady', function($data) { crunch($data) }, NULL, FALSE
);
   ...
// Using a method of the current object
$this->signalSlotDispatcher->connect(
     'Crunching', 'emitDataReady', $this, 'crunch', FALSE
);
   ...
// Using a method of the specified class
$this->signalSlotDispatcher->connect(
     'Crunching', 'emitDataReady', 'Cruncher', 'crunch', FALSE
);
   ...

To trigger the Signal which invokes the Slots registered above, you’ve to run the following code.

$this->signalSlotDispatcher->dispatch('Crunching', 'emitDataReady', array($data));

One thing I found was that by default the Tx_Extbase_SignalSlot_Dispatcher it not a Singleton in older extbase versions. Bastian fixed that already in the master and 1-4 branches and lucky enough this change was part within the TYPO3 4.6.1 release. But I think it’s still important to mention that this wasn’t the default from the beginning on.

Even if AOP is a nicer way to implement this feature, the extbase backport still works pretty straigh forward.

Edit: One thing I’ve to add – Felix is not “just” talking about Signal/Slots – he’s the one to thank for the backport. And now that his blog is running again – this post seems like a summary ;)


Release reviews (templavoila, imagemap_wizard, workspaces)

Posted: February 24th, 2011 | Author: | Tags: , | 2 Comments »

I just push the TER upload button two times and in addition to that TYPO3 4.5.2 will be released tomorrow containing some nice workspaces updates. So here’s a short summary what happened in the extension releases.

TemplaVoila 1.5.4
The current release focussed on 4.5 compatibility. It uses the new sys_language flag “format” to support sprites, it hooks into the new backend-form (TCA) “layout” and add’s it’s fields to the right tabs within the backend forms and adjusts everything to work fine with the new CSRF mechanism.

Besides that bug fixes for the section index, performance improvements and a couple more are included.

One thing in conjunction with 4.5 you should be aware of is that copied elements are hidden by default. In older versions hidden elements won’t show up in the page module by default and therefore it might seem that nothing was copied, but that’s not right. With 1.5.4 the default setting was changed so hidden elements will show up in the page module. Unfortunately the old setting (to skip hidden elements) might still be present in your session settings – so please either clear your session settings or use the “Advanced function” tab in the page module to change to setting and avoid confusion.

Imagemap_wizard 0.6.0
The last versions proved to be very stable and with some additional sponsoring I was able to improve the DAM and TYPO3 workspaces support. Besides that a couple of issues which showed up in 4.4 and 4.5 were fixed. One of the next features will hopefully be a useful point of interest implementation – keep your fingers crossed that someone’s clients want’s to sponsor some time for that ;)

Workspaces 4.5.1 / 4.5.2
Even if it’s shipped with the Core and included in the official release notes, here’s my summary of the improvements. The workspace module itself brought us lot’s of good feedback and also the new workspace preview raised some attention. Even though 4.5.0 was quite stable we weren’t able to get it working perfectly. The fixes made for 4.5.1 made sure that especially the preview window works much more stable, it introduced state persistence (so switching preview modes or module settings are memorized properly) and it brought some performance improvements.
Btw. if you didn’t check out the new workspaces features and improvements the new workspaces documentation from Susanne Moog is a good point to start.


TYPO3 4.5 beta1

Posted: November 18th, 2010 | Author: | Comments Off

As announced on news.typo3.org yesterday the TYPO3 Core team published TYPO3 4.5 beta. With this beta the features for the next version are fixed and the remaining time until the release will be used for polishing and bug fixing.
A complete list of the included features and changes can be found on forge.typo3.org.

As member of the TYPO3 workspace team I’d like to encourage everyone to send as much feedback as possible for all the workspace related changes and since maintaining TemplaVoila is also still on my list, it would be great if you let me know if you find any TemplaVoila related issues with the new TYPO3 version.

If you’d like to stay up-to-date with the latest changes in the TYPO3 Core, without reading all the newsgroup messages, you might be interested to use the TYPO3 trunk Changelog RSS feed. Besides the feed there’s a great service from the Core team, they started to publish the protocol of their weekly meeting as “Minutes from the meeting of the release 4.5 team” to the typo3.project.v4 newsgroup. I hope this will be kept up in the future.


TemplaVoila 1.5 released

Posted: October 3rd, 2010 | Author: | Tags: , | 2 Comments »

The new version comes with many bugfixes,new features and a closer TYPO3 integration. Overall 95 issues have been resolved in the last 4 months to finalize this versions, some of the highlights are:

HTML5 support

The full list of HTML5 tags is now supported in TemplaVoila. The restrictions to specific tags was removed and the TYPO3 integrator is now able to use the full bandwidth of modern HTML. With this change also the tag-icons themself were replaced and the coloring schema was changed. The inspiration for the current color schema came from Josh Duck’s “Periodic Table of the Elements”. In additon same mapping bugs have been resolved too – for details see #13974 and #14881.

TemplaVoila 1.5 page module

Page module with TYPO3 4.4 look&feel

TYPO3 4.4 Look&Feel and docHeader integration

TYPO3 4.4 introduced a new skin and changed the look&feel in the backend radically. Once installed in 4.4 TemplaVoila 1.5 adjusts it’s look and provides the same usability improvements as the official page module. The page-module was optimized to use as much “official” CSS as possible to support designes with their own backend-skins. In addition to the CSS&Markup changes, TemplaVoila also uses the TYPO3 4.4 SpriteIcon API to provide and retrieve backend icons and uses the FlashMessage API to style all backend notifications.

Another important step was the integration of the so called docHeader. This is the area at the very top of each backend module page which provides useful tools and action-icons. With this version TemplaVoila finally provides docHeaders within every backend-part.

Improved TYPO3 integration

Besides the visual changes the general TYPO3 integration has been improved with various modifications.

With the current version there’s no need to give “Edit page” rights to you editors if they want to add or remove content elements. Just the “Edit content” right and access to the “Page>Content” field is enough for them. For details see: #3903

The “advached header link inclusion” is one of the integration steps in the frontend. All resources which are related to an FCE are passed through an TYPO3 API (pageRenderer). This avoids duplicate inclusion of one resource (e.g. CSS files) and enables further post-processing (e.g. compression or merging). It can be enabled using the “advancedHeaderInclusion” within your TypoScript setup which could then look like this:

page = PAGE
page.typeNum = 0
page.10 = USER
page.10.userFunc = tx_templavoila_pi1->main_page
page.10.advancedHeaderInclusion= 1


The full list of changes within this version can be found on bugs.typo3.org.
Many many thanks to all contributors and reviewers – it’s great that more people try to help out and it keeps me motivated to continue improving this great TYPO3 extension.


TemplaVoila on github.com

Posted: September 3rd, 2010 | Author: | Tags: , | Comments Off

Update: Finally TemplaVoila moved to git.typo3.org – please read the update here

As it seems, souce code version control for TYPO3 will be done with Git in the future. The Phoenix team already uses git.typo3.org, there’s also already the possibility to get the latest updates for the v4 Core via github.com and it won’t take long until git.typo3.org is been used for version 4 as well.

Due to the fact that my TemplaVoila development workflow is also already git based, I thought it might be interesting for some contributors to develop with a git repository upstream. Therefore I started to maintain a TemplaVoila repository on github.com [1]. The Subversion repository on forge.typo3.org [2] is of course still the master, but both repositories are kept in sync automatically.

So once you think about sending an RFC to the typo3.team.templavoila list, feel free to attach a git based patch-file.

[1] http://github.com/tolleiv/TemplaVoila
[2] https://svn.typo3.org/TYPO3v4/Extensions/templavoila/