Browse Source

add exception.

euromark 11 years ago
parent
commit
2ff6d19878
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/Model/Behavior/SluggedBehavior.php

+ 5 - 0
src/Model/Behavior/SluggedBehavior.php

@@ -138,8 +138,13 @@ class SluggedBehavior extends Behavior {
 	 * @param mixed $query
 	 * @param mixed $options
 	 * @return Query
+	 * @throws \InvalidArgumentException If the 'slug' key is missing in options
 	 */
 	public function findSlugged(Query $query, array $options) {
+		if (empty($options['slug'])) {
+			throw new \InvalidArgumentException("The 'slug' key is required for find('slugged')");
+		}
+
 		return $query->where([$this->_config['field'] => $options['slug']]);
 	}