mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 18:24:57 +02:00
Add a Template::setRaw() method, phpdoc fix in Paths class and update the $trackChanges property in Wire base class to be protected rather than private (as an optimization)
This commit is contained in:
@@ -8,9 +8,10 @@
|
|||||||
* #pw-summary-paths-only These properties are only useful when accessed from `$config->paths` as they are not HTTP accessible as URLs.
|
* #pw-summary-paths-only These properties are only useful when accessed from `$config->paths` as they are not HTTP accessible as URLs.
|
||||||
* #pw-summary-urls-only These properties apply only to the `$urls` or `$config->urls`. Do not use them with `$config->paths`.
|
* #pw-summary-urls-only These properties apply only to the `$urls` or `$config->urls`. Do not use them with `$config->paths`.
|
||||||
* #pw-summary-pagination These properties apply only to the `$urls` or `$config->urls` and only when pagination is active for the current request.
|
* #pw-summary-pagination These properties apply only to the `$urls` or `$config->urls` and only when pagination is active for the current request.
|
||||||
|
* #pw-var $var
|
||||||
*
|
*
|
||||||
* #pw-body =
|
* #pw-body =
|
||||||
* The Paths class is used by `$config->paths` and `$config->urls`. The `$config->paths` refers to server disk paths
|
* The Paths class is used by `$config->paths` and `$config->urls` (or just `$urls`). The `$config->paths` refers to server disk paths
|
||||||
* while `$config->urls` refers to web server URLs. All of the same properties are present on both, though several properties
|
* while `$config->urls` refers to web server URLs. All of the same properties are present on both, though several properties
|
||||||
* are only useful on one or the other (as outlined below). You can access a path or URL like this:
|
* are only useful on one or the other (as outlined below). You can access a path or URL like this:
|
||||||
* ~~~~~
|
* ~~~~~
|
||||||
@@ -46,6 +47,10 @@
|
|||||||
* In the examples on this page, you can replace the `$urls` variable with `$config->paths` if you need to get the server path
|
* In the examples on this page, you can replace the `$urls` variable with `$config->paths` if you need to get the server path
|
||||||
* instead of a URL. As indicated earlier, `$urls` can aso be accessed at the more verbose `$config->urls` if you prefer.
|
* instead of a URL. As indicated earlier, `$urls` can aso be accessed at the more verbose `$config->urls` if you prefer.
|
||||||
*
|
*
|
||||||
|
* > Please note in the property/method descriptions below that the placeholder `$var` refers to either `$config->paths` or
|
||||||
|
* `$config->urls` (or the shorter alias `$urls`). So `$var->files` (for example) refers to either `$config->paths->files`
|
||||||
|
* or `$config->urls->files` (or the shorter alias `$urls->files`).
|
||||||
|
*
|
||||||
* #pw-body
|
* #pw-body
|
||||||
*
|
*
|
||||||
* ProcessWire 3.x, Copyright 2020 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2020 by Ryan Cramer
|
||||||
|
@@ -746,14 +746,14 @@ class Template extends WireData implements Saveable, Exportable {
|
|||||||
*/
|
*/
|
||||||
protected function setSetting($key, $value) {
|
protected function setSetting($key, $value) {
|
||||||
|
|
||||||
if($key == 'id') {
|
if($key === 'id') {
|
||||||
$value = (int) $value;
|
$value = (int) $value;
|
||||||
|
|
||||||
} else if($key == 'name') {
|
} else if($key === 'name') {
|
||||||
$value = $this->loaded ? $this->wire('sanitizer')->name($value) : $value;
|
$value = $this->loaded ? $this->wire()->sanitizer->templateName($value) : $value;
|
||||||
|
|
||||||
} else if($key == 'fieldgroups_id' && $value) {
|
} else if($key === 'fieldgroups_id' && $value) {
|
||||||
$fieldgroup = $this->wire('fieldgroups')->get($value);
|
$fieldgroup = $this->wire()->fieldgroups->get($value);
|
||||||
if($fieldgroup) {
|
if($fieldgroup) {
|
||||||
$this->setFieldgroup($fieldgroup);
|
$this->setFieldgroup($fieldgroup);
|
||||||
} else {
|
} else {
|
||||||
@@ -778,6 +778,28 @@ class Template extends WireData implements Saveable, Exportable {
|
|||||||
$this->settings[$key] = $value;
|
$this->settings[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set setting value without processing
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $value
|
||||||
|
* @since 3.0.194
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function setRaw($key, $value) {
|
||||||
|
if($key === 'fieldgroups_id') {
|
||||||
|
$fieldgroup = $this->wire()->fieldgroups->get($value);
|
||||||
|
if($fieldgroup) {
|
||||||
|
$this->settings['fieldgroups_id'] = (int) $value;
|
||||||
|
$this->fieldgroup = $fieldgroup;
|
||||||
|
}
|
||||||
|
} else if(isset($this->settings[$key])) {
|
||||||
|
$this->settings[$key] = $value;
|
||||||
|
} else {
|
||||||
|
parent::set($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the cacheExpirePages property
|
* Set the cacheExpirePages property
|
||||||
*
|
*
|
||||||
|
@@ -974,7 +974,7 @@ abstract class Wire implements WireTranslatable, WireFuelable, WireTrackable {
|
|||||||
* @var int Bitmask
|
* @var int Bitmask
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private $trackChanges = 0;
|
protected $trackChanges = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array containing the names of properties (as array keys) that were changed while change tracking was ON.
|
* Array containing the names of properties (as array keys) that were changed while change tracking was ON.
|
||||||
|
@@ -63,8 +63,10 @@ class WireData extends Wire implements \IteratorAggregate, \ArrayAccess {
|
|||||||
if(!is_array($value)) $value = (array) $value;
|
if(!is_array($value)) $value = (array) $value;
|
||||||
return $this->setArray($value);
|
return $this->setArray($value);
|
||||||
}
|
}
|
||||||
$v = isset($this->data[$key]) ? $this->data[$key] : null;
|
if($this->trackChanges) {
|
||||||
if(!$this->isEqual($key, $v, $value)) $this->trackChange($key, $v, $value);
|
$v = isset($this->data[$key]) ? $this->data[$key] : null;
|
||||||
|
if(!$this->isEqual($key, $v, $value)) $this->trackChange($key, $v, $value);
|
||||||
|
}
|
||||||
$this->data[$key] = $value;
|
$this->data[$key] = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user