115 throw new InvalidArgumentException(
'$class must be a class name.');
120 throw new InvalidArgumentException(
'$requiredType must be a system entity type.');
124 $this->initialized_attributes = $initialized_attrs;
125 $all_attr_names = array_keys($initialized_attrs);
126 $this->secondary_attr_names = array_diff($all_attr_names, self::$primary_attr_names);
136 return array_diff(self::$primary_attr_names, array_keys(
$row)) !== array();
146 return array_diff($this->secondary_attr_names, array_keys(
$row)) !== array();
157 if (
$row[
'type'] !== $this->required_type) {
186 if (!is_array(
$row) && !(
$row instanceof stdClass)) {
191 if (empty(
$row[
'guid'])) {
192 throw new InvalidArgumentException(
'$row must be or contain a GUID');
199 if (($was_missing_primaries || $was_missing_secondaries) && is_callable($this->full_loader)) {
200 $fetched = (array) call_user_func($this->full_loader,
$row[
'guid']);
207 if ($was_missing_primaries) {
208 if (!is_callable($this->primary_loader)) {
209 throw new LogicException(
'Primary attribute loader must be callable');
211 if ($this->requires_access_control) {
212 $fetched = (array) call_user_func($this->primary_loader,
$row[
'guid']);
215 $fetched = (array) call_user_func($this->primary_loader,
$row[
'guid']);
228 if ($was_missing_secondaries) {
229 if (!is_callable($this->secondary_loader)) {
230 throw new LogicException(
'Secondary attribute loader must be callable');
232 $fetched = (array) call_user_func($this->secondary_loader,
$row[
'guid']);
242 $row[
'subtype'] = (int)
$row[
'subtype'];
245 foreach (self::$null_attr_names as
$key) {
255 foreach (self::$integer_attr_names as $key) {
256 if (isset(
$row[$key])) {
271 $acceptable_attrs = self::$primary_attr_names;
272 array_splice($acceptable_attrs, count($acceptable_attrs), 0, $this->secondary_attr_names);
273 $acceptable_attrs = array_combine($acceptable_attrs, $acceptable_attrs);
276 if (!isset($acceptable_attrs[
$key])) {
277 $this->additional_select_values[
$key] = $val;
checkType($row)
Check that the type is correct.
isMissingSecondaries($row)
Get secondary attributes that are missing.
getRequiredAttributes($row)
Get all required attributes for the entity, validating any that are passed in.
elgg_set_ignore_access($ignore=true)
Set if Elgg's access system should be ignored.
isMissingPrimaries($row)
Get primary attributes missing that are missing.
__construct($class, $required_type, array $initialized_attrs)
Constructor.
getAdditionalSelectValues()
Get values selected from the database that are not attributes.
filterAddedColumns($row)
Filter non-attribute keys into $this->additional_select_values.
$additional_select_values
static $primary_attr_names
static $integer_attr_names