File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 88use Symfony \Component \Filesystem \Filesystem ;
99use UniversityOfAdelaide \ShepherdDrupalScaffold \ScaffoldTrait ;
1010use UniversityOfAdelaide \ShepherdDrupalScaffold \tasks \CopyFile ;
11+ use UniversityOfAdelaide \ShepherdDrupalScaffold \tasks \DeleteFile ;
1112
1213/**
1314 * Updates the Shepherd scaffold files.
@@ -25,6 +26,10 @@ public function onEvent(Event $event): void
2526 foreach (static ::tasks ($ this ->filesystem , $ scaffoldPath , $ projectPath ) as $ task ) {
2627 $ task ->execute ();
2728 }
29+
30+ $ event ->getIO ()->write ('Deleting install.php ' );
31+ $ delete = new DeleteFile ($ this ->filesystem , 'web/core ' , 'install.php ' );
32+ $ delete ->execute ();
2833 }
2934
3035 /**
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace UniversityOfAdelaide \ShepherdDrupalScaffold \tasks ;
6+
7+ use Symfony \Component \Filesystem \Filesystem ;
8+
9+ class DeleteFile implements TaskInterface
10+ {
11+ protected Filesystem $ filesystem ;
12+ protected string $ path ;
13+ protected string $ filename ;
14+
15+ public function __construct (Filesystem $ filesystem , string $ path , string $ filename )
16+ {
17+ $ this ->filesystem = $ filesystem ;
18+ $ this ->path = $ path ;
19+ $ this ->filename = $ filename ;
20+ }
21+
22+ public function getFilename (): string
23+ {
24+ return $ this ->filename ;
25+ }
26+
27+ /**
28+ * @throws \Symfony\Component\Filesystem\Exception\FileNotFoundException
29+ * When original file doesn't exist
30+ * @throws \Symfony\Component\Filesystem\Exception\IOException
31+ * When copy fails
32+ */
33+ public function execute (): void
34+ {
35+ // Skip copying files that already exist at the destination.
36+ if (!$ this ->filesystem ->exists ($ this ->path . '/ ' . $ this ->filename )) {
37+ return ;
38+ }
39+
40+ $ this ->filesystem ->remove (
41+ $ this ->path . '/ ' . $ this ->filename
42+ );
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments