PHPackages                             heimrichhannot/contao-observer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. heimrichhannot/contao-observer

ActiveContao-module[Mail &amp; Notifications](/categories/mail)

heimrichhannot/contao-observer
==============================

A observer for contao.

1.2.0(8y ago)01082LGPL-3.0-or-laterPHPPHP ~5.4 || ~7.0

Since Aug 29Pushed 8y ago4 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-observer)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-observer)[ Docs](https://github.com/heimrichhannot/contao-observer)[ RSS](/packages/heimrichhannot-contao-observer/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (7)Versions (9)Used By (2)

Observer
========

[](#observer)

A observer for contao. It is currently required by [heimrichhannot/contao-collab](https://github.com/heimrichhannot/contao-collab) and provide task creation from a mailbox, or notify task assignees. But it can be extended easily.

Features
--------

[](#features)

The observer is a cron-job module, that checks subjects against given criteria and update attached observers. It structure is based on the observer pattern. We have subjects like a mailbox for example. If a mail with given criteria (for example new mail) will be received, the attached Taskobserver will create a new Task from a given mail ([heimrichhannot/contao-collab](https://github.com/heimrichhannot/contao-collab) required).

- Observe a mailbox (php-imap php extension is required)
- Wait for subject age (wait until tstamp of context elapsed given waiting duration)
- Priority handling (manage execution order)
- Observer log
- Observer history: store all already run subject/observer combinations within local history (e.g. will prevent multiple user notification)

### Observer manager

[](#observer-manager)

The observer manager observes all entities withing the minutely contao cron job. It works within the poor man's minutly cronjob out of the box, or you can call the binary script within you crontab:

Contao 3 without composer:

```
* * * * * php /path/to/contao/system/modules/observer/bin/manager.php

```

Contao 3 with composer:

```
* * * * * php /path/to/contao/composer/vendor/heimrichhannot/contao-observer/bin/manager.php

```

Contao 4:

```
* * * * * php /path/to/contao/vendor/heimrichhannot/contao-observer/bin/manager.php

```

### Make usage within you custom module

[](#make-usage-within-you-custom-module)

#### Add a new subject

[](#add-a-new-subject)

A subject is for example a mailbox, or tasks within a given tasklist, with needed criteria (UNSEEN Mail, unassigned Tasks…).

##### 1. Add the subject to your config.php

[](#1-add-the-subject-to-your-configphp)

```
// config.php
array_insert(
	$GLOBALS['OBSERVER']['SUBJECTS'],
	0,
	[
		'MY_SUBJECT_NAME' => 'MyNamespace\Observer\MySubject',
	]
);

```

##### 2. Add your subject palette to tl\_observer.php

[](#2-add-your-subject-palette-to-tl_observerphp)

You might add custom fields also in here.

```
// tl_observer.php

$arrDca = &$GLOBALS['TL_DCA']['tl_observer'];

/**
 * Palettes
 */
$arrDca['palettes']['MY_SUBJECT_NAME'] =
	'{general_legend},subject,title;{cronjob_legend},cronInterval,useCronExpression,priority,invoked,invokedState;{observer_legend},observer;{expert_legend},debug,addObserverStates;{publish_legend},published;';

```

##### 3. Create your Subject Object 'MyNamespace\\Observer\\MySubject'

[](#3-create-your-subject-object-mynamespaceobservermysubject)

Must extend `HeimrichHannot\Observer\Subject`.

```
