Skip to content
Permalink
Browse files

Be consistent naming the Associations property.

  • Loading branch information...
bar committed Mar 10, 2014
1 parent eee474b commit 750e6d82a2172229fa53f777aa5a3c3aafb9969b
Showing with 20 additions and 20 deletions.
  1. +20 −20 src/ORM/Table.php
@@ -139,7 +139,7 @@ class Table implements RepositoryInterface, EventListener {
*
* @var \Cake\ORM\Associations
*/
protected $_associated;
protected $_associations;
/**
* EventManager for this table.
@@ -185,6 +185,7 @@ class Table implements RepositoryInterface, EventListener {
* passed to it.
* - eventManager: An instance of an event manager to use for internal events
* - behaviors: A BehaviorRegistry. Generally not used outside of tests.
* - associations: An Associations instance.
*
* @param array config Lsit of options for this table
*/
@@ -204,20 +205,19 @@ public function __construct(array $config = []) {
if (!empty($config['entityClass'])) {
$this->entityClass($config['entityClass']);
}
$eventManager = $behaviors = null;
$eventManager = $behaviors = $associations = null;
if (!empty($config['eventManager'])) {
$eventManager = $config['eventManager'];
}
if (!empty($config['behaviors'])) {
$behaviors = $config['behaviors'];
}
$associations = null;
if (!empty($config['associations'])) {
$associations = $config['associations'];
}
$this->_eventManager = $eventManager ?: new EventManager();
$this->_associated = $associations ?: new Associations();
$this->_behaviors = $behaviors ?: new BehaviorRegistry($this);
$this->_associations = $associations ?: new Associations();
$this->initialize($config);
$this->_eventManager->attach($this);
@@ -508,7 +508,7 @@ public function hasBehavior($name) {
* @return \Cake\ORM\Association
*/
public function association($name) {
return $this->_associated->get($name);
return $this->_associations->get($name);
}
/**
@@ -517,7 +517,7 @@ public function association($name) {
* @return \Cake\ORM\Associations
*/
public function associations() {
return $this->_associated;
return $this->_associations;
}
/**
@@ -549,7 +549,7 @@ public function associations() {
public function belongsTo($associated, array $options = []) {
$options += ['sourceTable' => $this];
$association = new BelongsTo($associated, $options);
return $this->_associated->add($association->name(), $association);
return $this->_associations->add($association->name(), $association);
}
/**
@@ -586,7 +586,7 @@ public function belongsTo($associated, array $options = []) {
public function hasOne($associated, array $options = []) {
$options += ['sourceTable' => $this];
$association = new HasOne($associated, $options);
return $this->_associated->add($association->name(), $association);
return $this->_associations->add($association->name(), $association);
}
/**
@@ -627,7 +627,7 @@ public function hasOne($associated, array $options = []) {
public function hasMany($associated, array $options = []) {
$options += ['sourceTable' => $this];
$association = new HasMany($associated, $options);
return $this->_associated->add($association->name(), $association);
return $this->_associations->add($association->name(), $association);
}
/**
@@ -671,7 +671,7 @@ public function hasMany($associated, array $options = []) {
public function belongsToMany($associated, array $options = []) {
$options += ['sourceTable' => $this];
$association = new BelongsToMany($associated, $options);
return $this->_associated->add($association->name(), $association);
return $this->_associations->add($association->name(), $association);
}
/**
@@ -1128,15 +1128,15 @@ protected function _processSave($entity, $options) {
return false;
}
$options['associated'] = $this->_associated->normalizeKeys($associated);
$options['associated'] = $this->_associations->normalizeKeys($associated);
$event = new Event('Model.beforeSave', $this, compact('entity', 'options'));
$this->getEventManager()->dispatch($event);
if ($event->isStopped()) {
return $event->result;
}
$saved = $this->_associated->saveParents(
$saved = $this->_associations->saveParents(
$this,
$entity,
$options['associated'],
@@ -1158,7 +1158,7 @@ protected function _processSave($entity, $options) {
}
if ($success) {
$success = $this->_associated->saveChildren(
$success = $this->_associations->saveChildren(
$this,
$entity,
$options['associated'],
@@ -1364,7 +1364,7 @@ protected function _processDelete($entity, $options) {
throw new \InvalidArgumentException($msg);
}
$this->_associated->cascadeDelete($entity, $options->getArrayCopy());
$this->_associations->cascadeDelete($entity, $options->getArrayCopy());
$query = $this->query();
$statement = $query->delete()
@@ -1542,7 +1542,7 @@ public function entityValidator() {
*/
public function newEntity(array $data = [], $associations = null) {
if ($associations === null) {
$associations = $this->_associated->keys();
$associations = $this->_associations->keys();
}
$marshaller = $this->marshaller();
return $marshaller->one($data, $associations);
@@ -1565,7 +1565,7 @@ public function newEntity(array $data = [], $associations = null) {
*/
public function newEntities(array $data, $associations = null) {
if ($associations === null) {
$associations = $this->_associated->keys();
$associations = $this->_associations->keys();
}
$marshaller = $this->marshaller();
return $marshaller->many($data, $associations);
@@ -1580,7 +1580,7 @@ public function newEntities(array $data, $associations = null) {
*/
public function patchEntity(EntityInterface $entity, array $data, $associations = null) {
if ($associations === null) {
$associations = $this->_associated->keys();
$associations = $this->_associations->keys();
}
$marshaller = $this->marshaller();
return $marshaller->merge($entity, $data, $associations);
@@ -1599,7 +1599,7 @@ public function patchEntity(EntityInterface $entity, array $data, $associations
*/
public function patchEntities($entities, array $data, $associations = null) {
if ($associations === null) {
$associations = $this->_associated->keys();
$associations = $this->_associations->keys();
}
$marshaller = $this->marshaller();
return $marshaller->mergeMany($entities, $data, $associations);
@@ -1649,7 +1649,7 @@ public function patchEntities($entities, array $data, $associations = null) {
*/
public function validate($entity, $options = []) {
if (!isset($options['associated'])) {
$options['associated'] = $this->_associated->keys();
$options['associated'] = $this->_associations->keys();
}
$entityValidator = $this->entityValidator();
@@ -1700,7 +1700,7 @@ public function validate($entity, $options = []) {
*/
public function validateMany($entities, $options = []) {
if (!isset($options['associated'])) {
$options['associated'] = $this->_associated->keys();
$options['associated'] = $this->_associations->keys();
}
$entityValidator = $this->entityValidator();

0 comments on commit 750e6d8

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