<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Why sfContext::getInstance() Is Bad</title>
	<atom:link href="http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/feed/" rel="self" type="application/rss+xml" />
	<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/</link>
	<description>On The Art Of Web Development</description>
	<lastBuildDate>Fri, 05 Mar 2010 15:08:09 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bernhard</title>
		<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/comment-page-1/#comment-2008</link>
		<dc:creator>Bernhard</dc:creator>
		<pubDate>Fri, 05 Mar 2010 15:08:09 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=380#comment-2008</guid>
		<description>@Interested: Just inject the I18N instance into the form. I&#039;m doing that too. 

$form = new myForm($i18n, ...);

And concerning the helpers... it&#039;s probably better not to use them at all and rely on the underlying implementation. format_date(), f.i., is just a wrapper for sfNumberFormat. So use sfNumberFormat instead.

@John: What do you mean? In the form? Inject them.</description>
		<content:encoded><![CDATA[<p>@Interested: Just inject the I18N instance into the form. I&#8217;m doing that too. </p>
<p>$form = new myForm($i18n, &#8230;);</p>
<p>And concerning the helpers&#8230; it&#8217;s probably better not to use them at all and rely on the underlying implementation. format_date(), f.i., is just a wrapper for sfNumberFormat. So use sfNumberFormat instead.</p>
<p>@John: What do you mean? In the form? Inject them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/comment-page-1/#comment-2007</link>
		<dc:creator>John</dc:creator>
		<pubDate>Fri, 05 Mar 2010 15:00:08 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=380#comment-2007</guid>
		<description>How is it possible to get &quot;multiple sfUser instances&quot; ?</description>
		<content:encoded><![CDATA[<p>How is it possible to get &#8220;multiple sfUser instances&#8221; ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Interested</title>
		<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/comment-page-1/#comment-2006</link>
		<dc:creator>Interested</dc:creator>
		<pubDate>Fri, 05 Mar 2010 14:57:45 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=380#comment-2006</guid>
		<description>And how about I18n or other helpers loading in Form, or Model class (sfContext::getInstance()-&gt;getConfiguration()-&gt;loadHelpers(&#039;I18N&#039;);)</description>
		<content:encoded><![CDATA[<p>And how about I18n or other helpers loading in Form, or Model class (sfContext::getInstance()-&gt;getConfiguration()-&gt;loadHelpers(&#8217;I18N&#8217;);)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher Shennan</title>
		<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/comment-page-1/#comment-1911</link>
		<dc:creator>Christopher Shennan</dc:creator>
		<pubDate>Tue, 16 Feb 2010 15:57:19 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=380#comment-1911</guid>
		<description>I&#039;ve usually come across this when using sfForm and I get around this by using the constructor injector mentioned above but pass the object I want as an option i.e. 

$form = new myForm(array(), array(&#039;sf_guard_user&#039; =&gt; $user));

Passing it in this manner allows me to access it in the form class via $this-&gt;options[&#039;sf_guard_user&#039;];</description>
		<content:encoded><![CDATA[<p>I&#8217;ve usually come across this when using sfForm and I get around this by using the constructor injector mentioned above but pass the object I want as an option i.e. </p>
<p>$form = new myForm(array(), array(&#8217;sf_guard_user&#8217; =&gt; $user));</p>
<p>Passing it in this manner allows me to access it in the form class via $this-&gt;options['sf_guard_user'];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jwesker</title>
		<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/comment-page-1/#comment-1849</link>
		<dc:creator>jwesker</dc:creator>
		<pubDate>Thu, 04 Feb 2010 18:27:27 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=380#comment-1849</guid>
		<description>@gpilotino, Yeah, how is sfContext::getInstace() avoidable from the generator, and also from the form classes? is it possible to inject dependency on the forms too?</description>
		<content:encoded><![CDATA[<p>@gpilotino, Yeah, how is sfContext::getInstace() avoidable from the generator, and also from the form classes? is it possible to inject dependency on the forms too?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Clark</title>
		<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/comment-page-1/#comment-1309</link>
		<dc:creator>David Clark</dc:creator>
		<pubDate>Thu, 03 Dec 2009 14:23:02 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=380#comment-1309</guid>
		<description>THANKS ;
I  have been struggling with dependency injection forever, this really helps!</description>
		<content:encoded><![CDATA[<p>THANKS ;<br />
I  have been struggling with dependency injection forever, this really helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gpilotino</title>
		<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/comment-page-1/#comment-990</link>
		<dc:creator>gpilotino</dc:creator>
		<pubDate>Mon, 09 Nov 2009 15:35:26 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=380#comment-990</guid>
		<description>I can see another situation where you cannot avoid using sfContext::getInstance(): the admin generator.
(ie. how can you have a table_method / peer_method filtered on user credentials without accessing context from the Model ?)</description>
		<content:encoded><![CDATA[<p>I can see another situation where you cannot avoid using sfContext::getInstance(): the admin generator.<br />
(ie. how can you have a table_method / peer_method filtered on user credentials without accessing context from the Model ?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/comment-page-1/#comment-602</link>
		<dc:creator>David</dc:creator>
		<pubDate>Tue, 29 Sep 2009 15:13:22 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=380#comment-602</guid>
		<description>There&#039;s one more thing to add here: if you REALLY need a context in an sfTask (symfony command line task), you can use the following:

  protected function execute($arguments = array(), $options = array())
  {
    $databaseManager = new sfDatabaseManager($this-&gt;configuration);
    sfContext::createInstance($this-&gt;configuration);

    // your code goes here
  }</description>
		<content:encoded><![CDATA[<p>There&#8217;s one more thing to add here: if you REALLY need a context in an sfTask (symfony command line task), you can use the following:</p>
<p>  protected function execute($arguments = array(), $options = array())<br />
  {<br />
    $databaseManager = new sfDatabaseManager($this-&gt;configuration);<br />
    sfContext::createInstance($this-&gt;configuration);</p>
<p>    // your code goes here<br />
  }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dextro</title>
		<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/comment-page-1/#comment-435</link>
		<dc:creator>Dextro</dc:creator>
		<pubDate>Thu, 27 Aug 2009 11:20:30 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=380#comment-435</guid>
		<description>Perfect explanation. Thx!</description>
		<content:encoded><![CDATA[<p>Perfect explanation. Thx!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernhard</title>
		<link>http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/comment-page-1/#comment-415</link>
		<dc:creator>Bernhard</dc:creator>
		<pubDate>Thu, 20 Aug 2009 07:57:31 +0000</pubDate>
		<guid isPermaLink="false">http://webmozarts.com/?p=380#comment-415</guid>
		<description>@Peter: Thank you, fixed :-)</description>
		<content:encoded><![CDATA[<p>@Peter: Thank you, fixed <img src='http://webmozarts.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
