|
|
@@ -3,14 +3,12 @@
|
|
|
namespace Tools\Model\Behavior;
|
|
|
|
|
|
use Cake\Core\Configure;
|
|
|
-use Cake\Error\Exception;
|
|
|
use Cake\Event\Event;
|
|
|
use Cake\ORM\Behavior;
|
|
|
use Cake\ORM\Entity;
|
|
|
use Cake\ORM\Query;
|
|
|
use Cake\ORM\Table;
|
|
|
use Cake\Utility\Inflector;
|
|
|
-use Exception as PhpException;
|
|
|
use InvalidArgumentException;
|
|
|
|
|
|
/**
|
|
|
@@ -128,11 +126,11 @@ class SluggedBehavior extends Behavior {
|
|
|
if (strpos($field, '.')) {
|
|
|
list($alias, $field) = explode('.', $field);
|
|
|
if (!$this->_table->$alias->hasField($field)) {
|
|
|
- throw new PhpException('(SluggedBehavior::setup) model ' . $this->_table->$alias->name . ' is missing the field ' . $field .
|
|
|
+ throw new Exception('(SluggedBehavior::setup) model ' . $this->_table->$alias->name . ' is missing the field ' . $field .
|
|
|
' (specified in the setup for model ' . $this->_table->name . ') ');
|
|
|
}
|
|
|
} elseif (!$this->_table->hasField($field) && !method_exists($this->_table->entityClass(), '_get' . Inflector::classify($field))) {
|
|
|
- throw new PhpException('(SluggedBehavior::setup) model ' . $this->_table->name . ' is missing the field ' . $field . ' specified in the setup.');
|
|
|
+ throw new Exception('(SluggedBehavior::setup) model ' . $this->_table->name . ' is missing the field ' . $field . ' specified in the setup.');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -296,7 +294,7 @@ class SluggedBehavior extends Behavior {
|
|
|
}
|
|
|
if ($this->_config['unique']) {
|
|
|
if (!$entity) {
|
|
|
- throw new PhpException('Needs an Entity to work on');
|
|
|
+ throw new Exception('Needs an Entity to work on');
|
|
|
}
|
|
|
$field = $this->_table->alias() . '.' . $this->_config['field'];
|
|
|
$conditions = [$field => $slug];
|
|
|
@@ -337,7 +335,7 @@ class SluggedBehavior extends Behavior {
|
|
|
*/
|
|
|
public function resetSlugs($params = []) {
|
|
|
if (!$this->_table->hasField($this->_config['field'])) {
|
|
|
- throw new PhpException('Table does not have field ' . $this->_config['field']);
|
|
|
+ throw new Exception('Table does not have field ' . $this->_config['field']);
|
|
|
}
|
|
|
$defaults = [
|
|
|
'page' => 1,
|
|
|
@@ -363,7 +361,7 @@ class SluggedBehavior extends Behavior {
|
|
|
'fieldList' => array_merge([$this->_table->primaryKey(), $this->_config['field']], $this->_config['label'])
|
|
|
];
|
|
|
if (!$this->_table->save($record, $options)) {
|
|
|
- throw new PhpException(print_r($this->_table->errors(), true));
|
|
|
+ throw new Exception(print_r($this->_table->errors(), true));
|
|
|
}
|
|
|
}
|
|
|
$params['page']++;
|