Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Abstracted logic to own methods

  • Loading branch information...
commit 692c06082d57a92fbe819047291a75dd4179a864 1 parent 173a2b6
@DrPheltRight authored
View
8 classes/kohana/controller/publicize.php
@@ -22,15 +22,19 @@ public function action_copy()
{
$asset = $this->request->param('asset');
- if (Kohana::$environment !== Kohana::DEVELOPMENT)
+ if (Publicize::should_copy_to_docroot())
{
$uri = $this->request->param('uri');
// Copy and redirect
Publicize::copy_to_docroot($asset, $uri);
- $this->request->redirect($uri);
+ //$this->request->redirect($uri);
}
+ // Send last modified headers so browsers have a chance
+ $this->response->headers('Last-Modified',
+ date(DATE_RFC1123, filemtime($asset)));
+
// Show live copy
$this->response->send_file($asset);
}
View
24 classes/kohana/publicize.php
@@ -16,13 +16,35 @@ class Kohana_Publicize {
const PUBLIC_FOLDER = 'public';
/**
+ * Should we copy to docroot? We should if not in the
+ * development environment.
+ *
+ * @return boolean
+ */
+ public static function should_copy_to_docroot()
+ {
+ return Kohana::$environment !== Kohana::DEVELOPMENT;
+ }
+
+ /**
+ * Should we set route? We should if not in the
+ * production environment.
+ *
+ * @return boolean
+ */
+ public static function should_set_route()
+ {
+ return Kohana::$environment !== Kohana::PRODUCTION;
+ }
+
+/**
* Sets route if not in production.
*
* @return void
*/
public static function set_route()
{
- if (Kohana::$environment !== Kohana::PRODUCTION)
+ if (self::should_set_route())
{
self::_set_route();
}
Please sign in to comment.
Something went wrong with that request. Please try again.