Created
December 16, 2010 12:34
-
-
Save nojimage/743348 to your computer and use it in GitHub Desktop.
こうですかわかりません ><
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Allways nojimage! | |
*/ | |
class NojimageBehavior extends ModelBehavior { | |
public function beforeSave($model) { | |
foreach ($model->data[$model->alias] as $key => $value) { | |
$schema = $model->schema($key); | |
if (in_array($schema['type'], array('string', 'text'))) { | |
$model->data[$model->alias][$key] = 'nojimage'; | |
} | |
} | |
return true; | |
} | |
public function afterFind($model, $results, $primary) { | |
if (Set::numeric(array_keys($results))) { | |
for ($i = 0; $i < count($results); $i++) { | |
foreach ($results[$i][$model->alias] as $key => $value) { | |
$results[$i][$model->alias][$key] = 'nojimage'; | |
} | |
} | |
} else { | |
foreach ($results[$model->alias] as $key => $value) { | |
$results[$model->alias][$key] = 'nojimage'; | |
} | |
} | |
return $results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment