Skip to content

Commit

Permalink
feat(word count analysis): add injector for word count
Browse files Browse the repository at this point in the history
use DI for Word count analysis replacement to utilize updateCollateContentFields
  • Loading branch information
oliver-norden committed May 18, 2021
1 parent c634316 commit 919d04d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _config/injector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ SilverStripe\Core\Injector\Injector:
class: NorthCreationAgency\SEOHelper\NCAPageSeoExtension
QuinnInteractive\Seo\Seo:
class: NorthCreationAgency\SEOHelper\SeoInjector
QuinnInteractive\Seo\Analysis\WordCountAnalysis:
class: NorthCreationAgency\SEOHelper\WordCountAnalysisInjector

14 changes: 14 additions & 0 deletions code/injectors/WordCountAnalysisInjector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace NorthCreationAgency\SEOHelper;

use NorthCreationAgency\SEOHelper\SeoInjector;
use QuinnInteractive\Seo\Analysis\WordCountAnalysis;

class WordCountAnalysisInjector extends WordCountAnalysis
{
public function getWordCount()
{
return count(array_filter(explode(' ', SeoInjector::collateContentFields($this->getPage()))));
}
}

0 comments on commit 919d04d

Please sign in to comment.