|
@@ -96,6 +96,15 @@ class EagerLoader
|
|
|
protected $_joinsMap = [];
|
|
protected $_joinsMap = [];
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * Controls whether or not fields from associated tables
|
|
|
|
|
+ * will be eagerly loaded. When set to false, no fields will
|
|
|
|
|
+ * be loaded from associations.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @var bool
|
|
|
|
|
+ */
|
|
|
|
|
+ protected $_autoFields = true;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* Sets the list of associations that should be eagerly loaded along for a
|
|
* Sets the list of associations that should be eagerly loaded along for a
|
|
|
* specific table using when a query is provided. The list of associated tables
|
|
* specific table using when a query is provided. The list of associated tables
|
|
|
* passed to this method must have been previously set as associations using the
|
|
* passed to this method must have been previously set as associations using the
|
|
@@ -135,6 +144,20 @@ class EagerLoader
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * Set whether or not contained associations will load fields automatically.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bool $value The value to set.
|
|
|
|
|
+ * @return bool The current value.
|
|
|
|
|
+ */
|
|
|
|
|
+ public function autoFields($value = null)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($value !== null) {
|
|
|
|
|
+ $this->_autoFields = (bool)$value;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->_autoFields;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* Adds a new association to the list that will be used to filter the results of
|
|
* Adds a new association to the list that will be used to filter the results of
|
|
|
* any given query based on the results of finding records for that association.
|
|
* any given query based on the results of finding records for that association.
|
|
|
* You can pass a dot separated path of associations to this method as its first
|
|
* You can pass a dot separated path of associations to this method as its first
|
|
@@ -294,7 +317,7 @@ class EagerLoader
|
|
|
$config = $loadable->config() + [
|
|
$config = $loadable->config() + [
|
|
|
'aliasPath' => $loadable->aliasPath(),
|
|
'aliasPath' => $loadable->aliasPath(),
|
|
|
'propertyPath' => $loadable->propertyPath(),
|
|
'propertyPath' => $loadable->propertyPath(),
|
|
|
- 'includeFields' => $includeFields
|
|
|
|
|
|
|
+ 'includeFields' => $includeFields,
|
|
|
];
|
|
];
|
|
|
$loadable->instance()->attachTo($query, $config);
|
|
$loadable->instance()->attachTo($query, $config);
|
|
|
}
|
|
}
|