/** * PHP magic method used when accessing fields as document properties, i.e. `$document->_id`. * * @param $name The field name, as specified with an object property. * @return mixed Returns the value of the field specified in `$name`, and wraps complex data * types in sub-`Document` objects. */ public function &__get($name) { if (strpos($name, '.')) { return $this->_getNested($name); } if (isset($this->_embedded[$name]) && !isset($this->_relationships[$name])) { throw new RuntimeException("Not implemented."); } $result =& parent::__get($name); if ($result !== null || array_key_exists($name, $this->_updated)) { return $result; } if ($field = $this->schema($name)) { if (isset($field['default'])) { $this->set(array($name => $field['default'])); return $this->_updated[$name]; } if (isset($field['array']) && $field['array'] && ($model = $this->_model)) { $this->_updated[$name] = $model::create(array(), array('class' => 'set', 'schema' => $this->schema(), 'pathKey' => $this->_pathKey ? $this->_pathKey . '.' . $name : $name, 'parent' => $this, 'model' => $this->_model, 'defaults' => false)); return $this->_updated[$name]; } } $null = null; return $null; }
/** * PHP magic method used when accessing fields as document properties, i.e. `$document->_id`. * * @param $name The field name, as specified with an object property. * @return mixed Returns the value of the field specified in `$name`, and wraps complex data * types in sub-`Document` objects. */ public function &__get($name) { if (strpos($name, '.')) { return $this->_getNested($name); } if (isset($this->_embedded[$name]) && !isset($this->_relationships[$name])) { throw new RuntimeException("Not implemented."); } $result = parent::__get($name); if ($result !== null || array_key_exists($name, $this->_updated)) { return $result; } if ($field = $this->schema($name)) { if (isset($field['default'])) { $this->set(array($name => $field['default'])); return $this->_updated[$name]; } if (isset($field['array']) && $field['array'] && ($model = $this->_model)) { $this->_updated[$name] = $model::connection()->item($model, array(), array('class' => 'array')); return $this->_updated[$name]; } } $null = null; return $null; }
/** * PHP magic method used when accessing fields as document properties, i.e. `$document->_id`. * * @param $name The field name, as specified with an object property. * @return mixed Returns the value of the field specified in `$name`, and wraps complex data * types in sub-`Document` objects. */ public function &__get($name) { if (strpos($name, '.')) { return $this->_getNested($name); } if (isset($this->_removed[$name])) { $null = null; return $null; } if (isset($this->_embedded[$name]) && !isset($this->_relationships[$name])) { $this->_relationships[$name] = $this->_relate($this->_embedded[$name], isset($this->_data[$name]) ? $this->_data[$name] : array()); } $model = $this->_model; $conn = $model ? $model::connection() : null; if ($model && $conn && ($schema = $model::schema($name))) { if (isset($this->_updated[$name])) { return $this->_updated[$name]; } if (!isset($this->_data[$name])) { $schema = array($name => $schema); $pathKey = $this->_pathKey ? $this->_pathKey : null; $options = compact('pathKey', 'schema') + array('first' => true); if (($value = $conn->cast($this, array($name => null), $options)) !== null) { $this->_data[$name] = $value; return $this->_data[$name]; } } } return parent::__get($name); }
/** * PHP magic method used when accessing fields as document properties, i.e. `$document->_id`. * * @param $name The field name, as specified with an object property. * @return mixed Returns the value of the field specified in `$name`, and wraps complex data * types in sub-`Document` objects. */ public function &__get($name) { if (strpos($name, '.')) { return $this->_getNested($name); } if (isset($this->_embedded[$name]) && !isset($this->_relationships[$name])) { $item = isset($this->_data[$name]) ? $this->_data[$name] : array(); var_dump($this->_relationships[$name]); die('#WINNING'); // $this->_relationships[$name] = $this->_relate($this->_embedded[$name], $item); } $result = parent::__get($name); if ($result !== null || array_key_exists($name, $this->_updated)) { return $result; } if ($field = $this->schema($name)) { if (isset($field['default'])) { $this->set(array($name => $field['default'])); return $this->_updated[$name]; } if (isset($field['array']) && $field['array'] && ($model = $this->_model)) { $this->_updated[$name] = $model::connection()->item($model, array(), array( 'class' => 'array' )); return $this->_updated[$name]; } } $null = null; return $null; }