File tree Expand file tree Collapse file tree 6 files changed +22
-6
lines changed
Expand file tree Collapse file tree 6 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 2525 },
2626 "require" : {
2727 "php" : " ^8.0" ,
28- "statamic/cms" : " ^4.48 "
28+ "statamic/cms" : " ^4.51 "
2929 },
3030 "require-dev" : {
3131 "doctrine/dbal" : " ^3.3" ,
Original file line number Diff line number Diff line change 77use Statamic \Assets \Asset as FileAsset ;
88use Statamic \Assets \AssetUploader as Uploader ;
99use Statamic \Contracts \Assets \Asset as AssetContract ;
10+ use Statamic \Data \HasDirtyState ;
1011use Statamic \Facades \Blink ;
1112use Statamic \Facades \Path ;
1213use Statamic \Support \Arr ;
1314use Statamic \Support \Str ;
1415
1516class Asset extends FileAsset
1617{
18+ use HasDirtyState {
19+ syncOriginal as traitSyncOriginal;
20+ }
21+
22+ public function syncOriginal ()
23+ {
24+ // FileAsset overrides the trait method in order to add the "pending
25+ // data" logic. We don't need it here since everything comes from
26+ // the model so we'll just use the original trait method again.
27+ return $ this ->traitSyncOriginal ();
28+ }
29+
1730 protected $ existsOnDisk = false ;
1831 protected $ removedData = [];
1932
@@ -22,7 +35,8 @@ public static function fromModel(Model $model)
2235 return (new static ())
2336 ->container ($ model ->container )
2437 ->path (Str::replace ('// ' , '/ ' , $ model ->folder .'/ ' .$ model ->basename ))
25- ->hydrateMeta ($ model ->meta );
38+ ->hydrateMeta ($ model ->meta )
39+ ->syncOriginal ();
2640 }
2741
2842 public function meta ($ key = null )
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public static function fromModel(Model $model)
3636 }
3737 }
3838
39- return $ entry ;
39+ return $ entry-> syncOriginal () ;
4040 }
4141
4242 public function toModel ()
Original file line number Diff line number Diff line change @@ -35,14 +35,13 @@ public static function fromModel(Model $model)
3535 unset($ data ['collection ' ]);
3636 }
3737
38- $ term ->syncOriginal ();
3938 $ term ->data ($ data );
4039
4140 if (config ('statamic.system.track_last_update ' )) {
4241 $ term ->set ('updated_at ' , $ model ->updated_at ?? $ model ->created_at );
4342 }
4443
45- return $ term ;
44+ return $ term-> syncOriginal () ;
4645 }
4746
4847 public function toModel ()
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public function entry_is_found_within_all_created_entries_using_entry_facade_wit
3939 public function entry_is_found_within_all_created_entries_and_select_query_columns_are_set_using_entry_facade_with_find_method_with_columns_param ()
4040 {
4141 $ searchedEntry = $ this ->createDummyCollectionAndEntries ();
42- $ columns = ['title ' ];
42+ $ columns = ['foo ' , ' collection ' ];
4343 $ retrievedEntry = Entry::query ()->find ($ searchedEntry ->id (), $ columns );
4444
4545 $ retrievedEntry ->model (null );
Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ class EntryTest extends TestCase
1919 /** @test */
2020 public function it_loads_from_entry_model ()
2121 {
22+ Collection::make ('blog ' )->title ('blog ' )->save ();
23+
2224 $ model = new EntryModel ([
25+ 'collection ' => 'blog ' ,
2326 'slug ' => 'the-slug ' ,
2427 'data ' => [
2528 'foo ' => 'bar ' ,
You can’t perform that action at this time.
0 commit comments