Example #1
0
 /**
  * Generate a HTML link with role control.
  *
  * @param  string  $url
  * @param  array   $parameters
  * @param  string  $title
  * @param  array   $attributes
  * @param  bool    $secure
  * @return string
  */
 public function roleCheckLink($url, $parameters = array(), $title = null, $attributes = array(), $secure = null)
 {
     if (!$this->manager->hasUrlAccess('GET', $url)) {
         return;
     }
     $url = $this->url->to($url, $parameters, $secure);
     if (is_null($title) || $title === false) {
         $title = $url;
     }
     return '<a href="' . $url . '"' . $this->attributes($attributes) . '>' . $this->entities($title) . '</a>';
 }
Example #2
0
 /**
  * Check if the user have role access
  *
  * @param  array $parameters
  * @return void
  */
 protected function checkRoleAccess(array $parameters = array())
 {
     $formMethod = $this->getMethod(array_get($parameters, 'method', 'post'));
     if (isset($parameters['url'])) {
         return $this->manager->hasUrlAccess($formMethod, $parameters['url']);
     } else {
         if (isset($parameters['route'])) {
             if (is_array($parameters['route'])) {
                 $route = current($parameters['route']);
             } else {
                 $route = $parameters['route'];
             }
             return $this->manager->hasRouteAccess($formMethod, $route);
         } else {
             if (isset($parameters['action'])) {
                 if (is_array($parameters['action'])) {
                     $action = current($parameters['action']);
                 } else {
                     $action = $parameters['action'];
                 }
                 return $this->manager->hasActionAccess($formMethod, $action);
             }
         }
     }
 }