コード例 #1
0
 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);
 }
コード例 #2
0
 protected function modelExists($className)
 {
     if (class_exists($className)) {
         return true;
     } else {
         try {
             SDependencies::requireDependency('models', $className, get_class($this->record));
         } catch (Exception $e) {
             return false;
         }
     }
     return true;
 }
コード例 #3
0
 private function requireDependencies()
 {
     SLocale::loadStrings(APP_DIR . '/i18n/' . SDependencies::subDirectory(get_class($this)));
     SUrlRewriter::initialize($this->request);
     foreach ($this->helpers as $k => $helper) {
         $this->helpers[$k] = $helper . 'Helper';
     }
     SDependencies::requireDependencies('models', $this->models, get_class($this));
     SDependencies::requireDependencies('helpers', $this->helpers, get_class($this));
 }