Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Making SluggableBehaviour return true in beforeSave() #26

Merged
merged 2 commits into from over 2 years ago

2 participants

Matthew Dunham Florian Krämer
Matthew Dunham

Title says it all. Normal model saves were failing because the behaviour beforeSave() was returning null and not true.

Sorry it is over 2 commits, I did it ages ago but forgot to pull request, code has changed greatly since then anyway.

Florian Krämer burzum merged commit 988ab2f into from
Florian Krämer burzum closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Sep 05, 2011
Matthew Dunham Dunhamzzz Added return true; to beforeSave 7046362
Oct 25, 2011
Matthew Dunham Dunhamzzz Returned true in beforeSave 28f0527
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 7 additions and 6 deletions. Show diff stats Hide diff stats

  1. +7 6 Model/Behavior/SluggableBehavior.php
13 Model/Behavior/SluggableBehavior.php
@@ -73,16 +73,16 @@ public function beforeSave(Model $Model) {
73 73 $settings = $this->settings[$Model->alias];
74 74 if (is_string($this->settings[$Model->alias]['trigger'])) {
75 75 if ($Model->{$this->settings[$Model->alias]['trigger']} != true) {
76   - return;
  76 + return true;
77 77 }
78 78 }
79 79
80 80 if (empty($Model->data[$Model->alias])) {
81   - return;
  81 + return true;
82 82 } else if (empty($Model->data[$Model->alias][$this->settings[$Model->alias]['label']])) {
83   - return;
  83 + return true;
84 84 } else if (!$this->settings[$Model->alias]['update'] && !empty($Model->id) && !is_string($this->settings[$Model->alias]['trigger'])) {
85   - return;
  85 + return true;
86 86 }
87 87
88 88 $slug = $Model->data[$Model->alias][$settings['label']];
@@ -101,15 +101,16 @@ public function beforeSave(Model $Model) {
101 101 $Model->whitelist[] = $settings['slug'];
102 102 }
103 103 $Model->data[$Model->alias][$settings['slug']] = $slug;
  104 + return true;
104 105 }
105 106
106 107 /**
107   - * Searche if the slug already exists and if yes increments it
  108 + * Search if the slug already exists and if yes increments it
108 109 *
109 110 * @param object $Model
110 111 * @param string the raw slug
111 112 * @return string The incremented unique slug
112   - *
  113 + *
113 114 */
114 115 public function makeUniqueSlug(Model $Model, $slug = '') {
115 116 $settings = $this->settings[$Model->alias];

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.