PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.6
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / llms-txt / application / file / commands / remove-file-command-handler.php

remove-file-command-handler.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.6, at src/llms-txt/application/file/commands/remove-file-command-handler.php

70 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded
4 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
5 namespace Yoast\WP\SEO\Llms_Txt\Application\File\Commands;
6
7 use Yoast\WP\SEO\Helpers\Options_Helper;
8 use Yoast\WP\SEO\Llms_Txt\Infrastructure\File\WordPress_File_System_Adapter;
9 use Yoast\WP\SEO\Llms_Txt\Infrastructure\File\WordPress_Llms_Txt_Permission_Gate;
10
11 /**
12 * Handles the removal of the llms.txt
13 */
14 class Remove_File_Command_Handler {
15
16 /**
17 * The options helper.
18 *
19 * @var Options_Helper
20 */
21 private $options_helper;
22
23 /**
24 * The file system adapter.
25 *
26 * @var WordPress_File_System_Adapter
27 */
28 private $file_system_adapter;
29
30 /**
31 * The permission gate.
32 *
33 * @var WordPress_Llms_Txt_Permission_Gate $permission_gate
34 */
35 private $permission_gate;
36
37 /**
38 * Constructor.
39 *
40 * @param Options_Helper $options_helper The options helper.
41 * @param WordPress_File_System_Adapter $file_system_adapter The file system adapter.
42 * @param WordPress_Llms_Txt_Permission_Gate $permission_gate The permission gate.
43 */
44 public function __construct(
45 Options_Helper $options_helper,
46 WordPress_File_System_Adapter $file_system_adapter,
47 WordPress_Llms_Txt_Permission_Gate $permission_gate
48 ) {
49 $this->options_helper = $options_helper;
50 $this->file_system_adapter = $file_system_adapter;
51 $this->permission_gate = $permission_gate;
52 }
53
54 /**
55 * Runs the command.
56 *
57 * @return void
58 */
59 public function handle() {
60 if ( $this->permission_gate->is_managed_by_yoast_seo() ) {
61 $file_removed = $this->file_system_adapter->remove_file();
62
63 if ( $file_removed ) {
64 // Maybe move this to a class if we need to handle this option more often.
65 \update_option( Populate_File_Command_Handler::CONTENT_HASH_OPTION, '' );
66 }
67 }
68 }
69 }
70