title: Add custom RBAC rule to PhpManager in Yii 2.0
body: <p>I want to add a custom rule to PhpManager RBAC in Yii 2.0.  </p>
  
  <p>Here is the custom rule (@app/rbac/OwnerRule.php):</p>
  
  <pre><code>&lt;?php
  
  namespace app\rbac;
  
  use yii\rbac\Rule;
  
  /**
   * Checks if userID matches user passed via params
   */
  class OwnerRule extends Rule
  {
      public $name = 'isOwner';
  
      public function execute($user, $item, $params)
      {
          $access = false;
          if(isset($params['id'])){ 
              // My custom logic used to set $access
          }
  
          return $access;
      }
  }
  </code></pre>
  
  <p>Here is the RBAC hierarchy file (@app/data/rbac.php)</p>
  
  <pre><code>&lt;?php
  use yii\rbac\Item;
  
  return [
      'manageThing0' =&gt; ['type' =&gt; Item::TYPE_OPERATION, 'description' =&gt; '...', 'bizRule' =&gt; NULL, 'data' =&gt; NULL],
      'manageThing1' =&gt; ['type' =&gt; Item::TYPE_OPERATION, 'description' =&gt; '...', 'bizRule' =&gt; NULL, 'data' =&gt; NULL],
      'manageThing2' =&gt; ['type' =&gt; Item::TYPE_OPERATION, 'description' =&gt; '...', 'bizRule' =&gt; NULL, 'data' =&gt; NULL],
  
      // AND THE ROLES
      'guest' =&gt; [
          'type' =&gt; Item::TYPE_ROLE,
          'description' =&gt; 'Guest',
          'bizRule' =&gt; NULL,
          'data' =&gt; NULL
      ],
  
      'user' =&gt; [
          'type' =&gt; Item::TYPE_ROLE,
          'description' =&gt; 'User',
          'children' =&gt; [
              'guest',
              'manageThing0', // User can edit thing0
          ],
          'bizRule' =&gt; 'return !Yii::$app-&gt;user-&gt;isGuest;',
          'data' =&gt; NULL
      ],
  
      'moderator' =&gt; [
          'type' =&gt; Item::TYPE_ROLE,
          'description' =&gt; 'Moderator',
          'children' =&gt; [
              'user',         // Can manage all that user can
              'manageThing1', // and also thing1
          ],
          'bizRule' =&gt; NULL,
          'data' =&gt; NULL
      ],
  
      'admin' =&gt; [
          'type' =&gt; Item::TYPE_ROLE,
          'description' =&gt; 'Admin',
          'children' =&gt; [
              'moderator',    // can do all the stuff that moderator can
              'manageThing2', // and also manage thing2
          ],
          'bizRule' =&gt; NULL,
          'data' =&gt; NULL
      ],
  
  ]; 
  </code></pre>
  
  <p>How do I use my custom rule in the hierarchy file?</p>