public static function getOptions($owner, $name, $options) { if (!is_array($options)) { $type = $options; $options = array(); $options['assoc_type'] = $type; } if (!isset($options['assoc_type'])) { throw new SException('Type of relationship is required.'); } if (!isset($options['class_name'])) { if ($options['assoc_type'] == 'has_many' || $options['assoc_type'] == 'many_to_many') { $options['class_name'] = SInflection::singularize($name); } else { $options['class_name'] = $name; } } $dest = $options['class_name']; // we instanciate the dest class without associations to avoid an infinite loop if (!class_exists($dest)) { SDependencies::requireDependency('models', $dest, get_class($owner)); } $destInstance = new $dest(Null, True); $options['table_name'] = $destInstance->tableName; $options['primary_key'] = $destInstance->identityField; $assocMethod = SInflection::camelize($options['assoc_type']); return self::$assocMethod($owner, $name, $dest, $options); }
protected function initialize() { if ($this->scaffold !== null) { $this->models[] = $this->scaffold; if (strpos($this->scaffold, '/') !== false) { list(, $this->scaffold) = explode('/', $this->scaffold); } $this->class_name = SInflection::camelize($this->scaffold); $this->singular_name = strtolower($this->scaffold); $this->plural_name = SInflection::pluralize($this->singular_name); } }
private function migrationClass($name) { return SInflection::camelize($name); }
private static function controllerClass($reqController) { if (strpos($reqController, '/')) { list(, $controllerName) = explode('/', $reqController); } else { $controllerName = $reqController; } return SInflection::camelize($controllerName) . 'Controller'; }
function testCamelize() { $this->assertEqual('MyTestController', SInflection::camelize('my_test_controller')); $this->assertEqual('SMyTestController', SInflection::camelize('s_my_test_controller')); }