<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Fri, 24 May 2013 21:15:41 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPMaster.com: Patterns for Flexible View Handling, Part 2 - Using Decorators]]></title>
      <guid>http://www.phpdeveloper.org/news/18448</guid>
      <link>http://www.phpdeveloper.org/news/18448</link>
      <description><![CDATA[<p>
PHPMaster.com has posted the second part in their series looking at design patterns in handling views in your framework of choice. In <a href="http://phpmaster.com/flexible-view-manipulation-2/">this new article</a> they focus on the decorator pattern, using additional functionality to augment the results from the view being rendered.
</p>
<blockquote>
It's also feasible to manipulate views in fairly flexible fashion by appealing to the niceties of a few other patterns as well, including the rather underrated <a href="http://en.wikipedia.org/wiki/Decorator_pattern">Decorators</a>. If you're wondering in what parallel universe Decorators get along with views, in this part I'll be showing how to put them to work side by side in nice orchestration to bring to life yet another view module.
</blockquote>
<p>
They create a simple example where an HTML element (based on an interface) is rendered - a span tag - with content passed in on creation. They take this same logic and transfer it over to the View handler, making handlers for difference pieces of the content (outer and inner). These decorators are then passed in the data from the view and rendered in order.
</p>]]></description>
      <pubDate>Wed, 05 Sep 2012 11:18:58 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[MaltBlue.com: Hot to Use the Zend Form ViewScript Decorator in All Modules]]></title>
      <guid>http://www.phpdeveloper.org/news/18337</guid>
      <link>http://www.phpdeveloper.org/news/18337</link>
      <description><![CDATA[<p>
On his MaltBlue.com site today, <i>Matt Setter</i> has a new post showing you how to <a href="http://www.maltblue.com/tips/how-to-make-zend-forms-available-in-all-modules-in-just-one-step">use the Zend_Form ViewScript decorator</a> in your Zend Framework-based application's forms.
</p>
<blockquote>
If you've been using Zend Forms for any length of time, you'll know <a href="http://www.maltblue.com/zend-framework/zend-form-mastery-with-zend-config-part-1-custom-filter-paths">just how flexible and configurable</a> they are. [...] We can, as I'm quite fond of, use the <a href="http://framework.zend.com/manual/en/zend.form.standardDecorators.html#zend.form.standardDecorators.viewScript">ViewScript decorator</a>. This allows us to have nearly 100% control of the configuration of the look and feel of our rendered forms. 
</blockquote>
<p>
The ViewScript decorator lets you have full control over the layout of your form, letting you use a view (file) to define the markup for the form and injecting your elements into it. There is an issue with using the form in other modules though - it can't find the view file by default. The solution is to pass in a viewModule when using the form, showing it where it can find the view.
</p>]]></description>
      <pubDate>Thu, 09 Aug 2012 08:52:38 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Anthony Ferrara's Blog: Handling Plugins In PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17654</guid>
      <link>http://www.phpdeveloper.org/news/17654</link>
      <description><![CDATA[<p>
<i>Anthony Ferrara</i> has a new post today looking at <a href="http://blog.ircmaxell.com/2012/03/handling-plugins-in-php.html">plugin handling</a> and a few of the more common design patterns that can be used to implement them in your applications.
</p>
<blockquote>
A common problem that developers face when building applications is how to allow the application to be "plug-able" at runtime.  Meaning, to allow non-core code to modify the way an application is processed at runtime.  There are a lot of different ways that this can be done, and lots of examples of it in real life.  Over a year ago, I wrote a <a href="http://stackoverflow.com/a/4471363/338665">StackOverflow Answer</a> on this topic.  However, I think it deserves another look.  So let's look at some patterns and common implementations.
</blockquote>
<p>The patterns he covers are:</p>
<ul>
<li>Observer
<li>Mediator
<li>Strategy
<li>Decorator
<li>Chain of Responsibility
</ul>
<p>
For each there's both a bit of sample code showing it in use and links to some examples from various frameworks and other projects.
</p>]]></description>
      <pubDate>Fri, 09 Mar 2012 13:34:38 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Jason Gilmore's Blog: How I Learned to Stop Worrying and Love Zend_Form]]></title>
      <guid>http://www.phpdeveloper.org/news/16753</guid>
      <link>http://www.phpdeveloper.org/news/16753</link>
      <description><![CDATA[<p>
On his blog today <i>Jason Gilmore</i> has a quick post about <a href="http://www.wjgilmore.com/blog/entry/how_i_learned_to_stop_worrying_and_love_zend_form">solving one of his frustrations with Zend_Form</a> (a part of the <a href="http://framework.zend.com">Zend Framework</a>) - the default form decorators.
</p>
<blockquote>
It is a fantastically productive framework, one which I happen to use almost every single day. There was however one feature which absolutely drove me crazy. The Zend_Form component's uses the dd, dl, and dt elements as the default form markup decorators, meaning that even a simple contact form consisting of name, email, and message fields and a submit button [is marked up with dl, dt and dds]. [...]  It goes without saying that the overwhelming majority of developers do not use these elements to mark up their forms, with the sheer number of questions posted to StackOverflow and elsewhere about getting rid of these decorators backing this assertion.
</blockquote>
<p>
He gives his simple solution to the issue, something better than removing all of the decorators and using <a href="http://framework.zend.com/manual/en/zend.form.decorators.html">setDecorator</a> to replace them - a simple partial view that echos out the fields directly. The trick is to use the setDecorators call with a "ViewScript" option pointing to your partial and  setElementDecorators() call to use a "ViewHelper".
</p>]]></description>
      <pubDate>Mon, 22 Aug 2011 13:57:14 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Zend Developer Zone: My Favorite Design Patterns]]></title>
      <guid>http://www.phpdeveloper.org/news/16242</guid>
      <link>http://www.phpdeveloper.org/news/16242</link>
      <description><![CDATA[<p>
On the Zend Developer Zone there's a new article from <i>Keith Casey</i> where he talks about some of his <a href="http://devzone.zend.com/article/14003-My-Favorite-Design-Patterns">favorite design patterns</a> he's come across in his time as a developer - adapter, facade and decorator.
</p>
<blockquote>
Within the <a href="http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29">Design Patterns</a> world, there are four main categories: Architectural, Structural, Creational, and Behavioral. Architectural patterns describe the system as a whole, Structural patterns describe the relationships between objects, Creational handle creating objects, and finally Behavioral describe the communication patterns between objects.  Each of the categories is worth discussion on its own, but in this case we'll stick to the Structural patterns of Adapter, Facade, and Decorator.
</blockquote>
<p>
He describes each of the patterns (no code in this one, just descriptions) and for each mentions some of the tools that the <a href="http://framework.zend.com">Zend Framework</a> has to offer that match up. For example, the Adapter pattern is used in quite a few places in the framework including in the Zend_Db component for the connection types to different databases.
</p>]]></description>
      <pubDate>Mon, 25 Apr 2011 10:38:13 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Function decorators in PHP with PHPDoc and Annotations]]></title>
      <guid>http://www.phpdeveloper.org/news/15841</guid>
      <link>http://www.phpdeveloper.org/news/15841</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has a new post to his blog looking at some of the recent work he's done with <a href="http://gonzalo123.wordpress.com/2011/02/01/function-decorators-in-php-with-phpdoc-and-annotations/">PHPDoc and annotations</a> to create "function decorators" in his code.
</p>
<blockquote>
The idea is to solve the same problem I had when I wrote the previous article. I want to protect the execution of certain functions in a class to only being executed if the user is logged on. [...] The solution with interfaces is clean and simple (no extra libraries need and no reflection need too). The problem is that I can use it only for all the functions of the class.
</blockquote>
<p>
He gives an example class with four different methods (one with annotations) and his annotation parsing class that runs the predispatch and postdispatch methods based on those annotations. He also shows another examples using an abstract class.
</p>]]></description>
      <pubDate>Tue, 01 Feb 2011 13:13:04 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Label Media Blog: Design Patterns in PHP - Decorator Pattern]]></title>
      <guid>http://www.phpdeveloper.org/news/15547</guid>
      <link>http://www.phpdeveloper.org/news/15547</link>
      <description><![CDATA[<p>
<i>Tom Rawcliffe</i> has <a href="http://www.labelmedia.co.uk/blog/posts/design-patterns-decorator-pattern.html">posted the latest installment</a> of his look at design patterns in PHP. This time his focus is on the Decorator pattern.
</p>
<blockquote>
Continuing my series on PHP design patterns, today it's the turn of the Decorator. In contrast to last week's <a href="http://www.labelmedia.co.uk/blog/posts/design-patterns-strategy-pattern.html">Strategy Pattern</a> which is used to change the 'guts' of a class, the Decorator Pattern is used to extend the behavior of a class with different functionality at run time. This is achieved by implementing a 'decorator' class that implements the same interface as the object that you wish to 'decorate' and wraps it's content.
</blockquote>
<p>
The Decorator pattern lets you "decorate" your objects with additional features. He illustrates with a sample "Property" class (that implements an interface) that he wants to extend past the normal property handling. He add a "PropertyDecorator" to the mix that lets it use deocrators for uppercasing and padding the string. There's an example script included at the end that shows how to put it all to use.
</p>]]></description>
      <pubDate>Wed, 08 Dec 2010 09:13:55 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[NETTUTS.com: A Beginner's Guide to Design Patterns ]]></title>
      <guid>http://www.phpdeveloper.org/news/14761</guid>
      <link>http://www.phpdeveloper.org/news/14761</link>
      <description><![CDATA[<p>
On NETTUTS.com today there's <a href="http://net.tutsplus.com/articles/general/a-beginners-guide-to-design-patterns">a new tutorial</a> that introduces a bit more advanced concept in the development process - design patterns.
</p>
<blockquote>
Design patterns are optimized, reusable solutions to the programming problems that we encounter every day. A design pattern is not a class or a library that we can simply plug into our system; it's much more than that. It is a template that has to be implemented in the correct situation. It's not language-specific either. A good design pattern should be implementable in most - if not all - languages, depending on the capabilities of the language. 
</blockquote>
<p>
They introduce a few of the more widely used patterns including the strategy pattern, adapter pattern, factory methods, decorator and singleton patterns. Each comes with a bit of code showing how it would work and a "where would I use this?" section with a better example.
</p>]]></description>
      <pubDate>Thu, 08 Jul 2010 08:47:55 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[ZendCasts.com: Creating Custom Zend_Form Decorators]]></title>
      <guid>http://www.phpdeveloper.org/news/14115</guid>
      <link>http://www.phpdeveloper.org/news/14115</link>
      <description><![CDATA[<p>
On ZendCasts.com today there's a new screencast aimed at showing off <a href="http://www.zendcasts.com/creating-custom-zend_form-decorators/2010/02">custom Zend_Form decorators</a> for your Zend Framework application.
</p>
<blockquote>
This little video tutorial should set you up for building your own custom Zend_Form decorators in 15 minutes. I'll show you how you can make the necessary class and have it easily added to your existing Zend_Form_Decorator configuration.
</blockquote>
<p>
If you'd like to follow along with the tutorial as he walks through it you can <a href="http://zendcasts.googlecode.com/svn/trunk/zc48-creating-custom-decorators/zc48-creating-custom-decorators.zip">grab a copy of the source</a> or, for other examples, <a href="http://code.google.com/p/zendcasts/source/browse/#svn/trunk/zc48-creating-custom-decorators">look through their repository</a>. 
</p>]]></description>
      <pubDate>Tue, 02 Mar 2010 11:10:52 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Matthew Weier O'Phinney's Blog: Creating composite elements]]></title>
      <guid>http://www.phpdeveloper.org/news/12336</guid>
      <link>http://www.phpdeveloper.org/news/12336</link>
      <description><![CDATA[<p>
Based on an example in a previous blog post (seen <a href="http://weierophinney.net/matthew/archives/215-Rendering-Zend_Form-decorators-individually.html">here</a>) <i>Matthew Weier O'Phinney</i> wanted to <a href="http://weierophinney.net/matthew/archives/217-Creating-composite-elements.html">clear a few things up</a> on the "date of birth" element he had mocked up in his Zend_Form example.
</p>
<blockquote>
In my <a href="http://weierophinney.net/matthew/archives/215-Rendering-Zend_Form-decorators-individually.html">last post on decorators</a>, I had an example that showed rendering a "date of birth" element [...]. This has prompted some questions about how this element might be represented as a Zend_Form_Element, as well as how a decorator might be written to encapsulate this logic. Fortunately, I'd already planned to tackle those very subjects for this post! 
</blockquote>
<p>
To be able to use the element in its current state the key lies in the setValue method. More correctly in the overriding of the setValue method. He includes an example class that is smart enough to use that custom form element. It has get and set methods for each of the date fields (month/day/year) and the set/getValue methods that can interact using them. He wraps this all up inside a form decorator and creates an instance of the Date element to help create and handle the properties it has.
</p>]]></description>
      <pubDate>Tue, 14 Apr 2009 10:25:53 -0500</pubDate>
    </item>
  </channel>
</rss>
