title: Yii2 GridView value call to a model function
body: <p>In my User model I have a function:</p>
  
  <pre><code>public function getRole() {
      if ($this-&gt;role == self::ROLE_USER) {
          return "user";
      } else if ($this-&gt;role == self::ROLE_ADMIN) {
          return "admin";
      }
  
      return "unassigned";
  }
  </code></pre>
  
  <p>In the GridView I'd like to call it, but can't figure out how in Yii2, the old Yii way doesn't seem to work:</p>
  
  <pre><code>[
      'attribute' =&gt; 'role',
      'filter' =&gt; false,
      'format' =&gt; 'raw',
      'value' =&gt; '$model-&gt;getRole()',
  ],
  </code></pre>
  
  <p>I don't want use an anonymous function:</p>
  
  <pre><code>'value' =&gt; function($model) {
      switch($model-&gt;role) {
          case 10:
              return "user";
              break;
          case 90;
              return "admin";
              break;
          default;
              return "unassigned";
              break;
      }
  },
  </code></pre>