/** * Recreate an existing record. * @param Model $model Associated model. * @param array $data Associative array of record data. * @param array $virtual Associative array of virtual record data. * @return RecordBuilder An existing record. */ public static function createExisting(Model $model, $data = array(), $virtual = array()) { $record = new RecordBuilder($model, $model->getSchema()->filter($data)); $record->updatedData = array(); $record->virtual = $virtual; return $record; }
/** * Construct record. * * @param Model $model * Associated model. * @param array $data * Associative array of record data. * @param string $allowedFields * List of allowed fields. */ private function __construct(Model $model, $data = array(), $allowedFields = null) { $this->model = $model; $this->data = array_fill_keys($model->getDefinition()->getFields(), null); $this->addData($data, $allowedFields); }