mirror of
https://github.com/processwire/processwire.git
synced 2025-08-19 04:51:22 +02:00
Refactoring of core Template class to improve, optimize and simplify it, plus add new dedicated methods for childTemplates(), parentTemplates(), and allowNewPages().
This commit is contained in:
@@ -23,12 +23,16 @@ class Templates extends WireSaveableItems {
|
||||
|
||||
/**
|
||||
* Reference to all the Fieldgroups
|
||||
*
|
||||
* @var Fieldgroups
|
||||
*
|
||||
*/
|
||||
protected $fieldgroups = null;
|
||||
|
||||
/**
|
||||
* WireArray of all Template instances
|
||||
*
|
||||
* @var TemplatesArray
|
||||
*
|
||||
*/
|
||||
protected $templatesArray;
|
||||
@@ -82,6 +86,30 @@ class Templates extends WireSaveableItems {
|
||||
return $this->templatesArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an item and populate with given data
|
||||
*
|
||||
* #pw-internal
|
||||
*
|
||||
* @param array $a Associative array of data to populate
|
||||
* @return Saveable|Wire
|
||||
* @since 3.0.146
|
||||
*
|
||||
*/
|
||||
public function makeItem(array $a = array()) {
|
||||
|
||||
/** @var Template $item */
|
||||
$template = $this->wire(new Template());
|
||||
$template->loaded(false);
|
||||
foreach($a as $key => $value) {
|
||||
$template->set($key, $value);
|
||||
}
|
||||
$template->loaded(true);
|
||||
$template->resetTrackChanges(true);
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new blank item
|
||||
*
|
||||
|
Reference in New Issue
Block a user