Exemple #1
0
 /**
  * Returns an array containing information about the relation.
  *
  * @param string $name Relation name
  * @param array  $info Relation info
  *
  * @return array
  */
 public static function getRelationInfo($name, $info = [])
 {
     // Get current models namespace
     $class = new ReflectionClass(get_called_class());
     $namespace = $class->getNamespaceName();
     // Name
     $info['name'] = $name;
     // Model
     if (!isset($info['model'])) {
         // $info['model'] = Inflector::modelise($name);
         $info['model'] = Inflector::singularize(Inflector::classify($name));
     }
     // Set model namespace
     if (strpos($info['model'], '\\') === false) {
         $info['model'] = "\\{$namespace}\\{$info['model']}";
     }
     // Class
     $model = new ReflectionClass($info['model']);
     $info['class'] = $model->getShortName();
     return $info;
 }