-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added assets versioning #12591
Added assets versioning #12591
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,16 +61,22 @@ class $Resource implements ResourceInterface | |
|
||
protected _targetUri { get }; | ||
|
||
protected _version { set, get }; | ||
|
||
protected _autoVersion = false { set }; | ||
|
||
/** | ||
* Phalcon\Assets\Resource constructor | ||
*/ | ||
public function __construct(string type, string path, boolean local = true, boolean filter = true, array attributes = []) | ||
public function __construct(string type, string path, boolean local = true, boolean filter = true, attributes = null, var version = null, var autoVersion = null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Jurigag Do we really need to change attributes type? The Phalcon v4 will have a lot of BC incompatible changes. Could you please try to sort out how to avoid yet another |
||
{ | ||
let this->_type = type, | ||
this->_path = path, | ||
this->_local = local, | ||
this->_filter = filter, | ||
this->_attributes = attributes; | ||
this->_attributes = attributes, | ||
this->_version = version, | ||
this->_autoVersion = autoVersion; | ||
} | ||
|
||
/** | ||
|
@@ -192,12 +198,24 @@ class $Resource implements ResourceInterface | |
*/ | ||
public function getRealTargetUri() -> string | ||
{ | ||
var targetUri; | ||
var targetUri, version, modificationTime; | ||
|
||
let targetUri = this->_targetUri; | ||
if empty targetUri { | ||
let targetUri = this->_path; | ||
} | ||
|
||
let version = this->_version; | ||
|
||
if this->_autoVersion && this->_local { | ||
let modificationTime = filemtime(this->getRealSourcePath()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the filemtime is I/O function, which will be called for each request. right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, right. |
||
let version = version ? version . "." . modificationTime : modificationTime; | ||
} | ||
|
||
if version { | ||
let targetUri = targetUri . "?ver=" . version; | ||
} | ||
|
||
return targetUri; | ||
} | ||
|
||
|
@@ -255,6 +273,14 @@ class $Resource implements ResourceInterface | |
return targetPath; | ||
} | ||
|
||
/** | ||
* Checks if resource is using auto version | ||
*/ | ||
public function isAutoVersion() -> boolean | null | ||
{ | ||
return this->_autoVersion; | ||
} | ||
|
||
/** | ||
* Gets the resource's key. | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function popup() { | ||
alert("Hello World"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function popup() { | ||
alert("Hello World"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function popup() { | ||
alert("Hello World"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to not introduce anymore _prefixed variables. Lets use
autoVersion
instead of_autoVersion
.