Skip to content
Browse files

Delegating delete logic to HasMany, fixed typos

  • Loading branch information...
1 parent c112a18 commit b36f4ff128adc61d956e616330e20a47b81d90f1 @lorenzo lorenzo committed
Showing with 5 additions and 21 deletions.
  1. +1 −1 src/Model/Behavior/Translate/TranslateTrait.php
  2. +4 −20 src/Model/Behavior/TranslateBehavior.php
View
2 src/Model/Behavior/Translate/TranslateTrait.php
@@ -24,7 +24,7 @@
/**
* Returns the entity containing the translated fields for this object and for
- * the spedcified language. If the translation for the passed language is not
+ * the specified language. If the translation for the passed language is not
* present, a new empty entity will be created so that values can be added to
* it.
*
View
24 src/Model/Behavior/TranslateBehavior.php
@@ -112,7 +112,8 @@ public function setupFieldAssociations($fields, $table) {
'foreignKey' => 'foreign_key',
'strategy' => 'subquery',
'conditions' => ["$table.model" => $alias],
- 'propertyName' => '_i18n'
+ 'propertyName' => '_i18n',
+ 'dependent' => true
]);
}
@@ -218,23 +219,6 @@ public function afterSave(Event $event, Entity $entity) {
}
/**
- * Deletes all translation for the entity that was recently deleted
- *
- * @param \Cake\Event\Event the afterDelete event that was fired
- * @param \Cake\ORM\Entity the entity that was recently deleted
- * @return void
- */
- public function afterDelete(Event $event, Entity $entity) {
- $primary = (array)$this->_table->primaryKey();
- $key = $entity->get(current($primary));
- $table = $this->config()['translationTable'];
- TableRegistry::get($table)->deleteAll([
- 'foreign_key' => $key,
- 'model' => $this->_table->alias()
- ]);
- }
-
-/**
* Sets all future finds for the bound table to also fetch translated fields for
* the passed locale. If no value is passed, it returns the currently configured
* locale
@@ -350,7 +334,7 @@ public function groupTranslations($results) {
/**
* Helper method used to generated multiple translated field entities
- * out fo the data found in the `_translations` property in the passed
+ * out of the data found in the `_translations` property in the passed
* entity. The result will be put into its `_i18n` property
*
* @param \Cake\ORM\Entity $entity
@@ -403,7 +387,7 @@ protected function _bundleTranslatedFields($entity) {
/**
* Returns the ids found for each of the condition arrays passed for the translations
- * table. Each records is index by the corresponding position to the conditions array
+ * table. Each records is indexed by the corresponding position to the conditions array
*
* @param array $ruleSet an array of arary of conditions to be used for finding each
* @return array

0 comments on commit b36f4ff

Please sign in to comment.
Something went wrong with that request. Please try again.