Skip to content

Commit

Permalink
Move page class into Civi\Funding\Page namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Tubach committed Feb 4, 2025
1 parent 0ce66fe commit 98f4f33
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 25 deletions.
7 changes: 4 additions & 3 deletions Civi/Funding/Event/Remote/RemotePageRequestEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,22 @@

namespace Civi\Funding\Event\Remote;

use Civi\Funding\Page\AbstractRemoteControllerPage;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\EventDispatcher\Event;

final class RemotePageRequestEvent extends Event {

private \CRM_Funding_Page_AbstractRemotePage $page;
private AbstractRemoteControllerPage $page;

private Request $request;

public function __construct(\CRM_Funding_Page_AbstractRemotePage $page, Request $request) {
public function __construct(AbstractRemoteControllerPage $page, Request $request) {
$this->page = $page;
$this->request = $request;
}

public function getPage(): \CRM_Funding_Page_AbstractRemotePage {
public function getPage(): AbstractRemoteControllerPage {
return $this->page;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

declare(strict_types = 1);

namespace Civi\Funding\Page;

use Civi\Funding\Controller\PageControllerInterface;
use Civi\RemoteTools\RequestContext\RequestContextInterface;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -25,10 +27,8 @@

/**
* @codeCoverageIgnore
*
* phpcs:disable Generic.NamingConventions.AbstractClassNamePrefix.Missing
*/
abstract class CRM_Funding_Page_AbstractPage extends \CRM_Core_Page {
abstract class AbstractControllerPage extends \CRM_Core_Page {

public function run(): void {
$request = Request::createFromGlobals();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

declare(strict_types = 1);

namespace Civi\Funding\Page;

use Civi\Funding\Event\Remote\RemotePageRequestEvent;
use Civi\RemoteTools\RequestContext\RequestContextInterface;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -27,7 +29,7 @@
*
* phpcs:disable Generic.NamingConventions.AbstractClassNamePrefix.Missing
*/
abstract class CRM_Funding_Page_AbstractRemotePage extends CRM_Funding_Page_AbstractPage {
abstract class AbstractRemoteControllerPage extends AbstractControllerPage {

protected function handle(Request $request): Response {
/** @var \Civi\RemoteTools\RequestContext\RequestContextInterface $requestContext */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

declare(strict_types = 1);

use Civi\Funding\Controller\PageControllerInterface;
namespace Civi\Funding\Page;

use Civi\Funding\Controller\DrawdownAcceptController;
use Civi\Funding\Controller\PageControllerInterface;

/**
* @codeCoverageIgnore
*/
class CRM_Funding_Page_DrawdownAccept extends CRM_Funding_Page_AbstractPage {
final class DrawdownAcceptPage extends AbstractControllerPage {

protected function getController(): PageControllerInterface {
return \Civi::service(DrawdownAcceptController::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

declare(strict_types = 1);

namespace Civi\Funding\Page;

use Civi\Funding\Controller\PageControllerInterface;
use Civi\Funding\Controller\DrawdownDocumentDownloadController;

/**
* @codeCoverageIgnore
*/
class CRM_Funding_Page_DrawdownDocumentDownload extends CRM_Funding_Page_AbstractPage {
final class DrawdownDocumentDownloadPage extends AbstractControllerPage {

protected function getController(): PageControllerInterface {
return \Civi::service(DrawdownDocumentDownloadController::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

declare(strict_types = 1);

namespace Civi\Funding\Page;

use Civi\Funding\Controller\PageControllerInterface;
use Civi\Funding\Controller\DrawdownRejectController;

/**
* @codeCoverageIgnore
*/
class CRM_Funding_Page_DrawdownReject extends CRM_Funding_Page_AbstractPage {
final class DrawdownRejectPage extends AbstractControllerPage {

protected function getController(): PageControllerInterface {
return \Civi::service(DrawdownRejectController::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

declare(strict_types = 1);

use Civi\Funding\Controller\PageControllerInterface;
namespace Civi\Funding\Page;

use Civi\Funding\Controller\ApplicationTemplateRenderController;
use Civi\Funding\Controller\PageControllerInterface;

/**
* @codeCoverageIgnore
*/
final class CRM_Funding_Page_RemoteApplicationTemplateRender extends CRM_Funding_Page_AbstractRemotePage {
final class RemoteApplicationTemplateRenderPage extends AbstractRemoteControllerPage {

protected function getController(): PageControllerInterface {
return \Civi::service(ApplicationTemplateRenderController::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

declare(strict_types = 1);

namespace Civi\Funding\Page;

use Civi\Funding\Controller\PageControllerInterface;
use Civi\Funding\Controller\TransferContractDownloadController;

/**
* @codeCoverageIgnore
*/
class CRM_Funding_Page_RemoteTransferContractDownload extends CRM_Funding_Page_AbstractRemotePage {
class RemoteTransferContractDownloadPage extends AbstractRemoteControllerPage {

protected function getController(): PageControllerInterface {
return \Civi::service(TransferContractDownloadController::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

declare(strict_types = 1);

namespace Civi\Funding\Page;

use Civi\Funding\Controller\PageControllerInterface;
use Civi\Funding\Controller\TransferContractDownloadController;

/**
* @codeCoverageIgnore
*/
class CRM_Funding_Page_TransferContractDownload extends CRM_Funding_Page_AbstractPage {
final class TransferContractDownloadPage extends AbstractControllerPage {

protected function getController(): PageControllerInterface {
return \Civi::service(TransferContractDownloadController::class);
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ parameters:
ignoreErrors:
# Note paths are prefixed with "*/" to work with inspections in PHPStorm because of:
# https://youtrack.jetbrains.com/issue/WI-63891/PHPStan-ignoreErrors-configuration-isnt-working-with-inspections
- '#^Method CRM_Funding_Page_[^\s]+::getController\(\) should return Civi\\Funding\\Controller\\PageControllerInterface but returns mixed.$#'
- '#^Method Civi\\Funding\\Page\\[^\s]+Page::getController\(\) should return Civi\\Funding\\Controller\\PageControllerInterface but returns mixed.$#'
- '#^Method Civi\\Funding\\FundingCaseTypeServiceLocator::[^\s]+ should return [^\s]+ but returns mixed.$#'
-
message: '#has an uninitialized property#'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Civi\Funding\Contact\FundingRemoteContactIdResolverInterface;
use Civi\Funding\Event\Remote\RemotePageRequestEvent;
use Civi\Funding\Mock\RequestContext\TestRequestContext;
use Civi\Funding\Page\AbstractRemoteControllerPage;
use Civi\RemoteTools\Exception\ResolveContactIdFailedException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function testGetSubscribedEvents(): void {
}

public function test(): void {
$pageMock = $this->createMock(\CRM_Funding_Page_AbstractRemotePage::class);
$pageMock = $this->createMock(AbstractRemoteControllerPage::class);
$request = new Request();
$request->headers->set('X-Civi-Remote-Contact-Id', 'abc');
$event = new RemotePageRequestEvent($pageMock, $request);
Expand All @@ -79,7 +80,7 @@ public function test(): void {
}

public function testRemoteContactIdMissing(): void {
$pageMock = $this->createMock(\CRM_Funding_Page_AbstractRemotePage::class);
$pageMock = $this->createMock(AbstractRemoteControllerPage::class);
$request = new Request();
$event = new RemotePageRequestEvent($pageMock, $request);

Expand All @@ -89,7 +90,7 @@ public function testRemoteContactIdMissing(): void {
}

public function testRemoteContactIdResolveFailed(): void {
$pageMock = $this->createMock(\CRM_Funding_Page_AbstractRemotePage::class);
$pageMock = $this->createMock(AbstractRemoteControllerPage::class);
$request = new Request();
$request->headers->set('X-Civi-Remote-Contact-Id', 'abc');
$event = new RemotePageRequestEvent($pageMock, $request);
Expand Down
12 changes: 6 additions & 6 deletions xml/Menu/funding.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
<menu>
<item>
<path>civicrm/funding/remote/application/render</path>
<page_callback>CRM_Funding_Page_RemoteApplicationTemplateRender</page_callback>
<page_callback>Civi\Funding\Page\RemoteApplicationTemplateRenderPage</page_callback>
<title>RemoteApplicationTemplateRender</title>
<access_arguments>access Remote Funding</access_arguments>
</item>
<item>
<path>civicrm/funding/transfer-contract/download</path>
<page_callback>CRM_Funding_Page_TransferContractDownload</page_callback>
<page_callback>Civi\Funding\Page\TransferContractDownloadPage</page_callback>
<title>TransferContractDownload</title>
<access_arguments>access Funding;administer Funding</access_arguments>
</item>
<item>
<path>civicrm/funding/remote/transfer-contract/download</path>
<page_callback>CRM_Funding_Page_RemoteTransferContractDownload</page_callback>
<page_callback>Civi\Funding\Page\RemoteTransferContractDownloadPage</page_callback>
<title>RemoteTransferContractDownload</title>
<access_arguments>access Remote Funding</access_arguments>
</item>
<item>
<path>civicrm/funding/drawdown/accept</path>
<page_callback>CRM_Funding_Page_DrawdownAccept</page_callback>
<page_callback>Civi\Funding\Page\DrawdownAcceptPage</page_callback>
<title>DrawdownAccept</title>
<access_arguments>access Funding;administer Funding</access_arguments>
</item>
<item>
<path>civicrm/funding/drawdown/reject</path>
<page_callback>CRM_Funding_Page_DrawdownReject</page_callback>
<page_callback>Civi\Funding\Page\DrawdownRejectPage</page_callback>
<title>DrawdownReject</title>
<access_arguments>access Funding;administer Funding</access_arguments>
</item>
<item>
<path>civicrm/funding/drawdown-document/download</path>
<page_callback>CRM_Funding_Page_DrawdownDocumentDownload</page_callback>
<page_callback>Civi\Funding\Page\DrawdownDocumentDownloadPage</page_callback>
<title>DrawdownDocumentDownload</title>
<access_arguments>access Funding;administer Funding</access_arguments>
</item>
Expand Down

0 comments on commit 98f4f33

Please sign in to comment.