title: Is it posible to create a urlManager Rule which preloads an object based on ID?
body: <p>Working with Yii 2.0.4, I'm trying to use urlManager Rule to preload an object based on a given ID in the URL.</p>
  
  <blockquote>
    <p>config/web.php</p>
  </blockquote>
  
  <pre><code>'components' =&gt; [
      'urlManager' =&gt; [
          [
              'pattern' =&gt; 'view/&lt;id:\d+&gt;',
              'route' =&gt; 'site/view',
              'defaults' =&gt; ['client' =&gt; Client::findOne($id)],
          ],
          [
              'pattern' =&gt; 'update/&lt;id:\d+&gt;',
              'route' =&gt; 'site/update',
              'defaults' =&gt; ['client' =&gt; Client::findOne($id)],
          ],
  
      ]
  ]
  </code></pre>
  
  <p>If this works, it will not be necessary to manually find and object each time, for some CRUD actions:</p>
  
  <pre><code>class SiteController extends Controller {
      public function actionView() {
          // Using the $client from the urlManager Rule
          // Instead of using $client = Client::findOne($id);
  
          return $this-&gt;render('view', ['client' =&gt; $client]);
      }
  
      public function actionUpdate() {
          // Using $client from urlManager Rule
          // Instead of using $client = Client::findOne($id);
  
          if ($client-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $client-&gt;save()) {
                  return $this-&gt;redirect(['view', 'id' =&gt; $client-&gt;id]);
              } else {
                  return $this-&gt;render('edit', ['client' =&gt; $client]);
              }
      }
  
  }
  </code></pre>
  
  <p><strong>NOTE:</strong> The above snippets are not working.  They're the idea of what I want to get</p>
  
  <p>Is it possible?  Is there any way to achieve this?</p>