mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 16:26:59 +02:00
Make Fields::getTags() and Templates::getTags() hookable per @outflux3 processwire/processwire-issues#1369
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
* @method void changedType(Saveable $item, Fieldtype $fromType, Fieldtype $toType) #pw-hooker
|
* @method void changedType(Saveable $item, Fieldtype $fromType, Fieldtype $toType) #pw-hooker
|
||||||
* @method void changeTypeReady(Saveable $item, Fieldtype $fromType, Fieldtype $toType) #pw-hooker
|
* @method void changeTypeReady(Saveable $item, Fieldtype $fromType, Fieldtype $toType) #pw-hooker
|
||||||
* @method bool|Field clone(Field $item, $name = '') Clone a field and return it or return false on fail.
|
* @method bool|Field clone(Field $item, $name = '') Clone a field and return it or return false on fail.
|
||||||
|
* @method array getTags($getFieldNames = false) Get tags for all fields (3.0.179+) #pw-advanced
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -601,7 +602,8 @@ class Fields extends WireSaveableItems {
|
|||||||
if($exception) {
|
if($exception) {
|
||||||
$this->error("Field type change failed. Database reports: $error");
|
$this->error("Field type change failed. Database reports: $error");
|
||||||
$database->exec("DROP TABLE `$table2`"); // QA
|
$database->exec("DROP TABLE `$table2`"); // QA
|
||||||
if($exception) $this->trackException($exception, true);
|
$severe = $this->wire()->process != 'ProcessField';
|
||||||
|
if($exception) $this->trackException($exception, $severe);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -926,13 +928,15 @@ class Fields extends WireSaveableItems {
|
|||||||
* - If you specify "reset" for the `$getFields` argument it returns a blank array and resets
|
* - If you specify "reset" for the `$getFields` argument it returns a blank array and resets
|
||||||
* internal tags cache.
|
* internal tags cache.
|
||||||
*
|
*
|
||||||
|
* #pw-advanced
|
||||||
|
*
|
||||||
* @param bool|string $getFieldNames Specify true to return associative array where keys are tags and values are field names
|
* @param bool|string $getFieldNames Specify true to return associative array where keys are tags and values are field names
|
||||||
* …or specify the string "reset" to force getTags() to reset its cache, forcing it to reload on the next call.
|
* …or specify the string "reset" to force getTags() to reset its cache, forcing it to reload on the next call.
|
||||||
* @return array
|
* @return array Both keys and values are tags in return value
|
||||||
* @since 3.0.106
|
* @since 3.0.106 + made hookable in 3.0.179
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getTags($getFieldNames = false) {
|
public function ___getTags($getFieldNames = false) {
|
||||||
|
|
||||||
if($getFieldNames === 'reset') {
|
if($getFieldNames === 'reset') {
|
||||||
$this->tagList = null;
|
$this->tagList = null;
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
* @method array getExportData(Template $template) Export Template data for external use. #pw-advanced
|
* @method array getExportData(Template $template) Export Template data for external use. #pw-advanced
|
||||||
* @method array setImportData(Template $template, array $data) Given an array of Template export data, import it to the given Template. #pw-advanced
|
* @method array setImportData(Template $template, array $data) Given an array of Template export data, import it to the given Template. #pw-advanced
|
||||||
* @method void fileModified(Template $template) Hook called when a template detects that its file has been modified. #pw-hooker
|
* @method void fileModified(Template $template) Hook called when a template detects that its file has been modified. #pw-hooker
|
||||||
|
* @method array getTags($getTemplateNames = false) Get tags for all templates (3.0.179+) #pw-advanced
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Templates extends WireSaveableItems {
|
class Templates extends WireSaveableItems {
|
||||||
@@ -789,11 +790,11 @@ class Templates extends WireSaveableItems {
|
|||||||
* Get all tags used by templates
|
* Get all tags used by templates
|
||||||
*
|
*
|
||||||
* @param bool $getTemplateNames Get arrays of template names for each tag? (default=false)
|
* @param bool $getTemplateNames Get arrays of template names for each tag? (default=false)
|
||||||
* @return array
|
* @return array In return value both key and value are the tag
|
||||||
* @since 3.0.176
|
* @since 3.0.176 + hookable in 3.0.179
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getTags($getTemplateNames = false) {
|
public function ___getTags($getTemplateNames = false) {
|
||||||
$tags = array();
|
$tags = array();
|
||||||
foreach($this as $template) {
|
foreach($this as $template) {
|
||||||
/** @var Template $template */
|
/** @var Template $template */
|
||||||
|
Reference in New Issue
Block a user