<?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>Tue, 21 May 2013 05:50:59 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Matthew Turland's Blog: The Configuration Pattern in Zend Framework]]></title>
      <guid>http://www.phpdeveloper.org/news/13292</guid>
      <link>http://www.phpdeveloper.org/news/13292</link>
      <description><![CDATA[<p>
<i>Matthew Turland</i> has <a href="http://ishouldbecoding.com/2009/09/25/the-configuration-pattern-in-zend-framework">pointed out</a> a pattern he's seen happening over and over again in the <a href="http://framework.zend.com">Zend Framework</a>, what he calls the "Configuration Pattern".
</p>
<blockquote>
Here's how it works. Have a look at the constructor for Zend_Form. It accepts an $options parameter, which can be an associative array or Zend_Config instance. If it's an array, setOptions() is called. If it's a Zend_Config instance, setConfig() is called, which then converts the Zend_Config instance to an associative array and passes that to setOptions(). So, either way, you end up in the same method with the same type of data. setOptions() then iterates over the associative array it receives. It takes the index of each element and looks for a corresponding <a href="http://en.wikipedia.org/wiki/Mutator_method">setter method</a>. 
</blockquote>
<p>
This method helps to reduce the overall function calls (including a <a href="http://php.net/method_exists">method_exists</a>) and can help to produce cleaner code in the process. A comment on the post also points out <a href="http://giorgiosironi.blogspot.com/2009/09/zend-framework-api-what-options-is.html">related comments</a> from <i>Matthew Weier O'Phinney</i> about these options.
</p>]]></description>
      <pubDate>Mon, 28 Sep 2009 09:07:31 -0500</pubDate>
    </item>
  </channel>
</rss>
