g4b0/sitetree-walk

Walk through the SiteTree, and hooks implementors of SiteTreeWalkListener interface letting them doing things over each page.

Installs: 1 668

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 1

Open Issues: 2

Type:silverstripe-vendormodule

2.0.0 2018-05-10 12:34 UTC

This package is not auto-updated.

Last update: 2024-12-18 17:00:06 UTC


README

Implementation of the annoying task to walk through the entire SiteTree in order to do things over the pages.

Introduction

This module by itself does not do anything, it just iterate recursively through the SiteTree and hooks every implementor of SiteTreeWalkListener interface letting them doing things over each page.

Requirements

  • SilverStripe >= 4.1 < 5.0

For 3.x installations refer to the 1.x version

Installation

Install the module through composer:

composer require --no-update g4b0/sitetree-walk
composer update --no-dev g4b0/sitetree-walk

Running the task.

Before running the task you need to implement your logic extending SiteTreeWalkListener interface. An example is provided with SiteTreeWalkPrint, that simply prints out the page title. To enable it set its member variable SiteTreeWalkPrint::$enabled to true. SiteTreeWalkListener implementor's run() method should return true for the processed pages, false for the excluded ones. Following the output of the sample:

#sake dev/tasks/SiteTreeWalk "flush=all"
Running Task SiteTreeWalk

Following SiteTreeWalkListener Implementors will be executed: 
	* SiteTreeWalkPrint

Continue? [y|n]y

Home 
Test 
	Test 2 
	Test 3 
Chi siamo 
Contattaci 
Pagina non trovata  *** Excluded from processing
Errore server  *** Excluded from processing
My Page 

################################################
Traversed Pages: 9

Processed Pages: 
	SiteTreeWalkPrint: 9
################################################