Navigation Menu

Skip to content

Commit

Permalink
Be consistent naming the Associations property.
Browse files Browse the repository at this point in the history
  • Loading branch information
bar committed Mar 10, 2014
1 parent eee474b commit 750e6d8
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/ORM/Table.php
Expand Up @@ -139,7 +139,7 @@ class Table implements RepositoryInterface, EventListener {
*
* @var \Cake\ORM\Associations
*/
protected $_associated;
protected $_associations;

/**
* EventManager for this table.
Expand Down Expand Up @@ -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
*/
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -517,7 +517,7 @@ public function association($name) {
* @return \Cake\ORM\Associations
*/
public function associations() {
return $this->_associated;
return $this->_associations;
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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'],
Expand All @@ -1158,7 +1158,7 @@ protected function _processSave($entity, $options) {
}

if ($success) {
$success = $this->_associated->saveChildren(
$success = $this->_associations->saveChildren(
$this,
$entity,
$options['associated'],
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 750e6d8

Please sign in to comment.