public function apply($value) { $id = (int) $value; if (empty($id)) { return false; } $record = $this->table->get($id); if ($record instanceof RecordInterface) { return $id; } else { return false; } }
protected function getTableSchema(TableInterface $table) { $columns = $table->getColumns(); $builder = new SchemaBuilder($table->getDisplayName()); foreach ($columns as $column => $type) { $type = ($type >> 20 & 0xff) << 20; switch ($type) { case TableInterface::TYPE_SMALLINT: case TableInterface::TYPE_INT: $builder->integer($column); break; case TableInterface::TYPE_BOOLEAN: $builder->boolean($column); break; case TableInterface::TYPE_DECIMAL: case TableInterface::TYPE_FLOAT: $builder->float($column); break; case TableInterface::TYPE_DATE: $builder->date($column); break; case TableInterface::TYPE_DATETIME: $builder->dateTime($column); break; case TableInterface::TYPE_TIME: $builder->time($column); break; case TableInterface::TYPE_BIGINT: case TableInterface::TYPE_VARCHAR: case TableInterface::TYPE_TEXT: case TableInterface::TYPE_BLOB: $builder->string($column); break; } } return new Schema($builder->getProperty()); }
public function addTable(TableInterface $table, array $data) { $this->tables[$table->getName()] = new Table($table, $data); }