← All changes
|
src/integrations/watchers/indexable-term-watcher.php
+21
-9
18.3
→
trunk
View file →
| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | use Yoast\WP\SEO\Builders\Indexable_Builder; |
| 6 | 6 | use Yoast\WP\SEO\Builders\Indexable_Link_Builder; |
| 7 | 7 | use Yoast\WP\SEO\Conditionals\Migrations_Conditional; |
| 8 | +use Yoast\WP\SEO\Helpers\Indexable_Helper; | |
| 8 | 9 | use Yoast\WP\SEO\Helpers\Site_Helper; |
| 9 | 10 | use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 10 | 11 | use Yoast\WP\SEO\Repositories\Indexable_Repository; |
| 11 | 12 | |
| @@ -35,8 +36,15 @@ | ||
| 35 | 36 | */ |
| 36 | 37 | protected $link_builder; |
| 37 | 38 | |
| 38 | 39 | /** |
| 40 | + * The indexable helper. | |
| 41 | + * | |
| 42 | + * @var Indexable_Helper | |
| 43 | + */ | |
| 44 | + private $indexable_helper; | |
| 45 | + | |
| 46 | + /** | |
| 39 | 47 | * Represents the site helper. |
| 40 | 48 | * |
| 41 | 49 | * @var Site_Helper |
| 42 | 50 | */ |
| @@ -53,23 +61,26 @@ | ||
| 53 | 61 | |
| 54 | 62 | /** |
| 55 | 63 | * Indexable_Term_Watcher constructor. |
| 56 | 64 | * |
| 57 | - * @param Indexable_Repository $repository The repository to use. | |
| 58 | - * @param Indexable_Builder $builder The post builder to use. | |
| 59 | - * @param Indexable_Link_Builder $link_builder The lint builder to use. | |
| 60 | - * @param Site_Helper $site The site helper. | |
| 65 | + * @param Indexable_Repository $repository The repository to use. | |
| 66 | + * @param Indexable_Builder $builder The post builder to use. | |
| 67 | + * @param Indexable_Link_Builder $link_builder The lint builder to use. | |
| 68 | + * @param Indexable_Helper $indexable_helper The indexable helper. | |
| 69 | + * @param Site_Helper $site The site helper. | |
| 61 | 70 | */ |
| 62 | 71 | public function __construct( |
| 63 | 72 | Indexable_Repository $repository, |
| 64 | 73 | Indexable_Builder $builder, |
| 65 | 74 | Indexable_Link_Builder $link_builder, |
| 75 | + Indexable_Helper $indexable_helper, | |
| 66 | 76 | Site_Helper $site |
| 67 | 77 | ) { |
| 68 | - $this->repository = $repository; | |
| 69 | - $this->builder = $builder; | |
| 70 | - $this->link_builder = $link_builder; | |
| 71 | - $this->site = $site; | |
| 78 | + $this->repository = $repository; | |
| 79 | + $this->builder = $builder; | |
| 80 | + $this->link_builder = $link_builder; | |
| 81 | + $this->indexable_helper = $indexable_helper; | |
| 82 | + $this->site = $site; | |
| 72 | 83 | } |
| 73 | 84 | |
| 74 | 85 | /** |
| 75 | 86 | * Registers the hooks. |
| @@ -96,8 +107,9 @@ | ||
| 96 | 107 | return; |
| 97 | 108 | } |
| 98 | 109 | |
| 99 | 110 | $indexable->delete(); |
| 111 | + \do_action( 'wpseo_indexable_deleted', $indexable ); | |
| 100 | 112 | } |
| 101 | 113 | |
| 102 | 114 | /** |
| 103 | 115 | * Update the taxonomy meta data on save. |
| @@ -134,7 +146,7 @@ | ||
| 134 | 146 | // Update links. |
| 135 | 147 | $this->link_builder->build( $indexable, $term->description ); |
| 136 | 148 | |
| 137 | 149 | $indexable->object_last_modified = \max( $indexable->object_last_modified, \current_time( 'mysql' ) ); |
| 138 | - $indexable->save(); | |
| 150 | + $this->indexable_helper->save_indexable( $indexable ); | |
| 139 | 151 | } |
| 140 | 152 | } |