<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TYPO3Development</title>
	<atom:link href="http://blog.typoplanet.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.typoplanet.de</link>
	<description>A blog for professional TYPO3 developers</description>
	<lastBuildDate>Mon, 28 Mar 2011 18:10:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Query the Linked Data Cloud using TYPO3</title>
		<link>http://blog.typoplanet.de/2011/03/28/query-linked-data-cloud-typo3/</link>
		<comments>http://blog.typoplanet.de/2011/03/28/query-linked-data-cloud-typo3/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 18:10:02 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Semantic Web integration]]></category>
		<category><![CDATA[extension development]]></category>
		<category><![CDATA[rdf]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[sparql]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=397</guid>
		<description><![CDATA[The Semantic Web is coming to a TYPO3 installation near you. During the TYPO3 Transition Days 2011 in Berlin a couple of Developers&#8212;including me&#8212;discussed about how to implement some aspects of the Semantic Web Stack for TYPO3. One of the first outcome is the new Extension &#8220;semantic&#8221; providing a SPARQL Client. You can query the [...]]]></description>
			<content:encoded><![CDATA[<p>The Semantic Web is coming to a <a href="http://typo3.org">TYPO3</a> installation near you. During the TYPO3 Transition Days 2011 in Berlin a couple of Developers&mdash;including me&mdash;discussed about how to implement some aspects of the Semantic Web Stack for TYPO3. One of the first outcome is the new <a href="http://forge.typo3.org/projects/show/extension-semantic">Extension &#8220;semantic&#8221;</a> providing a SPARQL Client.<br />
<span id="more-397"></span></p>
<p>You can query the <a href="http://linkeddata.org">Linked Data Cloud</a>&mdash;which includes the content of Wikipedia&mdash;by specifying a Query in the <a href="http://en.wikipedia.org/wiki/SPARQL">SPARQL Protocol and RDF Query Language</a>. For example, the statement to query for <em>People born in Boston before 1900</em> looks like:</p>
<div class="codecolorer-container mysql dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="mysql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">PREFIX foaf: <span style="color: #CC0099;">&lt;</span>http: <span style="color: #CC0099;">//</span>xmlns.com<span style="color: #CC0099;">/</span>foaf<span style="color: #CC0099;">/</span><span style="color: #008080;">0.1</span><span style="color: #CC0099;">/&gt;</span><br />
PREFIX dbr: <span style="color: #CC0099;">&lt;</span>http: <span style="color: #CC0099;">//</span>dbpedia.org<span style="color: #CC0099;">/</span>resource<span style="color: #CC0099;">/&gt;</span><br />
PREFIX dbo: <span style="color: #CC0099;">&lt;</span>http: <span style="color: #CC0099;">//</span>dbpedia.org<span style="color: #CC0099;">/</span>ontology<span style="color: #CC0099;">/&gt;</span><br />
PREFIX xsd: <span style="color: #CC0099;">&lt;</span>http: <span style="color: #CC0099;">//</span>www.w3.org<span style="color: #CC0099;">/</span><span style="color: #008080;">2001</span><span style="color: #CC0099;">/</span>XMLSchema<span style="color: #808080; font-style: italic;">#&gt;</span><br />
<br />
<span style="color: #990099; font-weight: bold;">SELECT</span> ?resource ?name ?birthDate ?deathDate<br />
<span style="color: #990099; font-weight: bold;">WHERE</span> <span style="color: #FF00FF;">&#123;</span><br />
&nbsp; ?resource a foaf:Person .<br />
&nbsp; ?resource foaf:name ?name .<br />
&nbsp; ?resource dbo:birthPlace dbr:Boston .<br />
&nbsp; ?resource dbo:birthDate ?birthDate .<br />
&nbsp; ?resource dbo:deathDate ?deathDate .<br />
&nbsp; FILTER <span style="color: #FF00FF;">&#40;</span>?birthDate <span style="color: #CC0099;">&lt;</span> <span style="color: #008000;">&quot;1900-01-01&quot;</span><span style="color: #CC0099;">^^</span>xsd:<span style="color: #999900; font-weight: bold;">date</span><span style="color: #FF00FF;">&#41;</span><br />
<span style="color: #FF00FF;">&#125;</span><br />
<span style="color: #990099; font-weight: bold;">ORDER BY</span> ?deathDate</div></td></tr></tbody></table></div>
<p>In the following video I will guide you through the installation of the Extension &#8220;semantic&#8221; and demo some of its features.</p>
<p><object width="604" height="364">
	<param name="movie" value="http://www.youtube.com/v/Kz_8RozC5eM?fs=1&amp;hl=en_US"></param>
	<param name="allowFullScreen" value="true"></param>
	<param name="allowscriptaccess" value="always"></param>
	<embed src="http://www.youtube.com/v/Kz_8RozC5eM?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="604" height="364"></embed>
</object></p>
<p>I have also recorded the first fifteen minutes in the life of the extension. In the following video you see how I kickstarted the extension. Keep in mind that the library ARC2 I used in this first step isn&#8217;t part of the extension anymore. All the code is now written from scratch, including the SPARQL Query Parser (see other posting).</p>
<p><object width="604" height="364">
	<param name="movie" value="http://www.youtube.com/v/w12fudccROs?fs=1&amp;hl=en_US"></param>
	<param name="allowFullScreen" value="true"></param>
	<param name="allowscriptaccess" value="always"></param>
	<embed src="http://www.youtube.com/v/w12fudccROs?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="604" height="364"></embed>
</object></p>
<p>If you have any specific questions about the extension or found an issue, please visit the projects page on Forge so we can keep track of it. You might also want to have a look at our roadmap or visit the Homepage of the <a href="http://www.typo3.org">TYPO3 community.</http:></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2011/03/28/query-linked-data-cloud-typo3/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A SPARQL Query Result Parser written in PHP</title>
		<link>http://blog.typoplanet.de/2011/01/31/a-sparql-query-result-parser-written-in-php/</link>
		<comments>http://blog.typoplanet.de/2011/01/31/a-sparql-query-result-parser-written-in-php/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 17:21:14 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Meta Topics]]></category>
		<category><![CDATA[Semantic Web integration]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[sparql]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=411</guid>
		<description><![CDATA[Inspired by the SPARQL Query Result Parser written by Daniel Alexander Smith and published on the Enakting Blog, I just wrote an implementation in PHP. It utilizes the performant event based XML parser of PHP. In contrast to the original implementation written in Python, the current version below supports also the &#8220;datatype&#8221; and &#8220;xml:lang&#8221; attribute [...]]]></description>
			<content:encoded><![CDATA[<p>Inspired by the SPARQL Query Result Parser written by Daniel Alexander Smith and published on the <a href="http://blogs.ecs.soton.ac.uk/enakting/2011/01/28/fast-sparql-xml-results-parser-in-python/">Enakting Blog</a>, I just wrote an implementation in PHP. It utilizes the performant event based XML parser of PHP. In contrast to the original implementation written in Python, the current version below supports also the &#8220;datatype&#8221; and &#8220;xml:lang&#8221; attribute of literal types.<span id="more-411"></span></p>
<p>I have stripped off most of the comments and the copyright notice for better readability. You will find the <a href="http://forge.typo3.org/projects/extension-semantic/repository/entry/trunk/Classes/Domain/Model/Sparql/QueryResultParser.php">full code</a> on the project page. It also comes with <a href="http://forge.typo3.org/projects/extension-semantic/repository/entry/trunk/Tests/Unit/Domain/Model/Sparql/QueryResultParserTest.php">unit tests</a>.</p>
<p>This is just a small part of our attempt to integrate some techologies of the <a href="http://en.wikipedia.org/wiki/Semantic_Web_Stack">Semantic Web Stack</a> into TYPO3. For the current status of the project and our future plans, please see our <a href="http://forge.typo3.org/rb/master_backlogs/extension-semantic">product backlog</a>.</p>
<p>The script is part of the <a href="http://forge.typo3.org/projects/extension-semantic">Semantic Web Integration</a> project of TYPO3. You might also want to have a look at our roadmap or visit the Homepage of the <a href="http://www.typo3.org">TYPO3 community</a>.</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Tx_Semantic_Domain_Model_Sparql_QueryResultParser implements Tx_Semantic_Domain_Model_Sparql_QueryResultParserInterface <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$parser</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentResult</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentDataType</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$currentLanguage</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span> <span style="color: #339933;">=</span> <span style="color: #990000;">xml_parser_create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">xml_set_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">xml_set_element_handler</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'handleElementStart'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'handleElementStop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">xml_set_character_data_handler</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'handleCharacterData'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __destruct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990000;">xml_parser_free</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> parse<span style="color: #009900;">&#40;</span><span style="color: #000088;">$document</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #990000;">xml_parse</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$document</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Tx_Semantic_Domain_Model_Sparql_Exception_QueryResultParserException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Parser Error: &quot;'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">xml_error_string</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">xml_get_error_code</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parser</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;.'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1296481762</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> handleElementStart<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$elementName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$elementName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'VARIABLE'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'variables'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'BINDING'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'LITERAL'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'literal'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DATATYPE'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentDatatype</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DATATYPE'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'XML:LANG'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentLanguage</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$elementAttributes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'XML:LANG'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'BNODE'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'bnode'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'URI'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'uri'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> handleElementStop<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$elementName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$elementName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'BINDING'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentResult</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentName</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentName</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentCharacterData</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentType</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentDatatype</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentResult</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'datatype'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentDatatype</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentDatatype</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentLanguage</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentResult</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'language'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentLanguage</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentLanguage</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'LITERAL'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'BNODE'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'URI'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'RESULT'</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'results'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentResult</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentResult</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> handleCharacterData<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$characterData</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">processCharacterData</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currentCharacterData</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$characterData</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2011/01/31/a-sparql-query-result-parser-written-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A book about Extbase and Fluid</title>
		<link>http://blog.typoplanet.de/2010/07/06/book-about-extbase-and-fluid/</link>
		<comments>http://blog.typoplanet.de/2010/07/06/book-about-extbase-and-fluid/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 16:22:38 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[Development Process]]></category>
		<category><![CDATA[Extbase]]></category>
		<category><![CDATA[My Projects]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=382</guid>
		<description><![CDATA[Writing a book is a huge project. I never believed those people saying &#8220;Just double the time of your first estimate&#8221;. Now, after the book is finally available I would say they are wrong. You have to increase it threefold. The book about Extbase and Fluid was written in close collaboration with Sebastian Kurfürst (core [...]]]></description>
			<content:encoded><![CDATA[<p>Writing a book is a huge project. I never believed those people saying &#8220;Just double the time of your first estimate&#8221;. Now, after the book is finally available I would say they are wrong. You have to increase it threefold.</p>
<p>The book about <a href="http://forge.typo3.org/projects/typo3v4-mvc">Extbase</a> and <a href="http://forge.typo3.org/projects/show/package-fluid">Fluid</a> was written in close collaboration with Sebastian Kurfürst (core developer of Fluid) and Inken Kiupel (reader). We hope that it encourages the developers of TYPO3 extensions to get in touch with the fascinating concepts of FLOW3. And we hope that the book eases the migration to TYPO3 v5 (that&#8217;s what Extbase is all about).</p>
<p>We are aware of the fact that many of the English speaking TYPO3 developers are eagerly waiting for more Books about Extbase and Fluid  published in English. Sebastian Kurfürst and I are currently investigating the best way to to get the book translated into English to be published on <a href="http://www.typo3.org">typo3.org</a>.</p>
<p>If you have any questions regarding the book, or found some typos (at least 3), feel free to use the comments facility (if it is positive ;-) ) or write me an <a href="mailto:book@typoplanet.de">e-mail</a>. I am really looking forward to hear from you.</p>
<p>You might want to support our work by <a href="http://www.amazon.de/gp/product/3897219654?ie=UTF8&amp;tag=typoplanet-21&amp;linkCode=as2&amp;camp=1638&amp;creative=6742&amp;creativeASIN=3897219654">ordering the book through this link</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.de/e/ir?t=typoplanet-21&amp;l=as2&amp;o=3&amp;a=3897219654" border="0" alt="" width="1" height="1" />.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2010/07/06/book-about-extbase-and-fluid/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to Effectively use the Repository and Query Object of Extbase?</title>
		<link>http://blog.typoplanet.de/2010/01/27/the-repository-and-query-object-of-extbase/</link>
		<comments>http://blog.typoplanet.de/2010/01/27/the-repository-and-query-object-of-extbase/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 17:13:32 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Extbase]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[DDD]]></category>
		<category><![CDATA[extension development]]></category>
		<category><![CDATA[persistence]]></category>
		<category><![CDATA[query object]]></category>
		<category><![CDATA[repository]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=327</guid>
		<description><![CDATA[Extbase[1] supports very well the idea of Domain-Driven Design[2]. It supplies a Repository class to comfortably fetch your objects from. Some handy methods are already implemented. Let&#8217;s have a look at some example code. 12345678910111213141516171819202122$blog = new Tx_BlogExample_Domain_Model_Blog&#40;'TYPO3 Development'&#41;; $blog-&#62;setDescription&#40;'A blog for professional TYPO3 developers.'&#41;; $administrator = new Tx_BlogExample_Domain_Model_Administrator&#40;&#41;; $administrator-&#62;setName&#40;'Jochen Rau'&#41;; $administrator-&#62;setEmail&#40;'jochen.rau@example.com'&#41;; $blog-&#62;setAdministrator&#40;$administrator&#41;; $post = [...]]]></description>
			<content:encoded><![CDATA[<p>Extbase[<a href="http://blog.typoplanet.de/2010/01/27/the-repository-and-query-object-of-extbase/#footnote_0_327" id="identifier_0_327" class="footnote-link footnote-identifier-link" title="Extbase is a framework to develop Extensions for TYPO3.">1</a>] supports very well the idea of Domain-Driven Design[<a href="http://blog.typoplanet.de/2010/01/27/the-repository-and-query-object-of-extbase/#footnote_1_327" id="identifier_1_327" class="footnote-link footnote-identifier-link" title="Fo a brief introduction in DDD visit www.typo3-media.com">2</a>]. It supplies a <code class="codecolorer php dawn"><span class="php">Repository</span></code> class to comfortably fetch your objects from. Some handy methods are already implemented. <span id="more-327"></span> Let&#8217;s have a look at some example code.</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$blog</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Tx_BlogExample_Domain_Model_Blog<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TYPO3 Development'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$blog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDescription</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'A blog for professional TYPO3 developers.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$administrator</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Tx_BlogExample_Domain_Model_Administrator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$administrator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Jochen Rau'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$administrator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setEmail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jochen.rau@example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$blog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAdministrator</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$administrator</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Tx_BlogExample_Domain_Model_Post<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Effectively use the Query Object of Extbase'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setContent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Extbase is a framework to develop ... hey, we\'re getting recursive now!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$comment</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Tx_BlogExample_Domain_Model_Comment<span style="color: #339933;">;</span><br />
<span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDate</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAuthor</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Peter Pan'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setEmail</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'peter.pan@example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setContent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Do you need some pills?.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addComment</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$blog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addPost</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$blogRepository</span> <span style="color: #339933;">=</span> t3lib_div<span style="color: #339933;">::</span><span style="color: #004000;">makeInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tx_BlogExample_Domain_Repository_BlogRepository'</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$blogRepository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$blog</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>In a first step, we create a new blog with an administrator, and a post with a comment. We instanciate the <code class="codecolorer php dawn"><span class="php">BlogRepository</span></code> in line 21 and add the blog to it. That&#8217;s all we have to do. The blog is now persisted and can be fetched later from the repository again. We don&#8217;t have to say <code class="codecolorer php dawn"><span class="php">save<span style="color: #009900;">&#40;</span><span style="color: #000088;">$blog</span><span style="color: #009900;">&#41;</span></span></code> at any time. The repository &#8220;takes care&#8221; of the blog.</p>
<p>Keep in mind that you have to instanciate the repository with <code class="codecolorer php dawn"><span class="php">t3lib_div<span style="color: #339933;">::</span><span style="color: #004000;">makeInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> as it is a Singleton[<a href="http://blog.typoplanet.de/2010/01/27/the-repository-and-query-object-of-extbase/#footnote_2_327" id="identifier_2_327" class="footnote-link footnote-identifier-link" title="A Singleton is a design pattern to ensure the uniqueness of an object throughout a given scope.">3</a>]. If you instanciate it with <code class="codecolorer php dawn"><span class="php"><span style="color: #000000; font-weight: bold;">new</span></span></code> the Repository will be always an empty one if Extbase searches for objects to be persisted.</p>
<p>The <code class="codecolorer php dawn"><span class="php">BlogRepository</span></code> class is as simple as this:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> Tx_BlogExample_Domain_Repository_BlogRepository <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">extends</span> Tx_Extbase_Persistence_Repository <span style="color: #009900;">&#123;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Most of the methods needed are already implemented in the <code class="codecolorer php dawn"><span class="php">Tx_Extbase_Persistence_Repository</span></code>. These are:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$object</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$object</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$existingObject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newObject</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$modifiedObject</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">countAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Since Extbase 1.1</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">removeAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">countByProperty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Since Extbase 1.1</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findByProperty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000088;">$repository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findOneByProperty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span></div></div>
<p>The methods <code class="codecolorer php dawn"><span class="php">add<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> and <code class="codecolorer php dawn"><span class="php">remove<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> are self-explanatory. <code class="codecolorer php dawn"><span class="php">replace<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> takes an untracked object and puts it at the &#8220;place&#8221; of an existing one where <code class="codecolorer php dawn"><span class="php">update<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> just takes an existing object and updates it with the property values of the modified object.</p>
<p>The <code class="codecolorer php dawn"><span class="php">findByProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> and <code class="codecolorer php dawn"><span class="php">findOneByProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> methods are magic methods where you can replace &#8220;Property&#8221; with the name of a property of the <code class="codecolorer php dawn"><span class="php">Blog</span></code> object. For example we can write <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$blogRepository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findByTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My Blog'</span><span style="color: #009900;">&#41;</span></span></code> to fetch all Blogs with the given title. This also works for objects like in <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$blogRepository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findByAdministrator</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$administrator</span><span style="color: #009900;">&#41;</span></span></code> but not yet for properties holding aggregates. Thus, <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$blogRepository</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findByPost</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span></span></code> won&#8217;t work by now. <code class="codecolorer php dawn"><span class="php">findOneByProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> is pretty similar to <code class="codecolorer php dawn"><span class="php">findByProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> but returns the only first Object found.</p>
<p>The <code class="codecolorer php dawn"><span class="php">countAll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> and <code class="codecolorer php dawn"><span class="php">countByProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> methods are similar to the according <code class="codecolorer php dawn"><span class="php">find</span></code> methods. But the don&#8217;t build objects. They only count resulting objects.</p>
<p>All these methods keep the underlying storage solution (mostly a relational database) transparent to the user[<a href="http://blog.typoplanet.de/2010/01/27/the-repository-and-query-object-of-extbase/#footnote_3_327" id="identifier_3_327" class="footnote-link footnote-identifier-link" title="&amp;#8220;User&amp;#8221; means in our case the ::CODECOLORER_BLOCK_76:: object in which we fetch the blogs and hand them to the ::CODECOLORER_BLOCK_77::. More on the Model-View-Controller Pattern in a later post.">4</a>]. But what if we have special constraints that are not covered with the methods above? Let&#8217;s say we want to find the five most recent posts of a given blog. Then we can use a <code class="codecolorer php dawn"><span class="php">Query</span></code> object.  Let&#8217;s ask the <code class="codecolorer php dawn"><span class="php">PostRepository</span></code> for those posts:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> Tx_BlogExample_Domain_Repository_PostRepository<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">extends</span> Tx_Extbase_Persistence_Repository <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> findRecentByBlog<span style="color: #009900;">&#40;</span>Tx_BlogExample_Domain_Model_Blog <span style="color: #000088;">$blog</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">matching</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blog'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blog</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOrderings</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'date'</span> <span style="color: #339933;">=&gt;</span> Tx_Extbase_Persistence_QueryInterface<span style="color: #339933;">::</span><span style="color: #004000;">ORDER_DESCENDING</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLimit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>integer<span style="color: #009900;">&#41;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$posts</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The method <code class="codecolorer php dawn"><span class="php">createQuery<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> returns an appropriate <code class="codecolorer php dawn"><span class="php">Query</span></code> object suitable for <code class="codecolorer php dawn"><span class="php">Post</span></code> objects. In Line 6 we define the constraint the posts should match: <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">matching</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>constraint<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span></span></code>. The constraint is returned by <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blog'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blog</span><span style="color: #009900;">&#41;</span></span></code>. There are some more methods returning a constraint:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logicalAnd</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$constraint1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$constraint2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logicalOr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$constraint1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$constraint2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logicalNot</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$constraint</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">withUid</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$uid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #339933;">,</span> <span style="color: #000088;">$caseSensitive</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">in</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Since Extbase 1.1</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">contains</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Since Extbase 1.1</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">like</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lessThan</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lessThanOrEqual</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">greaterThan</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">greaterThanOrEqual</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$propertyName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$operand</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>We can define the orderings with <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOrderings</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>orderings<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span></span></code> where <code class="codecolorer php dawn"><span class="php"><span style="color: #009900;">&#91;</span>orderings<span style="color: #009900;">&#93;</span></span></code> is expected to be an array of property-order pairs. There are two constants defining the order:</p>
<ul>
<li>Order ascending: <code class="codecolorer php dawn"><span class="php">Tx_Extbase_Persistence_QueryInterface<span style="color: #339933;">::</span><span style="color: #004000;">ORDER_ASCENDING</span></span></code></li>
<li>Order descending: <code class="codecolorer php dawn"><span class="php">Tx_Extbase_Persistence_QueryInterface<span style="color: #339933;">::</span><span style="color: #004000;">ORDER_DESCENDING</span></span></code></li>
</ul>
<p>We limit the result set to a maximum of five posts with <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLimit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>integer<span style="color: #009900;">&#41;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span></span></code>. And finally invoke <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> which returns us the already build posts with all their comments inside (if we are not &#8220;lazy&#8221; ;-) ). There is also a method <code class="codecolorer php dawn"><span class="php"><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> which does  not fetch the resulting posts but counts them. Note that the <code class="codecolorer php dawn"><span class="php">Query</span></code> object enables chaining. Thus, the following code does the same as the given above:</p>
<div class="codecolorer-container php dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> findRecentByBlog<span style="color: #009900;">&#40;</span>Tx_BlogExample_Domain_Model_Blog <span style="color: #000088;">$blog</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">matching</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blog'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blog</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOrderings</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'date'</span> <span style="color: #339933;">=&gt;</span> Tx_Extbase_Persistence_QueryInterface<span style="color: #339933;">::</span><span style="color: #004000;">ORDER_DESCENDING</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLimit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>integer<span style="color: #009900;">&#41;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>That&#8217;s it for today. I hope you got a deeper insight and I am looking forward to your comments. Maybe you want to join the discussion on the related <a href="http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc">mailing list</a>. I have taken most of the code from the extension <code class="codecolorer php dawn"><span class="php">BlogExample</span></code> which is available in the <a href="http://typo3.org/extensions/repository/view/blog_example/current/">Extension Repository (TER)</a>. </p>
<h3>Footnotes</h3><ol class="footnotes"><li id="footnote_0_327" class="footnote">Extbase is a framework to develop Extensions for <a title="TYPO3 project page" href="http://www.typo3.org">TYPO3</a>.</li><li id="footnote_1_327" class="footnote">Fo a brief introduction in DDD visit <a href="http://www.typo3-media.com/blog/domain-driven-design-introduction.html" target="_blank">www.typo3-media.com</a></li><li id="footnote_2_327" class="footnote">A <a title="Wikipedia article about the Singleton pattern" href="http://en.wikipedia.org/wiki/Singleton_pattern">Singleton</a> is a design pattern to ensure the uniqueness of an object throughout a given scope.</li><li id="footnote_3_327" class="footnote">&#8220;User&#8221; means in our case the <code class="codecolorer php dawn"><span class="php">Controller</span></code> object in which we fetch the blogs and hand them to the <code class="codecolorer php dawn"><span class="php">View</span></code>. More on the Model-View-Controller Pattern in a later post.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2010/01/27/the-repository-and-query-object-of-extbase/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>A walk through the persistence layer of Extbase</title>
		<link>http://blog.typoplanet.de/2009/07/16/a-walk-trough-the-persistence-layer-of-extbase/</link>
		<comments>http://blog.typoplanet.de/2009/07/16/a-walk-trough-the-persistence-layer-of-extbase/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 09:34:16 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Extbase]]></category>
		<category><![CDATA[extension development]]></category>
		<category><![CDATA[flow3]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=275</guid>
		<description><![CDATA[Extbase[1] is the new frame-work for TYPO3 extension developers introduced in TYPO3 v4.3. In this article I will give you a brief overview over the persistence layer of Extbase. It falls into different (sub)layers — each of the with different responsibilities. Let&#8217;s start our journey from the top level. 1. Repository A Repository is the first [...]]]></description>
			<content:encoded><![CDATA[<p>Extbase[<a href="http://blog.typoplanet.de/2009/07/16/a-walk-trough-the-persistence-layer-of-extbase/#footnote_0_275" id="identifier_0_275" class="footnote-link footnote-identifier-link" title="For more information about Extbase, see&nbsp;Project Page (developer relevant) or my article in the t3n magazine (german only) ">1</a>] is the new frame-work for <a title="TYPO3 project page" href="http://www.typo3.org">TYPO3</a> extension developers introduced in TYPO3 v4.3. In this article I will give you a brief overview over the persistence layer of Extbase. It falls into different (sub)layers — each of the with different responsibilities. Let&#8217;s start our journey from the top level.<span id="more-275"></span></p>
<p><strong>1. Repository</strong></p>
<p>A Repository is the first objects a developer comes in contact to. It handles only domain objects and provide task oriented interface to retrieve them by saying findByFoo(&#8216;Bar&#8217;). Most of the time you are done.</p>
<p><strong>2. Query</strong></p>
<p>The next level is the Query object. It provides methods to create an abstract query (abstract in sense of abstracted from where the objects come from). It has no clue about the underlying structure of the storage. It even does not now if it is based on a relational model or a tree model (like the content repository of [FLOW3|FLOW3 is a next generation web application framework built for the upcoming TYPO3 v5]). It also invokes the DataMapper (see below). An extension developer uses the Query object to create his own findByFoo() methods for  his Repositories.</p>
<p><strong>3. QueryObjectModel</strong></p>
<p>Deeper and deeper we dig &#8230; In comparison to the Query object Query Object Model knows about the underlying concepts of relations and thus Joins and Orderings. An extension developer may use this class to specify more complex and &#8220;relational model&#8221; aware queries. That makes the creation of queries (esp. Joins) al little bit laborious. But it helps to keep abstraction.</p>
<p><strong>4. StorageBackend</strong></p>
<p>The Storage Backend translates the Query Object Model in syntactical correct statement (SQL). It also invokes the call to the database via a handler. An extension developer normally does not have to mak his hands dirty with SQL (which is in most cases the best way to improve performance and security).</p>
<p><strong>5. DatabaseHandler</strong></p>
<p>The Database Handler prepares queries, fetches the result set. It can be simply the [t3lib_db|A class in TYPO3 providing methods to access a database], or [PDO|PHP Data Objects], or your preferred solution.</p>
<p><strong>6. DataMapper</strong></p>
<p>And finally the Data Mapper. It maps the resulting rows on the Domain Object (it creates an empty object and fills it with the converted property values). It also resolves relations according to the loading strategy (eg. Lazy Loading Proxy).</p>
<p>Puh! Now we are done. Hope you enjoyed the journey.</p>
<p><strong>F.A.Q</strong></p>
<p><strong>Q</strong> Are you nuts! Six different layers, dozens of objects, and bunch of new things to learn! I only wanted to say &#8220;SELECT * FROM Tx_MyExt_Foo WHERE &#8230;&#8221;!<br />
<strong>A</strong> You are right: I am nuts (at least a litte bit ;-)). But now we are fully compatible to the (Query) API of FLOW3 and reached the best level to port Extensions forward. And I really like the Idea of having totally freedom of choice.</p>
<p><strong>Q</strong> And what about performance?<br />
<strong>A</strong> That’s indeed a very important point. We will do some extensive profiling sessions, implement Lazy Loading strategies, and strive for optimized Queries.</p>
<p>And please keep in mind: 90% of the work is based on the concepts and code of <a title="FLOW3 project page" href="http://flow3.typo3.org/">FLOW3</a>. Credits goes to the FLOW3 team.</p>
<h3>Footnotes</h3><ol class="footnotes"><li id="footnote_0_275" class="footnote">For more information about Extbase, see <a title="Extbase project page" href="http://forge.typo3.org/projects/show/typo3v4-mvc">Project Page (developer relevant)</a> or my <a title="Article about Extbase" href="http://t3n.yeebase.com/magazin/neues-mvc-framework-extbase-ebnet-weg-4x-flow3-zukunft-222472/">article in the t3n magazine (german only)</a> </li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2009/07/16/a-walk-trough-the-persistence-layer-of-extbase/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>TYPO3 v5—The mental Transition</title>
		<link>http://blog.typoplanet.de/2009/03/30/typo3-v5%e2%80%94the-mental-transition/</link>
		<comments>http://blog.typoplanet.de/2009/03/30/typo3-v5%e2%80%94the-mental-transition/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 15:19:00 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Development Process]]></category>
		<category><![CDATA[extension development]]></category>
		<category><![CDATA[flow3]]></category>
		<category><![CDATA[transition]]></category>
		<category><![CDATA[typo3 v5]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=213</guid>
		<description><![CDATA[The upcoming Version 5 of TYPO3 is rewritten from scratch. It is based on a new framework called FLOW3. With TYPO3 v5 the [API&#124;Application Programming Interface] will change completely[1]. There are also a couple of new programming paradigms and patterns. Personally, I am very enthusiastic about the &#8220;new way&#8221;. The past couple of months I had [...]]]></description>
			<content:encoded><![CDATA[<p>The upcoming <a title="Roadmap of TYPO3" href="http://typo3.org/development/roadmap/">Version 5 of TYPO3</a> is rewritten from scratch. It is based on a new framework called <a title="Link to FLOW3" href="http://flow3.typo3.org/">FLOW3</a>. With TYPO3 v5 the [API|Application Programming Interface] will change completely[<a href="http://blog.typoplanet.de/2009/03/30/typo3-v5%e2%80%94the-mental-transition/#footnote_0_213" id="identifier_0_213" class="footnote-link footnote-identifier-link" title="TypoScript will be available in an enhanced, object oriented form">1</a>]. There are also a couple of new programming paradigms and patterns. Personally, I am very enthusiastic about the &#8220;new way&#8221;.</p>
<p>The past couple of months I had numerous discussions about the new version and how to migrate from TYPO3 v4 to v5. And I had to realize that there are several reservations and concerns about all the new things to learn. All of them have to be taken into account to keep the community healthy.<br />
<span id="more-213"></span></p>
<p>The people I have talked with had different backgrounds (different knowledge about TYPO3, different involvement in the community, etc.). Most of them asked one of the following questions:</p>
<ol>
<li>When will TYPO3 v5 be available?</li>
<li>How to migrate content?</li>
<li>How to migrate code (extensions)?</li>
<li>How to migrate me?</li>
</ol>
<p>Questions 1.-3. are already covered by <a title="FAQ about FLOW3" href="http://flow3.typo3.org/about/faq/">an article of the v5 team</a>. The most underestimated question is, how to cope with the mental transition of the developers. Many developers pointed out that they do not have enough time to dig into the new version. Maybe that is a question of how to weight the time spent on daily business and the time spent on (self) education. This prioritization has to be done not only by the developer himself but also by the company he is working for. Therefore, many of the developers decided to wait until FLOW3/TYPO3 v5 is released at a future point in time.</p>
<p>To enable the developers to get in touch with the paradigms of FLOW3 as soon as possible was my personal motivation to be involved in doing a back-port of the  FLOW3 [MVC|MVC stands for Model-View-Controller, a way to separate different concerns of an application] frame-work. The result is <a href="http://forge.typo3.org/projects/show/typo3v4-mvc">ExtBase</a>, a new frame-work for extensions and a successor of [pi_Base|The standard Plugin Base Class of TYPO3 v4]. It will be shipped with TYPO3 v4.3. It is planned to be released in May, 2009.</p>
<p>Furthermore, I am very happy about the decision at the TYPO3 snowboard tour[<a href="http://blog.typoplanet.de/2009/03/30/typo3-v5%e2%80%94the-mental-transition/#footnote_1_213" id="identifier_1_213" class="footnote-link footnote-identifier-link" title="The&nbsp;T3BOARD is my favorite community event. As the weather was&nbsp;bad good this year, we were forced to do a lot of coding ;-) .">2</a>] to back-port Fluid, too. Fluid is a very sophisticated new templating engine mainly developed by <a href="http://sandstorm-media.de/about-us.html">Sebastian Kurfürst</a>.</p>
<p>ExtBase in companion with Fluid encourages the developer of TYPO3 v4 based extensions to code the FLOW3 style right now.  There is already an example extension called BlogExample available[<a href="http://blog.typoplanet.de/2009/03/30/typo3-v5%e2%80%94the-mental-transition/#footnote_2_213" id="identifier_2_213" class="footnote-link footnote-identifier-link" title="You can download ExtBase, Fluid, and the BlogExample via Subversion:&nbsp;https://svn.typo3.org/TYPO3v4/CoreProjects/MVC/">3</a>]. At time of the release of v4.3 we also plan to give a good documentation at hand.</p>
<p>Although we implemented already 80% of the features there is quite a lot of work to do (e.g. implementing view helper classes, doing code reviews, and integration testing, writing documentation and tutorials). Do not hesitate to send me a message, if you want to lend us a helping hand.</p>
<h3>Footnotes</h3><ol class="footnotes"><li id="footnote_0_213" class="footnote">TypoScript will be available in an enhanced, object oriented form</li><li id="footnote_1_213" class="footnote">The <a title="Pictures of the TYPO3BOARD09 - by t3n" href="http://t3n.yeebase.com/t3board09-fotos-typo3-snowboardtour-240178/">T3BOARD</a> is my favorite community event. As the weather was <span style="text-decoration: line-through;">bad</span> good this year, we were forced to do a lot of coding ;-) .</li><li id="footnote_2_213" class="footnote">You can download ExtBase, Fluid, and the BlogExample via Subversion: <a href="https://svn.typo3.org/TYPO3v4/CoreProjects/MVC/">https://svn.typo3.org/TYPO3v4/CoreProjects/MVC/</a></li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2009/03/30/typo3-v5%e2%80%94the-mental-transition/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Domain Driven Content Management</title>
		<link>http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/</link>
		<comments>http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 12:02:31 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Development Process]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[DDD]]></category>
		<category><![CDATA[extension development]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=74</guid>
		<description><![CDATA[This Article is about the Domain of a Content Management System. What is the content all about? How is it structured, oredere, classified? How can it be transformed form one presentation form to another? And how can we deal with content in TYPO3 v5.x?]]></description>
			<content:encoded><![CDATA[<p>Domain Driven Design is—by experience—a strong concept and a good foundation to build TYPO3 extensions upon.</p>
<blockquote><p><strong>Domain-driven design</strong> (DDD) is an approach to the design of software, based on the two premises that complex domain designs should be based on a model, and that, for most software projects, the primary focus should be on the domain and domain logic [...].[<a href="http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/#footnote_0_74" id="identifier_0_74" class="footnote-link footnote-identifier-link" title="Quoted from:&nbsp;http://en.wikipedia.org/wiki/Domain-driven_design; for a brief introduction, visit&nbsp;http://www.typo3-media.com/blog/domain-driven-design-introduction.html">1</a>]</p></blockquote>
<p>The domain represents structure, knowledge and data. A content management system (CMS) like TYPO3 has to handle the data of the domain with respect to the domain knowledge. It aggregates the data, and visualizes it as a content of an output format[<a href="http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/#footnote_1_74" id="identifier_1_74" class="footnote-link footnote-identifier-link" title="Generally it delivers a HTML page but that can also be PDF, SVG, or any other format">2</a>].</p>
<p>A question emerges: How should the data stored in a domain be mapped on the content of the output? <span id="more-74"></span>You might say: &#8220;Hey, what&#8217;s the problem? The data &#8216;stored&#8217; in the extension <em>is</em> already the content to be displayed!&#8221;. I don&#8217;t think so. Nowadays, the domain of an extension and the domain of the CMS are woven into another. And the following questions are answered by the extension itself:</p>
<ul>
<li>&#8220;What is the title of the article?&#8221;</li>
<li>&#8220;How many articles should be shown on the front-page?</li>
<li>&#8220;Should the subtitle of the article be emphasized?&#8221;</li>
</ul>
<p>So, we have to spend hours and hours to adapt all the templates of an extension to fit in the overall context of a web page. That&#8217;s annoying. Now, let&#8217;s try to solve that issue. The first thing is to assign the questions to the proper domain:</p>
<ul>
<li>&#8220;What is the title of the article?&#8221; → domain of the extension</li>
<li>&#8220;How many articles should be shown on the front-page? → domain of the CMS</li>
<li>&#8220;Should the subtitle of the article be emphasized?&#8221; → domain of the CMS</li>
</ul>
<p>If we finished the separation of the two domains[<a href="http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/#footnote_2_74" id="identifier_2_74" class="footnote-link footnote-identifier-link" title="IMO, this has to be done soon for TYPO3 v5">3</a>] we are ready to take the next step: mapping the domain of the extension onto the output generated by the CMS. I propose a two-step process[<a href="http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/#footnote_3_74" id="identifier_3_74" class="footnote-link footnote-identifier-link" title="This is a well known pattern called Two-Step-View (http://martinfowler.com/eaaCatalog/twoStepView.html).">4</a>]:</p>
<ol>
<li>Map the domain objects of the extension onto the content object aggregate of the CMS</li>
<li>Transform the content object aggregate to the output format</li>
</ol>
<p>The first step maps the domain objects of the extension onto content objects[<a href="http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/#footnote_4_74" id="identifier_4_74" class="footnote-link footnote-identifier-link" title="These content objects should be &amp;#8220;naked&amp;#8221; content objects and not be overloaded like the cObj today.&nbsp;And they should &amp;#8220;real&amp;#8221; objects in the sense of OOP">5</a>]. These aggregated content objects represent the structure[<a href="http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/#footnote_5_74" id="identifier_5_74" class="footnote-link footnote-identifier-link" title="ordinality and carinality">6</a>] and the semantics of the output, but not its syntax (like &#8220;&lt;h1&gt;The Title&lt;/h1&gt;&#8221;). The second step transforms the content objects to the output format. This can be done with a templating engine as usual.</p>
<p>The benefit of this two-step process is that the CMS &#8220;owns&#8221; the templates. So we can configure the visual representation of the domain objects of <em>all</em> extensions at one central place.</p>
<h3>An Example</h3>
<p>An example might clarify the process. Let&#8217;s assume I want to write a news extension. The first step is to design the domain of my new extension[<a href="http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/#footnote_6_74" id="identifier_6_74" class="footnote-link footnote-identifier-link" title="This is only a quick sketch. It&amp;#8217;s not meant to be a replacement fo tt_news ;-) ">7</a>]:</p>
<div id="attachment_171" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-171" title="news" src="http://blog.typoplanet.de/wp-content/uploads/2009/03/news-300x268.png" alt="news" width="300" height="268" /><p class="wp-caption-text">The domain model &quot;News Item&quot; of the extension</p></div>
<p>Then I have to examine, what the CMS built-in content object catalog offers to me. Hm, okay, there is already a content object called &#8220;article&#8221;[<a href="http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/#footnote_7_74" id="identifier_7_74" class="footnote-link footnote-identifier-link" title="There isn&amp;#8217;t such a content object in TYPO3 available at the moment. But, let&amp;#8217;s assume to have one ;-) ">8</a>]. It seems to fit my purposes:</p>
<div id="attachment_174" class="wp-caption aligncenter" style="width: 274px"><img class="size-medium wp-image-174" title="article" src="http://blog.typoplanet.de/wp-content/uploads/2009/03/article-264x300.png" alt="The domain model &quot;Article&quot; of the CMS" width="264" height="300" /><p class="wp-caption-text">The domain model &quot;Article&quot; of the CMS</p></div>
<p>I configure the mapping as follows:</p>
<ul>
<li>Author → Author</li>
<li>Text  → Text</li>
<li>Title → Header</li>
<li>Subtitle → Subheader</li>
<li>Teaser → ShortDescription</li>
<li>PublishingDate → Date</li>
</ul>
<p>As a result, I have a generic &#8220;Article Object&#8221; which can be added to a higher-level content object, like &#8220;Main Content Area&#8221; or &#8220;Page&#8221;[<a href="http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/#footnote_8_74" id="identifier_8_74" class="footnote-link footnote-identifier-link" title="IMO a page is nothing but a content element. But that&amp;#8217;s worth another post">9</a>]. My &#8220;News Item&#8221; will be rendered depending on the configuration of the transformation process and the context the article is displayed in. I—as an extension developer—don&#8217;t have to deal with the visualization of my domain objects.</p>
<p>But, what if I want to get the control back over the presentation of my domain object? Then I have to define my own content object class (which can of course extend an existing content object class).</p>
<p>This leads to much more decoupled way of content management based on domain driven design. That&#8217;s why I called it &#8220;Domain Driven Content Management&#8221;.</p>
<p>I&#8217;m anxious to read your comments.</p>
<h3>Footnotes</h3><ol class="footnotes"><li id="footnote_0_74" class="footnote">Quoted from: <a href="http://en.wikipedia.org/wiki/Domain-driven_design">http://en.wikipedia.org/wiki/Domain-driven_design</a>; for a brief introduction, visit <a href="http://www.typo3-media.com/blog/domain-driven-design-introduction.html" target="_blank">http://www.typo3-media.com/blog/domain-driven-design-introduction.html</a></li><li id="footnote_1_74" class="footnote">Generally it delivers a HTML page but that can also be PDF, SVG, or any other format</li><li id="footnote_2_74" class="footnote">IMO, this has to be done soon for TYPO3 v5</li><li id="footnote_3_74" class="footnote">This is a well known pattern called Two-Step-View (<a href="http://martinfowler.com/eaaCatalog/twoStepView.html">http://martinfowler.com/eaaCatalog/twoStepView.html</a>).</li><li id="footnote_4_74" class="footnote">These content objects should be &#8220;naked&#8221; content objects and not be overloaded like the cObj today. And they should &#8220;real&#8221; objects in the sense of OOP</li><li id="footnote_5_74" class="footnote">ordinality and carinality</li><li id="footnote_6_74" class="footnote">This is only a quick sketch. It&#8217;s not meant to be a replacement fo tt_news ;-) </li><li id="footnote_7_74" class="footnote">There isn&#8217;t such a content object in TYPO3 available at the moment. But, let&#8217;s assume to have one ;-) </li><li id="footnote_8_74" class="footnote">IMO a page is nothing but a content element. But that&#8217;s worth another post</li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2009/03/07/domain-driven-content-management/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Some thoughts on extension development</title>
		<link>http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/</link>
		<comments>http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 17:02:15 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Development Process]]></category>
		<category><![CDATA[DDD]]></category>
		<category><![CDATA[extension development]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[ontology]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=92</guid>
		<description><![CDATA[Todays development process of a TYPO3 extension can be characterized by "Database Driven Design". In this article I describe my personal vision of a more modern approach - and beyond.]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s development process of a TYPO3 extension comprises (usually) the following steps:</p>
<ol>
<li>collect clients&#8217; or personal needs</li>
<li>design the relational model (database design)</li>
<li>scaffold the extension using the kickstarter</li>
<li>add a lot of database queries template handling to the file _pi1, _pi2, _pi3 etc.</li>
<li>design the templates</li>
</ol>
<p>This ends up in an extension design which is hard to maintain &#8211; especially for larger projects. A more modern approach uses the Model View Controller Pattern[<a href="http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/#footnote_0_92" id="identifier_0_92" class="footnote-link footnote-identifier-link" title="http://en.wikipedia.org/wiki/Model&ndash;view&ndash;controller">1</a>].<span id="more-92"></span> One of the advantages of this pattern is to enable the developer to focus on the domain of the client (and thus the domain model of the extension). So, the MVC pattern is a prerequisite for Domain Driven Design[<a href="http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/#footnote_1_92" id="identifier_1_92" class="footnote-link footnote-identifier-link" title="See http://en.wikipedia.org/wiki/Domain-driven_design or&nbsp;t3n_nr11_domain_driven_design.pdf">2</a>]. This leads to a slightly different development process:</p>
<ol>
<li>collect clients or personal needs</li>
<li>design the domain model (classes) translating the domain knowledge of the client into UML</li>
<li>scaffolding the extension using a kickstarter</li>
<li>adding the business logic to the domain model classes</li>
<li>design the templates</li>
</ol>
<p>What are the pros of this approach</p>
<ul>
<li>The developer and the client use a common language[<a href="http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/#footnote_2_92" id="identifier_2_92" class="footnote-link footnote-identifier-link" title="This is also called &amp;#8220;ubiquitous language&amp;#8221; in the context of domain driven design">3</a>].</li>
<li>The domain model is more decoupled from the implementation architecture.</li>
<li>It&#8217;s clearly defined where the business logic resides (in the domain model classes).</li>
</ul>
<p>&#8230; and the cons</p>
<ul>
<li>It adds complexity to the extension[<a href="http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/#footnote_3_92" id="identifier_3_92" class="footnote-link footnote-identifier-link" title="Complexity increases by having a lot of classes, and methods to enable interaction between these classes">4</a>].</li>
<li>It forces the developer to learn new programing paradigms, which might be difficult to schedule in the daily work.</li>
</ul>
<p>To be consequent we have to go one step further. The domain knowledge is captured in natural language. But natural language is much more expressive than object oriented software design in UML. As a consequence, there is a mismatch between the domain model expressed by the domain experts (the client) and the object oriented model expressed in UML[<a href="http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/#footnote_4_92" id="identifier_4_92" class="footnote-link footnote-identifier-link" title="There is also a mismatch between the model expressed in UML and the relational model.">5</a>].</p>
<p>If we want to keep all the information of the domain experts we have to define an ontology[<a href="http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/#footnote_5_92" id="identifier_5_92" class="footnote-link footnote-identifier-link" title="The term ontology has a philosophical background. I prefer the practical use in the context of semantic web applications&nbsp;http://en.wikipedia.org/wiki/Ontology_(information_science).">6</a>]. To express the domain knowledge in an ontology, OWL[<a href="http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/#footnote_6_92" id="identifier_6_92" class="footnote-link footnote-identifier-link" title="http://www.w3.org/2001/sw/BestPractices/SE/ODSD/">7</a>] seems to be a good solution to me, as it is a W3C standard and targets web applications. To edit ontologies I played around with Protégé[<a href="http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/#footnote_7_92" id="identifier_7_92" class="footnote-link footnote-identifier-link" title="http://protege.stanford.edu/overview/protege-owl.html">8</a>].</p>
<p>In the end, we will have a process which can be named &#8220;Ontology Driven Extension Development Process&#8221;:</p>
<ol style="text-align: left; ">
<li>collect clients or personal needs</li>
<li>design the ontology using the same language as the client does</li>
<li>scaffolding the extension using a new ontology driven kickstarter</li>
<li>adding the business logic to the domain model classes</li>
<li>design the templates</li>
</ol>
<p>What are the pros of this approach</p>
<ul>
<li>The developer and the client use a common language.</li>
<li>The ontology based domain model is independent from the implementation and can be shared across different extensions with different purposes.</li>
</ul>
<p>&#8230; and the cons</p>
<ul>
<li>It adds complexity to the development processes.</li>
<li>It&#8217;s forces the developer to learn completely new paradigms an terms.</li>
</ul>
<p>I&#8217;m looking forward to your comments an appreciate any questions.</p>
<h3>Footnotes</h3><ol class="footnotes"><li id="footnote_0_92" class="footnote"><a href="http://en.wikipedia.org/wiki/Model–view–controller" target="_blank">http://en.wikipedia.org/wiki/Model–view–controller</a></li><li id="footnote_1_92" class="footnote">See <a href="http://en.wikipedia.org/wiki/Domain-driven_design" target="_blank">http://en.wikipedia.org/wiki/Domain-driven_design</a> or <a href="http://typo3.org/fileadmin/t3n/articles/t3n_nr11_domain_driven_design.pdf" target="_blank">t3n_nr11_domain_driven_design.pdf</a></li><li id="footnote_2_92" class="footnote">This is also called &#8220;ubiquitous language&#8221; in the context of domain driven design</li><li id="footnote_3_92" class="footnote">Complexity increases by having a lot of classes, and methods to enable interaction between these classes</li><li id="footnote_4_92" class="footnote">There is also a mismatch between the model expressed in UML and the relational model.</li><li id="footnote_5_92" class="footnote">The term ontology has a philosophical background. I prefer the practical use in the context of semantic web applications <a href="http://en.wikipedia.org/wiki/Ontology_(information_science)" target="_blank">http://en.wikipedia.org/wiki/Ontology_(information_science)</a>.</li><li id="footnote_6_92" class="footnote"><a href="http://www.w3.org/2001/sw/BestPractices/SE/ODSD/" target="_blank">http://www.w3.org/2001/sw/BestPractices/SE/ODSD/</a></li><li id="footnote_7_92" class="footnote"><a href="http://protege.stanford.edu/overview/protege-owl.html" target="_blank">http://protege.stanford.edu/overview/protege-owl.html</a></li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2009/03/03/some-thoughts-on-extension-development/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>My personal tool box</title>
		<link>http://blog.typoplanet.de/2009/02/24/my-personal-tool-box/</link>
		<comments>http://blog.typoplanet.de/2009/02/24/my-personal-tool-box/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 09:07:51 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[billings]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[merlin]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[transmit]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=61</guid>
		<description><![CDATA[Every developer has its tool box grown over the years - same with me. Some the tools became quite worn but very convenient. Read about some of my favorite tools.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-69" title="dock" src="http://blog.typoplanet.de/wp-content/uploads/2009/02/dock.gif" alt="dock" width="450" height="23" /></p>
<p>Every developer has its tool box grown over the years &#8211; same with me. Some the tools became quite worn but very convenient. Here are some of my favorite tools.<span id="more-61"></span></p>
<p><span><a href="http://macromates.com/"><strong>TextMate</strong></a></span></p>
<p>This is one of my central apps &#8211; always at hand. After testing Eclipse PDT, Zend Studio, NetBeans more than one time, I always returned to it. It&#8217;s fast, powerful, easily extendable. (There is also a port for Windows users called <a href="http://www.e-texteditor.com/"><span>E-Texteditor</span></a>. So, no excuses!)</p>
<p><strong><a title="git" href="http://git-scm.com/" target="_blank">git</a></strong><span><strong></strong></span></p>
<p>It&#8217;s good practice to keep track of the development using a version control system. I use <del datetime="2010-01-27T19:21:59+00:00">svnX</del> git to manage my code (with git-svn as a frontend for svn).</p>
<p><span><a href="http://www.panic.com/transmit/"><strong>Transmit</strong><span><strong></strong></span></a></span></p>
<p>I use Transmit to access my servers via (S)FTP. It&#8217;s not perfect, but it works well <a href="http://muffinresearch.co.uk/archives/2006/06/13/use-tabs-in-textmate-for-remote-files-opened-by-transmit/"><span>with TextMate</span></a>.</p>
<p><span><a href="http://www.sequelpro.com/"><strong>Sequel Pro</strong><span><strong></strong></span></a></span></p>
<p>I often have to check and change database entries while developing an application. Sequel Pro is really a convenient front end for SQL databases-and it&#8217;s free!</p>
<p><span><a href="http://www.projectwizards.net/en/products/merlin"><strong>Merlin</strong><span><strong></strong></span></a></span></p>
<p>Merlin is a native Mac OS X project management tool. It&#8217;s much better (in sense of efficiency for the common developer) than MS Project, which I also know very well.</p>
<p><span><a href="http://www.billingsapp.com/"><strong>Billings</strong><span><strong></strong></span></a></span></p>
<p>At the end of the day, I have to write an invoice (or statement ;-)). I do that with Billings.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2009/02/24/my-personal-tool-box/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>What I read about development</title>
		<link>http://blog.typoplanet.de/2009/02/23/what-i-read-about-development/</link>
		<comments>http://blog.typoplanet.de/2009/02/23/what-i-read-about-development/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 15:07:01 +0000</pubDate>
		<dc:creator>Jochen Rau</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[patterns]]></category>

		<guid isPermaLink="false">http://blog.typoplanet.de/?p=41</guid>
		<description><![CDATA[Have a look at some of the books I’m reading (again and again). They were really eye-openers to me.]]></description>
			<content:encoded><![CDATA[<p>Here are some of the books I&#8217;m reading (again and again). They were really eye-openers to me.<span id="more-41"></span></p>
<table border="0">
<tbody>
<tr>
<td valign="top"><img class="alignnone size-full wp-image-221" title="31ywgz51v-l_sl110_" src="http://blog.typoplanet.de/wp-content/uploads/2009/03/31ywgz51v-l_sl110_.jpg" alt="31ywgz51v-l_sl110_" width="82" height="110" /></td>
<td style="padding-left: 30px;" valign="top"><strong>Domain-Driven Design</strong><br />
Eric Evans. Addison-Wesley Professional 2003, Hardcover,	 560 pages, $47.48</td>
</tr>
<tr>
<td valign="top"><img class="alignnone size-full wp-image-222" title="51sbuqixz9l_sl110_" src="http://blog.typoplanet.de/wp-content/uploads/2009/03/51sbuqixz9l_sl110_.jpg" alt="51sbuqixz9l_sl110_" width="85" height="110" /></td>
<td style="padding-left: 30px;" valign="top"><strong>Applying Domain-Driven Design and Patterns</strong><br />
Jimmy Nilsson. Addison-Wesley Professional 2006, Hardcover, 576 pages, $39.55</td>
</tr>
<tr>
<td valign="top"><img class="alignnone size-full wp-image-220" title="xUnit Test Patterns" src="http://blog.typoplanet.de/wp-content/uploads/2009/03/21hzfgxe4ql_sl110_.jpg" alt="xUnit Test Patterns" width="82" height="110" /></td>
<td style="padding-left: 30px;" valign="top"><strong>xUnit Test Patterns</strong><br />
Gerard Meszaros. Addison-Wesley 2007, Hardcover, 833 pages, $41.95</td>
</tr>
<tr>
<td valign="top"><img class="alignnone size-full wp-image-223" title="Patterns of Enterprise Application Architecture" src="http://blog.typoplanet.de/wp-content/uploads/2009/03/51x1k7r6fgl_sl110_.jpg" alt="Patterns of Enterprise Application Architecture" width="88" height="110" /></td>
<td style="padding-left: 30px;" valign="top"><strong>Patterns of Enterprise Application Architecture (Addison-Wesley Signature Series)<br />
</strong><br />
Martin Fowler. Addison-Wesley Professional 2002, Hardcover, 560 pages, $44.03</td>
</tr>
<tr>
<td valign="top"><img class="alignnone size-full wp-image-225" title="Refactoring" src="http://blog.typoplanet.de/wp-content/uploads/2009/02/21zcez5jbtl_sl110_.jpg" alt="Refactoring" width="86" height="110" /></td>
<td style="padding-left: 30px;" valign="top"><strong>Refactoring</strong><br />
Martin Fowler. Addison-Wesley Professional 1999, Hardcover, 464 pages, $38.00</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.typoplanet.de/2009/02/23/what-i-read-about-development/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

