Phactory\Mongo\Blueprint::build PHP Method

build() public method

* Build the document as an array, but don't save it to the db.
public build ( $overrides = [], $associated = [] )
$overrides field => value pairs which override the defaults for this blueprint
$associated [name] => [Association] pairs
    public function build($overrides = array(), $associated = array())
    {
        $data = $this->_defaults;
        if ($associated) {
            foreach ($associated as $name => $document) {
                if (!isset($this->_associations[$name])) {
                    throw new \Exception("No association '{$name}' defined");
                }
                $association = $this->_associations[$name];
                if (!$association instanceof Association\EmbedsMany && !$association instanceof Association\EmbedsOne) {
                    throw new \Exception("Invalid association object for '{$name}'");
                }
                $overrides[$name] = $document;
            }
        }
        $this->_evalSequence($data);
        if ($overrides) {
            foreach ($overrides as $field => $value) {
                $data[$field] = $value;
            }
        }
        return $data;
    }