AddFeaturePolicyEvent.php 840 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Security\FeaturePolicy;
  8. use OC\Security\FeaturePolicy\FeaturePolicyManager;
  9. use OCP\AppFramework\Http\EmptyFeaturePolicy;
  10. use OCP\EventDispatcher\Event;
  11. /**
  12. * Event that allows to register a feature policy header to a request.
  13. *
  14. * @since 17.0.0
  15. */
  16. class AddFeaturePolicyEvent extends Event {
  17. /** @var FeaturePolicyManager */
  18. private $policyManager;
  19. /**
  20. * @since 17.0.0
  21. */
  22. public function __construct(FeaturePolicyManager $policyManager) {
  23. parent::__construct();
  24. $this->policyManager = $policyManager;
  25. }
  26. /**
  27. * @since 17.0.0
  28. */
  29. public function addPolicy(EmptyFeaturePolicy $policy) {
  30. $this->policyManager->addDefaultPolicy($policy);
  31. }
  32. }