From fa7e245fcb48f4f2eb13429abb64c028080ad62e Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 5 Sep 2018 22:42:57 +0100 Subject: [PATCH] Document partials and address loading --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 80edd8f..675f353 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,27 @@ _Actions you can apply to messages that match the conditions:_ - `notImportant` - mark the message as not important. - `categorise` - apply a smart label to the message. +## Loading Filters from Partials + +If you want to split your filters into different partials, return an array of filters from each partial and add `return Opdavies\GmailFilterBuilder\Service\Partials::load()` to `filters.php`. This defaults to a directory called `filters`, but you can specify an alternative directory name as an argument. + +## Loading Addresses from a Separate File + +If you want to filter based on the `to` address and not include your addresses within the filters repository, you can include them from within a different file using `Addresses::load()`: + +``` +$myAddresses = Addresses::load('my-addresses.php'); + +return [ + Filter::create() + ->from('foo@example.com') + ->to($myAddresses) + ->trash(), +]; +``` + +In this example, the addresses are returned as an array from `~/.gmail-filters/my-addresses.php` and then used as a condition in the filter. + ## Filter Examples ```php