<?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>Jon&#039;s Blog &#187; zf</title>
	<atom:link href="http://bombdiggity.net/blog/tag/zf/feed/" rel="self" type="application/rss+xml" />
	<link>http://bombdiggity.net/blog</link>
	<description>Ramblings of a php coder</description>
	<lastBuildDate>Fri, 14 May 2010 17:36:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Accessing ZF Application Resources In Controller</title>
		<link>http://bombdiggity.net/blog/2009/12/09/accessing-zf-application-resources-in-controller/</link>
		<comments>http://bombdiggity.net/blog/2009/12/09/accessing-zf-application-resources-in-controller/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 04:15:35 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[resource]]></category>
		<category><![CDATA[zend_application]]></category>
		<category><![CDATA[zf]]></category>

		<guid isPermaLink="false">http://www.bombdiggity.net/blog/?p=162</guid>
		<description><![CDATA[My friend Rob Allen recently posted a quick how-to on how to access your configuration data in application.ini file while in a controller or action helper. The one part Rob didn&#8217;t touch on was how to get resources back. Resources are set when you return something out of your _init&#60;MethodName&#62;. For example when you use [...]]]></description>
			<content:encoded><![CDATA[<p>My friend Rob Allen recently posted a quick how-to on how to <a href="http://akrabat.com/zend-framework/accessing-your-configuration-data-in-application-ini/">access your configuration data in application.ini</a> file while in a controller or action helper. The one part Rob didn&#8217;t touch on was how to get resources back.</p>
<p><span id="more-162"></span></p>
<p>Resources are set when you return something out of your _init&lt;MethodName&gt;. For example when you use the following source code and return the $_logger, Zend_Application stores the returned value in a registry inside the application.</p>
<pre class="brush: php">
// place in your bootstrap file.
public function _initLogger()
{
    $writer = new Zend_Log_Writer_Firebug();
    $_logger = new Zend_Log($writer);
    return $_logger;
}
</pre>
<p>Now the way you get access to the logger is by doing the following inside your controller or controller helper:</p>
<pre class="brush: php">
class IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        // action body
        $logger = $this-&gt;getInvokeArg(&#039;bootstrap&#039;)
                        -&gt;getResource(&#039;logger&#039;);
    }
}
</pre>
<p>The key is the getResource() method.  You pass in the part following the _init from your method name.  This will return the instance of what ever object was returned in the _init method. </p>
<p>Where I got stuck, was since I&#8217;m using the Module Bootstrap for my modules and I only want the logger on specific modules and not the whole application when I used the above code it returned null.  The reason for null was because it was not in the global bootstrap file. To get access to the resources from the module bootstrap you need to use the following code:</p>
<pre class="brush: php">
class Admin_IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        // action body
        $logger = $this-&gt;getInvokeArg(&#039;bootstrap&#039;)
                        -&gt;getResource(&#039;modules&#039;)
                        -&gt;offsetGet($this-&gt;getRequest()-&gt;getModuleName())
                        -&gt;getResource(&#039;logger&#039;);
    }
}
</pre>
<p>I hope this helps someone else out there as it was an eye opener to me when I was told about it via the ZF mailing list.</p>
]]></content:encoded>
			<wfw:commentRss>http://bombdiggity.net/blog/2009/12/09/accessing-zf-application-resources-in-controller/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ZF Curly Quote Character Filter</title>
		<link>http://bombdiggity.net/blog/2009/12/09/zf-curly-quote-character-filter/</link>
		<comments>http://bombdiggity.net/blog/2009/12/09/zf-curly-quote-character-filter/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 15:15:08 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[curly quotes]]></category>
		<category><![CDATA[ms office]]></category>
		<category><![CDATA[zend_filter]]></category>
		<category><![CDATA[zf]]></category>

		<guid isPermaLink="false">http://www.bombdiggity.net/blog/?p=144</guid>
		<description><![CDATA[If your like me and have people who like to write stuff in MS Office first and then post it to the web you get the silly quotes and such that word uses. The quotes and such are not valid UFT-8 and that&#8217;s how I like to store my data in my database so it [...]]]></description>
			<content:encoded><![CDATA[<p>If your like me and have people who like to write stuff in MS Office first and then post it to the web you get the silly quotes and such that word uses. The quotes and such are not valid UFT-8 and that&#8217;s how I like to store my data in my database so it usually dumps out with an error.</p>
<p>I&#8217;ve come up with the following Zend_Filer_Interface so that way you can plug it into anything that has the ability to use Zend_Filter.</p>
<p>Read More for the source code.<br />
<span id="more-144"></span></p>
<p><del datetime="2009-12-10T21:39:16+00:00"><strong>Updated on 12/10/09 to include more characters and remove the html version</strong></del></p>
<p><strong>Updated again on 12/10/09 to make it work with UTF-8 Submitted Forms.  I&#8217;ve spent half the day validaing this and testing it with a HEX editor</strong></p>
<pre class="brush: php">
&lt;?php

class Util_Filter_WordChars implements Zend_Filter_Interface
{
    /**
     * Filter out the invalid characters that word puts in.
     * @param string $value
     * @return string
     */
    public function filter($value)
    {

        $search = array(chr(0xe2) . chr(0x80) . chr(0x98),  // &#039;
            chr(0xe2) . chr(0x80) . chr(0x99),  // &#039;
            chr(0xe2) . chr(0x80) . chr(0x9c),  // &quot;
            chr(0xe2) . chr(0x80) . chr(0x9d),  // &quot;
            chr(0xe2) . chr(0x80) . chr(0x93),  // em dash
            chr(0xe2) . chr(0x80) . chr(0x94),  // en dash
            chr(0xe2) . chr(0x80) . chr(0xa6)); // ...

        $replace = array(
            &#039;\&#039;&#039;,
            &#039;\&#039;&#039;,
            &#039;&quot;&#039;,
            &#039;&quot;&#039;,
            &#039;-&#039;,
            &#039;-&#039;,
            &#039;...&#039;);

        return str_replace($search, $replace, $value);
    }
}
</pre>
<p>This could be changed to put them in the html ascii code to display them but I like the standard single quote and double quote online.</p>
]]></content:encoded>
			<wfw:commentRss>http://bombdiggity.net/blog/2009/12/09/zf-curly-quote-character-filter/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Twitter Service for Zend Framework</title>
		<link>http://bombdiggity.net/blog/2008/11/16/twitter-service-for-zend-framework/</link>
		<comments>http://bombdiggity.net/blog/2008/11/16/twitter-service-for-zend-framework/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 01:05:01 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[zf]]></category>

		<guid isPermaLink="false">http://www.bombdiggity.net/blog/?p=50</guid>
		<description><![CDATA[After almost 2 months of work I am happy to have Zend_Service_Twitter included into the standard trunk for Zend Framework.  Currently Zend_Service_Twitter is schedule to be included in the 1.7 release.]]></description>
			<content:encoded><![CDATA[<p>Earlier this week I had the extreme pleasure of having my first addition to Zend Framework added to the standard library.  I started working on this component after talking with <a href="http://weierophinney.net/matthew/">Matthew Weier O&#8217;Phinney</a> at ZendCon &#8217;08 where he stated that he didn&#8217;t have time to work on implementing the api for use in with the framework.</p>
<p>Zend_Twitter_Service is currently in the standard trunk for Zend Framework and is scheduled to be released with 1.7.  Please check it out and check back for some examples in the next few days.</p>
]]></content:encoded>
			<wfw:commentRss>http://bombdiggity.net/blog/2008/11/16/twitter-service-for-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
