Example #1
0
 /**
  * {@inheritdoc}
  *
  * @throws ModelNotFoundException
  */
 protected function findModelInParameters($modelParameter, $routeParameters)
 {
     $model = parent::findModelInParameters($modelParameter, $routeParameters);
     if (!$model instanceof Model || $modelParameter->getName() === "me") {
         // `$me` can be invalid if, for example, no user is currently logged
         // in - in this case we can just pass the invalid Player model to
         // the controller without complaining
         return $model;
     } elseif (!$this->canSee($model)) {
         // If the model is not supposed to be visible to the player
         // requesting it, pretend it's not there
         throw new ModelNotFoundException($model->getTypeForHumans());
     }
     return $model;
 }