Browse Source

Don't merge events

This is one of the exceptions where merging is not likely to be the
desired behavior - it would mean that you can't configure to disable
default events, it'd require code calls
AD7six 12 years ago
parent
commit
b1350df392
1 changed files with 17 additions and 0 deletions
  1. 17 0
      src/Model/Behavior/TimestampBehavior.php

+ 17 - 0
src/Model/Behavior/TimestampBehavior.php

@@ -59,6 +59,23 @@ class TimestampBehavior extends Behavior {
 	protected $_ts;
 
 /**
+ * Constructor
+ *
+ * If events are specified - do *not* merge them with existing events,
+ * overwrite the events to listen on
+ *
+ * @param Table $table The table this behavior is attached to.
+ * @param array $config The config for this behavior.
+ */
+	public function __construct(Table $table, array $config = []) {
+		parent::__construct($table, $config);
+
+		if (isset($config['events'])) {
+			$this->config('events', $config['events'], false);
+		}
+	}
+
+/**
  * handleEvent
  *
  * There is only one event handler, it can be configured to be called for any event