-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dominic Tubach
committed
Feb 13, 2024
1 parent
a3b60ac
commit 7080100
Showing
4 changed files
with
119 additions
and
50 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
Civi/RemoteTools/EntityProfile/AbstractReadOnlyRemoteEntityProfile.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/* | ||
* Copyright (C) 2024 SYSTOPIA GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation in version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Civi\RemoteTools\EntityProfile; | ||
|
||
use Civi\RemoteTools\EntityProfile\Authorization\GrantResult; | ||
use Civi\RemoteTools\Form\FormSpec\FormSpec; | ||
|
||
/** | ||
* Abstract implementation for read only access that assumes that internal and | ||
* external fields are the same. (getRemoteFields() and convertToRemoteValues() | ||
* can be reimplemented if necessary.) | ||
* | ||
* @codeCoverageIgnore | ||
* | ||
* @api | ||
*/ | ||
abstract class AbstractReadOnlyRemoteEntityProfile extends AbstractRemoteEntityProfile { | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCreateFormSpec(array $arguments, array $entityFields, ?int $contactId): FormSpec { | ||
throw new \BadMethodCallException('Creating entities is not supported'); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getUpdateFormSpec(array $entityValues, array $entityFields, ?int $contactId): FormSpec { | ||
throw new \BadMethodCallException('Updating entities is not supported'); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function isCreateGranted(array $arguments, ?int $contactId): GrantResult { | ||
return GrantResult::newDenied(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function isDeleteGranted(array $entityValues, ?int $contactId): GrantResult { | ||
return GrantResult::newDenied(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function isUpdateGranted(?array $entityValues, ?int $contactId): GrantResult { | ||
return GrantResult::newDenied(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Civi/RemoteTools/EntityProfile/Traits/ConstProfileMetadataTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/* | ||
* Copyright (C) 2024 SYSTOPIA GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation in version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Civi\RemoteTools\EntityProfile\Traits; | ||
|
||
/** | ||
* Trait that can be used in implementations of RemoteEntityProfileInterface | ||
* that define the metadata in constants. | ||
* | ||
* @see \Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface | ||
* | ||
* @api | ||
*/ | ||
trait ConstProfileMetadataTrait { | ||
|
||
public function getEntityName(): string { | ||
return static::ENTITY_NAME; | ||
} | ||
|
||
public function getName(): string { | ||
return static::NAME; | ||
} | ||
|
||
public function getRemoteEntityName(): string { | ||
return static::REMOTE_ENTITY_NAME; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters