Exemplo n.º 1
0
 public function options()
 {
     if (null === $this->options) {
         $this->options = new \stdClass();
         $this->setUpOptions($this->options);
         /**
          * @var string $name
          * @var Option $option
          */
         foreach ((array) $this->options as $name => $option) {
             if ($option->isArgument) {
                 $this->arguments[] = $option;
                 continue;
             }
             if ($option->shortName) {
                 $this->optionsByShortName[$option->shortName] = $option;
             }
             if (empty($option->name)) {
                 $option->name = Utils::fromCamelCase($name, '-');
             }
             $this->optionsByName[$option->name] = $option;
         }
     }
     return $this->options;
 }
Exemplo n.º 2
0
 public function __construct(Request $request)
 {
     $this->request = $request;
     $this->unnamedMapper = function ($name) {
         return Utils::fromCamelCase($name, '-');
     };
     $this->namedMapper = function ($name) {
         return Utils::fromCamelCase($name, '_');
     };
 }
Exemplo n.º 3
0
 public function __set($name, $column)
 {
     if (is_int($column)) {
         $column = new Column($column);
         //$this->_arrayOfColumnData[$name] = $column;
     }
     // another column reference
     if (!empty($column->table) && $column->table->schemaName != $this->table->schemaName) {
         $refColumn = $column;
         $column = clone $column;
         $column->propertyName = $name;
         $column->schemaName = Utils::fromCamelCase($name);
         $column->table = $this->table;
         //$this->_arrayOfColumnData[$name] = $column;
         $foreignKey = new ForeignKey(array($column), array($refColumn));
         $column->foreignKey = $foreignKey;
         //$this->table->addForeignKey($foreignKey);
         $column->setFlag(Column::AUTO_ID, false);
     } else {
         $column->propertyName = $name;
         $column->schemaName = Utils::fromCamelCase($name);
         $column->table = $this->table;
     }
     if ($column->flags & Column::AUTO_ID) {
         $this->table->autoIdColumn = $column;
         if (!$this->table->primaryKey) {
             $this->table->setPrimaryKey($column);
         }
     }
     if ($column->isUnique) {
         $index = new Index($column);
         $index->setType(Index::TYPE_UNIQUE);
         $this->table->addIndex($index);
     } elseif ($column->isIndexed) {
         $index = new Index($column);
         $index->setType(Index::TYPE_KEY);
         $this->table->addIndex($index);
     }
     $this->table->database()->getUtility()->checkColumn($column);
     $this->_arrayOfColumnData[$name] = $column;
 }
Exemplo n.º 4
0
 /**
  * Method should return table definition of entity
  * @return Table
  */
 public static function table($alias = null)
 {
     $className = get_called_class();
     $tableKey = $className . ($alias ? ':' . $alias : '');
     $table =& self::$tables[$tableKey];
     if (null !== $table) {
         return $table;
     }
     /*
     if (isset(self::$settingColumns[$tableKey])) {
         throw new Exception('Already setting columns');
     }
     $columns = new \stdClass();
     self::$settingColumns[$tableKey] = $columns;
     unset(self::$settingColumns[$tableKey]);
     */
     $schemaName = Utils::fromCamelCase(str_replace('\\', '', $className));
     $table = new Table(null, self::getDatabase($className), $schemaName);
     $table->entityClassName = $className;
     $table->alias = $alias;
     static::setUpColumns($table->columns);
     static::setUpTable($table, $table->columns);
     return $table;
 }
Exemplo n.º 5
0
 public static function getPublicName($name)
 {
     return Utils::fromCamelCase($name, '_');
 }
Exemplo n.º 6
0
 public function getPublicName()
 {
     return Utils::fromCamelCase($this->name, '_');
 }