|
|
@@ -1550,13 +1550,11 @@ class Table implements RepositoryInterface, EventListener {
|
|
|
* Override this method if you want a table object to use custom
|
|
|
* marshalling logic.
|
|
|
*
|
|
|
- * @param bool $safe Whether or not this marshaller
|
|
|
- * should be in safe mode.
|
|
|
* @return \Cake\ORM\Marshaller
|
|
|
* @see \Cake\ORM\Marshaller
|
|
|
*/
|
|
|
- public function marshaller($safe = false) {
|
|
|
- return new Marshaller($this, $safe);
|
|
|
+ public function marshaller() {
|
|
|
+ return new Marshaller($this);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1576,22 +1574,22 @@ class Table implements RepositoryInterface, EventListener {
|
|
|
*
|
|
|
* By default all the associations on this table will be hydrated. You can
|
|
|
* limit which associations are built, or include deeper associations
|
|
|
- * using the associations parameter:
|
|
|
+ * using the options parameter:
|
|
|
*
|
|
|
* {{{
|
|
|
* $articles = $this->Articles->newEntity(
|
|
|
* $this->request->data(),
|
|
|
- * ['Tags', 'Comments.Users']
|
|
|
+ * ['associated' => ['Tags', 'Comments.Users']]
|
|
|
* );
|
|
|
* }}}
|
|
|
*
|
|
|
*/
|
|
|
- public function newEntity(array $data = [], $associations = null) {
|
|
|
- if ($associations === null) {
|
|
|
- $associations = $this->_associations->keys();
|
|
|
+ public function newEntity(array $data = [], array $options = []) {
|
|
|
+ if (!isset($options['associated'])) {
|
|
|
+ $options['associated'] = $this->_associations->keys();
|
|
|
}
|
|
|
$marshaller = $this->marshaller();
|
|
|
- return $marshaller->one($data, $associations);
|
|
|
+ return $marshaller->one($data, $options);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1604,14 +1602,14 @@ class Table implements RepositoryInterface, EventListener {
|
|
|
* {{{
|
|
|
* $articles = $this->Articles->newEntities(
|
|
|
* $this->request->data(),
|
|
|
- * ['Tags', 'Comments.Users']
|
|
|
+ * ['associated' => ['Tags', 'Comments.Users']]
|
|
|
* );
|
|
|
* }}}
|
|
|
*
|
|
|
*/
|
|
|
- public function newEntities(array $data, $associations = null) {
|
|
|
- if ($associations === null) {
|
|
|
- $associations = $this->_associations->keys();
|
|
|
+ public function newEntities(array $data, array $options = []) {
|
|
|
+ if (!isset($options['associated'])) {
|
|
|
+ $options['associated'] = $this->_associations->keys();
|
|
|
}
|
|
|
$marshaller = $this->marshaller();
|
|
|
return $marshaller->many($data, $associations);
|
|
|
@@ -1624,9 +1622,9 @@ class Table implements RepositoryInterface, EventListener {
|
|
|
* `$data` array will appear, those that can be matched by primary key will get
|
|
|
* the data merged, but those that cannot, will be discarded.
|
|
|
*/
|
|
|
- public function patchEntity(EntityInterface $entity, array $data, $associations = null) {
|
|
|
- if ($associations === null) {
|
|
|
- $associations = $this->_associations->keys();
|
|
|
+ public function patchEntity(EntityInterface $entity, array $data, array $options = []) {
|
|
|
+ if (!isset($options['associated'])) {
|
|
|
+ $options['associated'] = $this->_associations->keys();
|
|
|
}
|
|
|
$marshaller = $this->marshaller();
|
|
|
return $marshaller->merge($entity, $data, $associations);
|
|
|
@@ -1643,9 +1641,9 @@ class Table implements RepositoryInterface, EventListener {
|
|
|
* `$data` array will appear, those that can be matched by primary key will get
|
|
|
* the data merged, but those that cannot, will be discarded.
|
|
|
*/
|
|
|
- public function patchEntities($entities, array $data, $associations = null) {
|
|
|
- if ($associations === null) {
|
|
|
- $associations = $this->_associations->keys();
|
|
|
+ public function patchEntities($entities, array $data, array $options = []) {
|
|
|
+ if (!isset($options['associated'])) {
|
|
|
+ $options['associated'] = $this->_associations->keys();
|
|
|
}
|
|
|
$marshaller = $this->marshaller();
|
|
|
return $marshaller->mergeMany($entities, $data, $associations);
|