Ejemplo n.º 1
0
 public function getUsages()
 {
     $usages = array();
     if ($this->hasRelation()) {
         $model = $this->schema->getModel($this->property->getRelation()->getDestination());
         $usages[] = sprintf('use %s as %s;', $model->getModelClass(), $model->getClassName());
     }
     return $usages;
 }
Ejemplo n.º 2
0
 /**
  * @param $name
  * @param $config
  * @return Property
  */
 public function addProperty($name, $config)
 {
     if ($config instanceof Property) {
         $property = $config;
     } else {
         if (is_string($config)) {
             $config = array('name' => $name, 'comment' => $config);
         } elseif (is_array($config) && !is_numeric($name)) {
             if (isset($config[0])) {
                 array_unshift($config, $name);
             } else {
                 $config['name'] = $name;
             }
         }
         $config['model'] = $this;
         $property = new Property($config);
     }
     return $this->properties[$property->getName()] = $property;
 }
Ejemplo n.º 3
0
 public function hasRelation()
 {
     return !is_null($this->property->getRelation());
 }
Ejemplo n.º 4
0
 protected function propertyAsArray(Property $property)
 {
     return array('comment' => $property->getComment(), 'type' => $property->getType(), 'required' => $property->getRequired());
 }