コード例 #1
0
ファイル: Widget.php プロジェクト: inoplate/widget
 /**
  * Render widgets
  * 
  * @param  string $widget
  * @param  array  $data
  * @return array
  */
 public function render($widget, $data = [])
 {
     $raw = '';
     $handlers = $this->load($widget, $data) ?: [];
     foreach ($handlers as $key => $handler) {
         $content = view($handler['view'], $handler['options'])->render();
         if (!is_null($handler['cache'])) {
             $content = $this->cache->remember($handler['id'], $handler['cache'], $content);
         }
         $raw .= $content;
     }
     return $raw;
 }
コード例 #2
0
ファイル: RateLimiter.php プロジェクト: esensi/core
 /**
  * Add rate limit headers to the response.
  *
  * @param  Symfony\Component\HttpFoundation\Response $response
  * @return Symfony\Component\HttpFoundation\Response|void
  */
 public function addHeaders(Response $response = null)
 {
     // Short circuit
     if (is_null($response)) {
         return;
     }
     // Set X-RateLimit headers
     $response->headers->set('X-Ratelimit-Limit', $this->getLimit(), false);
     $response->headers->set('X-Ratelimit-Remaining', $this->getLimit() - $this->getCounter(), false);
     // Enable X-RateLimit-Tag header in debug mode
     if ($this->config->get('app.debug') == true) {
         $response->headers->set('X-Ratelimit-Tag', $this->getTag(), false);
     }
     return $response;
 }