{
    "href": "/post/2009/04/01/solar-mind-read/",
    "relId": "2009/04/01/solar-mind-read",
    "title": "Solar_Mind_Read",
    "author": "pmjones",
    "markup": "html",
    "tags": [
        {
            "href": "/tag/php/",
            "relId": "php",
            "title": "PHP",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        },
        {
            "href": "/tag/solar/",
            "relId": "solar",
            "title": "Solar",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        }
    ],
    "created": "2009-04-01 11:45:40 UTC",
    "updated": [
        "2009-04-01 11:45:40 UTC"
    ],
    "html": "<p>Given yesterday's news that <a href=\"http://www.breitbart.com/article.php?id=D978VQ480&amp;show_article=1\">Honda can now connect thoughts to robotic actuators</a>, we have been given permission to talk about the <a href=\"http://solarphp.com\">Solar</a> PHP implementation of that interface: <code>Solar_Mind_Read</code>.</p>\n<pre><code>&lt;?php\nclass Solar_Mind_Read extends Solar_Base {\n\n    protected $_Solar_Mind_Read = array(\n        'mind' =&gt; null,\n    );\n\n    protected $_mind;\n\n    public function __construct($config = null)\n    {\n        parent::__construct($config);\n\n        $this-&gt;_mind = Solar::dependency(\n            'Honda_Thought_Interface',\n            $this-&gt;_config['mind']\n        );\n    }\n\n    public function fetchIntent($search)\n    {\n        return $this-&gt;_mind-&gt;recall($search);\n    }\n\n    public function doWhatIMean($subject, $callback)\n    {\n        $intent = $this-&gt;fetchIntent($subject);\n        return call_user_func($callback, $intent);\n    }\n\n    public function fetchPhpCode($task)\n    {\n        throw $this-&gt;_exception('ERR_NOT_IMPLEMENTED', array(\n            'task' =&gt; $task,\n        ));\n    }\n}\n?&gt;</code></pre>\n<p>As you can see, we leverage Solar's <a href=\"http://solarphp.org/manual:project_standards:base_class\">base class and inherited configuration</a>, along with its existing <a href=\"http://solarphp.org/manual:solar:dependency_injection\">dependency injection</a> functionality, to receive an existing Honda \"thought\" object at construction time.  We can then see what the user's intent is given a particular subject using the <code>fetchIntent()</code> method.</p>\n<p>Even better, we can pass a callback to the <code>doWhatIMean()</code> method. This means that the user will always get what he wants, not merely what he asks for.</p>\n<p>Finally, as a developer tool, the <code>fetchPhpCode()</code> method will take a task description and generate PHP code for it. We are waiting on a related patch to the PHP RunKit extension for this to be fully implemented. In the mean time, the automatic <a href=\"http://solarphp.com/class/Solar_Base/_exception()\">exception system</a> finds the right exception class and throws it, with localized translation, and information about the task.</p>\n<p>Once <code>Solar_Mind_Read</code> is complete, we believe we will be able to move on to <code>Solar_Mind_Write</code>.  Together, these tools should help the developer with convincing his clients that what they really need is something that's easier to implement, and then with actually implementing it.</p>\n<p>Thanks for your attention; we hope this April Fool's Day article piques your interest in the power of the <a href=\"http://solarphp.com\">Solar Framework for PHP 5</a>. Many thanks to <a href=\"http://killersoft.com\">Clay Loveless</a> for the subject idea. :-)</p>\n"
}
