File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,6 @@ public function create($data): Entity
5757        }
5858
5959        foreach  ($ this getMapper ()->getPlugins () as  $ plugin
60-             $ plugingenerateKey ($ instance$ this space );
6160            $ pluginafterInstantiate ($ instance$ this space );
6261        }
6362
@@ -299,15 +298,15 @@ public function save(Entity $instance): Entity
299298            $ clientgetSpaceById ($ this getSpace ()->id )
300299                ->insert ($ tuple
301300
301+             $ instancesetOriginalTuple ($ tuple
302+ 
302303            foreach  ($ this getMapper ()->getPlugins () as  $ plugin
303304                $ pluginafterCreate ($ instance$ this space );
304305            }
305306
306307            if  (method_exists ($ instance'afterCreate ' )) {
307308                $ instanceafterCreate ();
308309            }
309- 
310-             $ instancesetOriginalTuple ($ tuple
311310        }
312311
313312        return  $ instance
Original file line number Diff line number Diff line change 1313
1414class  AnnotationTest extends  TestCase
1515{
16+     public  function  testEntityTriggers ()
17+     {
18+         $ mapper$ this createMapper ();
19+         $ this clean ($ mapper
20+         $ mappergetPlugin (Sequence::class);
21+ 
22+         $ mappergetPlugin (Annotation::class)
23+             ->register ('Entity \\Person ' )
24+             ->migrate ();
25+ 
26+         $ person$ mappergetRepository ('person ' )->create ([
27+             'name '  => 'bazyabushka ' ,
28+         ]);
29+ 
30+         $ this assertNull ($ personfullName );
31+         $ this assertNull ($ personid );
32+ 
33+         $ personsave ();
34+ 
35+         $ this assertNotNull ($ personid );
36+         $ this assertSame ($ personfullName , 'bazyabushka!@ ' );
37+     }
38+ 
1639    public  function  testMixedClassMap ()
1740    {
1841        $ mapper$ this createMapper ();
Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ class Person extends MapperEntity
2323
2424    public  function  beforeCreate ()
2525    {
26-         $ this fullName  = $ this name .'! ' ;
26+         $ this fullName  = $ this name  . '! ' ;
27+     }
28+ 
29+     public  function  afterCreate ()
30+     {
31+         $ this fullName  = $ this fullName  . '@ ' ;
2732    }
2833}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments