@@ -24,7 +24,7 @@ class ObfuscateBehavior extends Behavior
2424 'strategy ' => null ,
2525 'implementedFinders ' => [
2626 'obfuscated ' => 'findObfuscated ' ,
27- 'obfuscate ' => 'findObfuscate '
27+ 'obfuscate ' => 'findObfuscate ' ,
2828 ],
2929 'implementedMethods ' => [
3030 'obfuscate ' => 'obfuscate ' ,
@@ -50,7 +50,8 @@ public function initialize(array $config)
5050 */
5151 public function verifyConfig ()
5252 {
53- if (!$ strategy = $ this ->config ('strategy ' )) {
53+ $ strategy = $ this ->getConfig ('strategy ' );
54+ if (!$ strategy ) {
5455 throw new Exception ('Missing required obfuscation strategy. ' );
5556 }
5657
@@ -73,9 +74,9 @@ public function verifyConfig()
7374 */
7475 public function afterSave (Event $ event , EntityInterface $ entity , ArrayObject $ options )
7576 {
76- $ pk = $ this ->_table ->primaryKey ();
77+ $ pk = $ this ->_table ->getPrimaryKey ();
7778 $ entity ->set ($ pk , $ this ->obfuscate ($ entity ->{$ pk }));
78- $ entity ->dirty ($ pk , false );
79+ $ entity ->setDirty ($ pk , false );
7980 }
8081
8182 /**
@@ -94,8 +95,9 @@ public function beforeFind(Event $event, Query $query, ArrayObject $options, $pr
9495 }
9596
9697 $ query ->traverseExpressions (function ($ expression ) {
97- $ pk = $ this ->_table ->primaryKey ();
98- if (method_exists ($ expression , 'getField ' )
98+ $ pk = $ this ->_table ->getPrimaryKey ();
99+ if (
100+ method_exists ($ expression , 'getField ' )
99101 && in_array ($ expression ->getField (), [$ pk , $ this ->_table ->aliasField ($ pk )])
100102 ) {
101103 $ expression ->setValue ($ this ->elucidate ($ expression ->getValue ()));
@@ -105,8 +107,8 @@ public function beforeFind(Event $event, Query $query, ArrayObject $options, $pr
105107 });
106108
107109 foreach ($ this ->_table ->associations () as $ association ) {
108- if ($ association ->target ()->hasBehavior ('Obfuscate ' ) && ' all ' === $ association ->finder () ) {
109- $ association ->finder ('obfuscate ' );
110+ if ($ association ->getTarget ()->hasBehavior ('Obfuscate ' ) && $ association ->getFinder () === ' all ' ) {
111+ $ association ->setFinder ('obfuscate ' );
110112 }
111113 }
112114 }
@@ -136,7 +138,7 @@ public function findObfuscate(Query $query, array $options)
136138
137139 $ query ->formatResults (function ($ results ) {
138140 return $ results ->map (function ($ row ) {
139- $ pk = $ this ->_table ->primaryKey ();
141+ $ pk = $ this ->_table ->getPrimaryKey ();
140142 $ row [$ pk ] = $ this ->obfuscate ($ row [$ pk ]);
141143
142144 return $ row ;
@@ -175,6 +177,6 @@ public function elucidate($str)
175177 */
176178 public function strategy ()
177179 {
178- return $ this ->config ('strategy ' );
180+ return $ this ->getConfig ('strategy ' );
179181 }
180182}
0 commit comments