Пример #1
0
 public static function belongsTo($name, $params)
 {
     self::validateParams($params);
     $class = $params['class'];
     $localKey = $params['foreignKey'];
     $foreignKey = Arrays::getValue($params, 'referencedColumn') ?: MetaModelCache::getMetaInstance(AutoloadNamespaces::getModelNamespace() . $class)->getIdName();
     return self::newRelation($name, $localKey, $foreignKey, false, $params);
 }
Пример #2
0
function renderWidget($widgetName)
{
    $className = ucfirst($widgetName);
    $viewWidget = new View($className . '/' . $widgetName);
    $classLoad = AutoloadNamespaces::getWidgetNamespace() . $className;
    $widget = new $classLoad($viewWidget);
    return $widget->render();
}
Пример #3
0
 public function __construct()
 {
     $this->controllerNamespaces = AutoloadNamespaces::getControllerNamespace();
 }
Пример #4
0
 public function getClassNamespace()
 {
     $parts = explode('\\', $this->namespace);
     $parts = Arrays::map($parts, 'ucfirst');
     $modelNamespace = trim(AutoloadNamespaces::getModelNamespace(), '\\');
     if (!Strings::startsWith($this->namespace, $modelNamespace)) {
         $parts = array_merge(array($modelNamespace), $parts);
     }
     $parts = Arrays::filterNotBlank($parts);
     return implode('\\', $parts);
 }
Пример #5
0
 /**
  * @return Model
  */
 public function getRelationModelObject()
 {
     return MetaModelCache::getMetaInstance(AutoloadNamespaces::getModelNamespace() . $this->class);
 }
Пример #6
0
 public function getClassNamespace()
 {
     $controllerNamespaces = AutoloadNamespaces::getControllerNamespace();
     return rtrim($controllerNamespaces[0], '\\');
 }
Пример #7
0
 public function configure()
 {
     $defaultNamespace = trim(AutoloadNamespaces::getModelNamespace(), '\\');
     $this->setName('ouzo:model_generator')->addArgument('table', InputArgument::REQUIRED, 'Table name.')->addOption('class', 'c', InputOption::VALUE_REQUIRED, 'Class name. If not specified class name is generated based on table name.')->addOption('file', 'f', InputOption::VALUE_REQUIRED, 'Class file path. If not specified namespace and class name is used.')->addOption('namespace', 's', InputOption::VALUE_REQUIRED, 'Class namespace (e.g \'Model\\MyModel\'). Hint: Remember to escape backslash (\\\\)!', $defaultNamespace)->addOption('remove-prefix', 'p', InputOption::VALUE_REQUIRED, 'Remove prefix from table name when generating class name.', 't')->addOption('output-only', 'o', InputOption::VALUE_NONE, 'Only displaying generated model class.')->addOption('short-arrays', 'a', InputOption::VALUE_NONE, 'Generate model class with short arrays. (PHP 5.4).');
 }