src/Model/Behavior/SluggedBehavior.php
public function resetSlugs($params = []) {
		if (!$this->_table->hasField($this->_config['field'])) {
			throw new RuntimeException('Table does not have field ' . $this->_config['field']);
		}
		$defaults = [
			'page' => 1,
			'limit' => 100,
			'fields' => array_merge([$this->_table->getPrimaryKey()], $this->_config['label']),
			'order' => $this->_table->getDisplayField() . ' ASC',
			'conditions' => $this->_config['scope'],
			'overwrite' => true,
		];
		$params = array_merge($defaults, $params);

		$conditions = $params['conditions'];
		$count = $this->_table->find('all', compact('conditions'))->count();
		$max = ini_get('max_execution_time');
		if ($max) {
			set_time_limit(max($max, $count / 100));
		}

		$this->setConfig($params, null, false);
		while (($records = $this->_table->find('all', $params)->toArray())) {
			/** @var \Cake\ORM\Entity $record */
			foreach ($records as $record) {
				$record->isNew(true);

				$fields = array_merge([$this->_table->getPrimaryKey(), $this->_config['field']], $this->_config['label']);
				$options = [
					'validate' => true,
					'fields' => $fields,
				];
				if (!$this->_table->save($record, $options)) {
					throw new RuntimeException(print_r($record->getErrors(), true));
				}
			}
			$params['page']++;
		}
		return true;
	}
public function resetSlugs($params = []) {
		if (!$this->_table->hasField($this->_config['field'])) {
			throw new RuntimeException('Table does not have field ' . $this->_config['field']);
		}
		$defaults = [
			'page' => 1,
			'limit' => 100,
			'fields' => array_merge([$this->_table->getPrimaryKey()], $this->_config['label']),
			'order' => $this->_table->getDisplayField() . ' ASC',
			'conditions' => $this->_config['scope'],
			'overwrite' => true,
		];
		$params = array_merge($defaults, $params);

		$conditions = $params['conditions'];
		$count = $this->_table->find('all', compact('conditions'))->count();
		$max = ini_get('max_execution_time');
		if ($max) {
			set_time_limit(max($max, $count / 100));
		}

		$this->setConfig($params, null, false);
		while (($records = $this->_table->find('all', $params)->toArray())) {
			/** @var \Cake\ORM\Entity $record */
			foreach ($records as $record) {
				$record->isNew(true);

				$fields = array_merge([$this->_table->getPrimaryKey(), $this->_config['field']], $this->_config['label']);
				$options = [
					'validate' => true,
					'fields' => $fields,
				];
				if (!$this->_table->save($record, $options)) {
					throw new RuntimeException(print_r($record->getErrors(), true));
				}
			}
			$params['page']++;
		}
		return true;
	}
public function resetSlugs ( $ params = [ ] ) { if ( ! $ this -> _table -> hasField ( $ this -> _config [ 'field' ] ) ) { throw new RuntimeException ( 'Table does not have field ' . $ this -> _config [ 'field' ] ) ; } $ defaults = [ 'page' => 1 , 'limit' => 100 , 'fields' => array_merge ( [ $ this -> _table -> getPrimaryKey ( ) ] , $ this -> _config [ 'label' ] ) , 'order' => $ this -> _table -> getDisplayField ( ) . ' ASC' , 'conditions' => $ this -> _config [ 'scope' ] , 'overwrite' => true , ] ; $ params = array_merge ( $ defaults , $ params ) ; $ conditions = $ params [ 'conditions' ] ; $ count = $ this -> _table -> find ( 'all' , compact ( 'conditions' ) ) -> count ( ) ; $ max = ini_get ( 'max_execution_time' ) ; if ( $ max ) { set_time_limit ( max ( $ max , $ count / 100 ) ) ; } $ this -> setConfig ( $ params , null , false ) ; while ( ( $ records = $ this -> _table -> find ( 'all' , $ params ) -> toArray ( ) ) ) { /** @var \Cake\ORM\Entity $record */ foreach ( $ records as $ record ) { $ record -> isNew ( true ) ; $ fields = array_merge ( [ $ this -> _table -> getPrimaryKey ( ) , $ this -> _config [ 'field' ] ] , $ this -> _config [ 'label' ] ) ; $ options = [ 'validate' => true , 'fields' => $ fields , ] ; if ( ! $ this -> _table -> save ( $ record , $ options ) ) { throw new RuntimeException ( print_r ( $ record -> getErrors ( ) , true ) ) ; } } $ params [ 'page' ] ++ ; } return true ; }
ResetSlugs method.

Regenerate all slugs. On large dbs this can take more than 30 seconds - a time
limit is set to allow a minimum 100 updates per second as a preventative measure.

Note that you should use the Reset behavior if you need additional functionality such
as callbacks or timeouts.

@param array $params
@return bool Success
@throws \RuntimeException
ResetSlugs method .