<?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: How to create an instance of a controller</title>
	<atom:link href="http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Thu, 11 Mar 2010 15:41:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/comment-page-1/#comment-113982</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 04 Dec 2008 15:03:07 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=975#comment-113982</guid>
		<description>@Martin: Thanks for sharing your use case!</description>
		<content:encoded><![CDATA[<p>@Martin: Thanks for sharing your use case!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Westin</title>
		<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/comment-page-1/#comment-113882</link>
		<dc:creator>Martin Westin</dc:creator>
		<pubDate>Wed, 03 Dec 2008 10:20:48 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=975#comment-113882</guid>
		<description>@Rui &amp; @cakebaker:
Thought I&#039;d chime in since I call controllers from a shell (cron job).

The cron is an &quot;hourly update&quot; type of cron for aggregating reporting data, send scheduled messages (email, sms...) or performing other timed actions. The reason for calling controllers is that the shell should call all plugins which in turn will decide what needs to be done for that plugin.

Since each plugin has a PluginnameController and that the call is an &quot;external&quot; request, a controller call seems quite sensibile. The alternative would be some kind of PluginnameModel (which would not really be much of a model) or load a custom shell task located somewhere in the plugin, which would take care of any periodical stuff needed.

OK, I just thought I&#039;d provide an example of when calling a controller might be used.</description>
		<content:encoded><![CDATA[<p>@Rui &amp; @cakebaker:<br />
Thought I&#8217;d chime in since I call controllers from a shell (cron job).</p>
<p>The cron is an &#8220;hourly update&#8221; type of cron for aggregating reporting data, send scheduled messages (email, sms&#8230;) or performing other timed actions. The reason for calling controllers is that the shell should call all plugins which in turn will decide what needs to be done for that plugin.</p>
<p>Since each plugin has a PluginnameController and that the call is an &#8220;external&#8221; request, a controller call seems quite sensibile. The alternative would be some kind of PluginnameModel (which would not really be much of a model) or load a custom shell task located somewhere in the plugin, which would take care of any periodical stuff needed.</p>
<p>OK, I just thought I&#8217;d provide an example of when calling a controller might be used.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Story</title>
		<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/comment-page-1/#comment-113635</link>
		<dc:creator>Mark Story</dc:creator>
		<pubDate>Sat, 29 Nov 2008 03:39:28 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=975#comment-113635</guid>
		<description>Daniel:  must have missed it hiding way up at the top ;) my bad.</description>
		<content:encoded><![CDATA[<p>Daniel:  must have missed it hiding way up at the top ;) my bad.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pages tagged "how-to"</title>
		<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/comment-page-1/#comment-113613</link>
		<dc:creator>Pages tagged "how-to"</dc:creator>
		<pubDate>Fri, 28 Nov 2008 15:18:38 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=975#comment-113613</guid>
		<description>[...] bookmarks tagged how-toBusiness Checks How to create an instance of a controller - cakeba...&#160;saved by 1 others  &#160;&#160;&#160;&#160;narutoboi92 bookmarked on 11/28/08 &#124; [...]</description>
		<content:encoded><![CDATA[<p>[...] bookmarks tagged how-toBusiness Checks How to create an instance of a controller &#8211; cakeba&#8230;&nbsp;saved by 1 others  &nbsp;&nbsp;&nbsp;&nbsp;narutoboi92 bookmarked on 11/28/08 | [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/comment-page-1/#comment-113599</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 28 Nov 2008 07:48:13 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=975#comment-113599</guid>
		<description>@Mark, Repsah: Thanks for your comments!

@Mark: No, I didn&#039;t forgot the init() callback. At least in the current version (rev. 7897) from the repository the init() callback is automatically called if you use Controller::constructClasses(), see &lt;a href=&quot;https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/controller/controller.php#L413&quot; rel=&quot;nofollow&quot;&gt;https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/controller/controller.php#L413&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>@Mark, Repsah: Thanks for your comments!</p>
<p>@Mark: No, I didn&#8217;t forgot the init() callback. At least in the current version (rev. 7897) from the repository the init() callback is automatically called if you use Controller::constructClasses(), see <a href="https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/controller/controller.php#L413" rel="nofollow">https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/controller/controller.php#L413</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: http-repsah.pip.verisignlabs.com-</title>
		<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/comment-page-1/#comment-113582</link>
		<dc:creator>http-repsah.pip.verisignlabs.com-</dc:creator>
		<pubDate>Thu, 27 Nov 2008 23:20:00 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=975#comment-113582</guid>
		<description>I was the one, it might make little sense to you and I might be totally wrong at doing it, but rather that writing a complete different application to handle certain situations I&#039;d rather find a way to access my controllers through a script run by crontab, which I found and I keep using with satisfactory results.</description>
		<content:encoded><![CDATA[<p>I was the one, it might make little sense to you and I might be totally wrong at doing it, but rather that writing a complete different application to handle certain situations I&#8217;d rather find a way to access my controllers through a script run by crontab, which I found and I keep using with satisfactory results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Story</title>
		<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/comment-page-1/#comment-113533</link>
		<dc:creator>Mark Story</dc:creator>
		<pubDate>Wed, 26 Nov 2008 19:24:40 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=975#comment-113533</guid>
		<description>Daniel, you forgot about &lt;code&gt;Component-&gt;init($controller)&lt;/code&gt;  That is the callback that actually loads the components, which is necessary, as without it the rest of Component&#039;s methods do nothing.

Jonah: As for why you would need to do this, biggest use is in testing.  Testing controllers like a model (by directly running their methods) is the most powerful and flexible way to test controllers.</description>
		<content:encoded><![CDATA[<p>Daniel, you forgot about <code>Component-&gt;init($controller)</code>  That is the callback that actually loads the components, which is necessary, as without it the rest of Component&#8217;s methods do nothing.</p>
<p>Jonah: As for why you would need to do this, biggest use is in testing.  Testing controllers like a model (by directly running their methods) is the most powerful and flexible way to test controllers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/comment-page-1/#comment-113529</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 26 Nov 2008 17:04:31 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=975#comment-113529</guid>
		<description>@Rui: Thanks for your comment!

In one case I have seen that someone tried to use a controller from a shell script. Though, I&#039;m not sure what exactly he tried to accomplish.

Another possible case I could imagine is testing, when you want to have your controller in a certain state.</description>
		<content:encoded><![CDATA[<p>@Rui: Thanks for your comment!</p>
<p>In one case I have seen that someone tried to use a controller from a shell script. Though, I&#8217;m not sure what exactly he tried to accomplish.</p>
<p>Another possible case I could imagine is testing, when you want to have your controller in a certain state.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonah</title>
		<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/comment-page-1/#comment-113528</link>
		<dc:creator>Jonah</dc:creator>
		<pubDate>Wed, 26 Nov 2008 17:00:15 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=975#comment-113528</guid>
		<description>I would not recommend doing this.  CakePHP is not made to do it, and it does not make sense.  And I cannot think of any reasons that you would need to do that.

Thanks for the FYI tho</description>
		<content:encoded><![CDATA[<p>I would not recommend doing this.  CakePHP is not made to do it, and it does not make sense.  And I cannot think of any reasons that you would need to do that.</p>
<p>Thanks for the FYI tho</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rui Cruz</title>
		<link>http://cakebaker.42dh.com/2008/11/26/how-to-create-an-instance-of-a-controller/comment-page-1/#comment-113516</link>
		<dc:creator>Rui Cruz</dc:creator>
		<pubDate>Wed, 26 Nov 2008 11:45:44 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=975#comment-113516</guid>
		<description>As I read your article I was wondering in what kind of situations one would need to do this.

Do you mind giving some concrete examples?</description>
		<content:encoded><![CDATA[<p>As I read your article I was wondering in what kind of situations one would need to do this.</p>
<p>Do you mind giving some concrete examples?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
