Skip to content
Permalink
Browse files

Allow changing accessible fields when creating Entity

Usage: ``$this->Entity->newEntity($this->request->data, ['accessibleFields' => ['*' => false, 'teste' => true]])``
Related to: #4215
  • Loading branch information...
Henrique Henrique
Henrique authored and Henrique committed Sep 8, 2014
1 parent e307ed3 commit c0463552a63016f7cf0f75fcb81f79361d91cf03
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/ORM/Marshaller.php
@@ -87,6 +87,7 @@ protected function _buildPropertyMap($options) {
* * associated: Associations listed here will be marshalled as well.
* * fiedlList: A whitelist of fields to be assigned to the entity. If not present,
* the accessible fields list in the entity will be used.
* * accessibleFields: A list of fields to allow or deny in entity accessible fields.
*
* @param array $data The data to hydrate.
* @param array $options List of options
@@ -106,6 +107,12 @@ public function one(array $data, array $options = []) {
$data = $data[$tableName];
}
if (isset($options['accessibleFields'])) {
foreach ((array)$options['accessibleFields'] as $key => $value) {
$entity->accessible($key, $value);
}
}
$primaryKey = $schema->primaryKey();
$properties = [];
foreach ($data as $key => $value) {

0 comments on commit c046355

Please sign in to comment.
You can’t perform that action at this time.