Skip to content

Commit

Permalink
Minor code improvements for quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Firesphere committed Jul 20, 2019
1 parent f41a3f1 commit 7d5ae91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Models/SRI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Firesphere\CSPHeaders\Models;

use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\Security\PermissionProvider;

Expand Down Expand Up @@ -30,7 +31,7 @@ class SRI extends DataObject implements PermissionProvider

/**
* Created on request
* @param null $member
* @param null|Member $member
* @param array $context
* @return bool
*/
Expand All @@ -41,7 +42,7 @@ public function canCreate($member = null, $context = array())

/**
* If it needs to be edited, it should actually be recreated
* @param null $member
* @param null|Member $member
* @return bool
*/
public function canEdit($member = null)
Expand All @@ -50,7 +51,7 @@ public function canEdit($member = null)
}

/**
* @param null $member
* @param null|Member $member
* @return bool|int
*/
public function canDelete($member = null)
Expand Down
7 changes: 6 additions & 1 deletion src/View/CSPBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ public function includeInHTML($content): string

// Skip if content isn't injectable, or there is nothing to inject
$tagsAvailable = preg_match('#</head\b#', $content);
$hasFiles = $this->css || $this->javascript || $this->customCSS || $this->customScript || $this->customHeadTags;
$hasFiles = count($this->css) ||
count($this->javascript) ||
count($this->customCSS) ||
count($this->customScript) ||
count($this->customHeadTags);

if (!$tagsAvailable || !$hasFiles) {
return $content;
}
Expand Down

0 comments on commit 7d5ae91

Please sign in to comment.