-
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.
Add implementation for CiviCRM Activity entities
- Loading branch information
Dominic Tubach
committed
Oct 26, 2023
1 parent
ec05988
commit 79893c6
Showing
20 changed files
with
728 additions
and
0 deletions.
There are no files selected for viewing
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,43 @@ | ||
name: PHP_CodeSniffer - civiremote_activity | ||
|
||
on: | ||
push: ~ | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
phpcs: | ||
runs-on: ubuntu-latest | ||
name: PHP_CodeSniffer | ||
defaults: | ||
run: | ||
working-directory: modules/civiremote_activity | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.2 | ||
coverage: none | ||
tools: cs2pr | ||
env: | ||
fail-fast: true | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('modules/civiremote_activity/tools/phpcs/composer.json') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: composer update --no-progress --prefer-dist | ||
|
||
- name: Run PHP_CodeSniffer | ||
run: composer phpcs -- -q --report=checkstyle | cs2pr |
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,49 @@ | ||
name: PHPStan - civiremote_activity | ||
|
||
on: | ||
push: ~ | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
phpstan: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: ['7.4', '8.0', '8.2'] | ||
prefer: ['prefer-stable', 'prefer-lowest'] | ||
name: PHPStan with PHP ${{ matrix.php-versions }} ${{ matrix.prefer }} | ||
defaults: | ||
run: | ||
working-directory: modules/civiremote_activity | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
coverage: none | ||
env: | ||
fail-fast: true | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ hashFiles('modules/civiremote_activity/**/composer.json') }} | ||
restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}- | ||
|
||
- name: Install dependencies | ||
run: | | ||
composer update --no-progress --prefer-dist --${{ matrix.prefer }} --optimize-autoloader && | ||
composer composer-phpstan -- update --no-progress --prefer-dist --optimize-autoloader && | ||
composer --working-dir=ci update --no-progress --prefer-dist --${{ matrix.prefer }} --optimize-autoloader | ||
- name: Run PHPStan | ||
run: composer phpstan -- analyse -c phpstan.ci.neon |
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,2 @@ | ||
The dependencies specified in composer.json of this directory are required to | ||
run phpstan in CI. |
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,29 @@ | ||
{ | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "vcs", | ||
"url": "https://github.com/systopia/drupal-json_forms.git" | ||
}, | ||
{ | ||
"type": "vcs", | ||
"url": "https://github.com/systopia/opis-json-schema-ext.git" | ||
}, | ||
{ | ||
"type": "vcs", | ||
"url": "https://github.com/systopia/expression-language-ext.git" | ||
}, | ||
{ | ||
"type": "composer", | ||
"url": "https://packages.drupal.org/8" | ||
} | ||
], | ||
"require": { | ||
"drupal/core": "^9.5 || ^10", | ||
"drupal/json_forms": "~0.1" | ||
} | ||
} |
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,10 @@ | ||
name: CiviRemote Activity | ||
type: module | ||
description: 'CiviRemote Activity' | ||
package: CiviCRM | ||
core_version_requirement: ^9.5 || ^10 | ||
dependencies: | ||
- civiremote_entity | ||
|
||
project: civiremote | ||
version: 0.1-dev |
25 changes: 25 additions & 0 deletions
25
modules/civiremote_activity/civiremote_activity.routing.yml
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,25 @@ | ||
civiremote_activity.create_form: | ||
path: '/civiremote/activity/{profile}/add' | ||
defaults: | ||
_controller: 'Drupal\civiremote_activity\Controller\ActivityCreateController::form' | ||
options: | ||
no_cache: TRUE | ||
parameters: | ||
profile: | ||
type: string | ||
requirements: | ||
_user_is_logged_in: 'TRUE' | ||
|
||
civiremote_activity.update_form: | ||
path: '/civiremote/activity/{profile}/{id}' | ||
defaults: | ||
_controller: 'Drupal\civiremote_activity\Controller\ActivityUpdateController::form' | ||
options: | ||
no_cache: TRUE | ||
parameters: | ||
profile: | ||
type: string | ||
id: | ||
type: int | ||
requirements: | ||
_user_is_logged_in: 'TRUE' |
23 changes: 23 additions & 0 deletions
23
modules/civiremote_activity/civiremote_activity.services.yml
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,23 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
public: false # Controller classes and services directly fetched from container need to be public | ||
|
||
Drupal\civiremote_activity\Api\ActivityApi: | ||
class: Drupal\civiremote_activity\Api\ActivityApi | ||
|
||
Drupal\civiremote_activity\Controller\ActivityCreateController: | ||
class: Drupal\civiremote_activity\Controller\ActivityUpdateController | ||
public: true | ||
|
||
Drupal\civiremote_activity\Controller\ActivityUpdateController: | ||
class: Drupal\civiremote_activity\Controller\ActivityUpdateController | ||
public: true | ||
|
||
Drupal\civiremote_activity\Form\RequestHandler\ActivityCreateFormRequestHandler: | ||
class: Drupal\civiremote_activity\Form\RequestHandler\ActivityCreateFormRequestHandler | ||
public: true | ||
|
||
Drupal\civiremote_activity\Form\RequestHandler\ActivityUpdateFormRequestHandler: | ||
class: Drupal\civiremote_activity\Form\RequestHandler\ActivityUpdateFormRequestHandler | ||
public: true |
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,68 @@ | ||
{ | ||
"name": "custom/civiremote_activity", | ||
"description": "Drupal frontend to access CiviCRM Remote Activity.", | ||
"type": "drupal-custom-module", | ||
"license": "AGPL-3.0-only", | ||
"authors": [ | ||
{ | ||
"name": "SYSTOPIA GmbH", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Drupal\\civiremote_activity\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Drupal\\Tests\\civiremote_activity\\": "tests/src/" | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"config": { | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true, | ||
"phpstan/extension-installer": true | ||
} | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "composer", | ||
"url": "https://packages.drupal.org/8" | ||
} | ||
], | ||
"require": { | ||
"php": "^7.4 || ^8" | ||
}, | ||
"require-dev": { | ||
"drupal/core-dev": "^9.5 || ^10" | ||
}, | ||
"scripts": { | ||
"composer-phpstan": [ | ||
"@composer --working-dir=tools/phpstan" | ||
], | ||
"composer-tools": [ | ||
"@composer-phpstan" | ||
], | ||
"phpcs": [ | ||
"@php vendor/bin/phpcs" | ||
], | ||
"phpcbf": [ | ||
"@php vendor/bin/phpcbf" | ||
], | ||
"phpstan": [ | ||
"@php tools/phpstan/vendor/bin/phpstan" | ||
], | ||
"phpunit": [ | ||
"@php vendor/bin/phpunit --coverage-text" | ||
], | ||
"test": [ | ||
"@phpcs", | ||
"@phpstan", | ||
"@phpunit" | ||
] | ||
} | ||
} |
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,82 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="CiviCRM - PHPStan" | ||
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> | ||
|
||
<file>src</file> | ||
<!--<file>tests</file>--> | ||
<!--<file>civiremote_activity.module</file>--> | ||
|
||
<arg name="extensions" value="php"/> | ||
<arg name="cache" value=".phpcs.cache"/> | ||
<arg name="colors"/> | ||
<arg value="sp"/> | ||
|
||
<!-- Exit with code 0 if warnings, but no error occurred --> | ||
<config name="ignore_warnings_on_exit" value="true"/> | ||
|
||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal"> | ||
<!-- Don't enforce phpdoc type hint because it (might) only duplicate a PHP type hint --> | ||
<exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/> | ||
<exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/> | ||
|
||
<!-- Don't enforce comments --> | ||
<exclude name="Drupal.Commenting.VariableComment.Missing"/> | ||
<exclude name="Drupal.Commenting.ClassComment.Missing"/> | ||
<exclude name="Drupal.Commenting.FunctionComment.Missing"/> | ||
<exclude name="Drupal.Commenting.DocComment.MissingShort"/> | ||
|
||
<!-- Allow "/** @phpstan-var ... */" --> | ||
<exclude name="Drupal.Commenting.InlineComment.DocBlock"/> | ||
|
||
<!-- False positive with license header --> | ||
<exclude name="Drupal.Commenting.FileComment.NamespaceNoFileDoc"/> | ||
</rule> | ||
|
||
<rule ref="vendor/drupal/coder/coder_sniffer/DrupalPractice"/> | ||
|
||
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/> | ||
<rule ref="Generic.CodeAnalysis.EmptyStatement"> | ||
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/> | ||
</rule> | ||
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/> | ||
<rule ref="Generic.Files.OneClassPerFile"/> | ||
<rule ref="Generic.Files.OneInterfacePerFile"/> | ||
<rule ref="Generic.Files.OneObjectStructurePerFile"/> | ||
<rule ref="Generic.Files.OneTraitPerFile"/> | ||
<rule ref="Generic.Formatting.DisallowMultipleStatements"/> | ||
<rule ref="Generic.Metrics.CyclomaticComplexity"/> | ||
<rule ref="Generic.Metrics.NestingLevel"/> | ||
<rule ref="Generic.NamingConventions.AbstractClassNamePrefix"/> | ||
<rule ref="Generic.NamingConventions.InterfaceNameSuffix"/> | ||
<rule ref="Generic.NamingConventions.TraitNameSuffix"/> | ||
<rule ref="Generic.PHP.RequireStrictTypes"/> | ||
<rule ref="PSR1.Files.SideEffects"/> | ||
<rule ref="PSR12.Classes.ClassInstantiation"/> | ||
<rule ref="PSR12.Properties.ConstantVisibility"/> | ||
<rule ref="Squiz.PHP.CommentedOutCode"/> | ||
<rule ref="Squiz.PHP.GlobalKeyword"/> | ||
<rule ref="Squiz.Strings.DoubleQuoteUsage"> | ||
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/> | ||
</rule> | ||
|
||
<!-- Lines can be 120 chars long, but never show errors --> | ||
<rule ref="Generic.Files.LineLength"> | ||
<properties> | ||
<property name="lineLimit" value="120"/> | ||
<property name="absoluteLineLimit" value="0"/> | ||
</properties> | ||
</rule> | ||
|
||
<!-- Ban some functions --> | ||
<rule ref="Generic.PHP.ForbiddenFunctions"> | ||
<properties> | ||
<property name="forbiddenFunctions" type="array"> | ||
<element key="sizeof" value="count"/> | ||
<element key="delete" value="unset"/> | ||
<element key="print" value="echo"/> | ||
<element key="is_null" value="null"/> | ||
<element key="create_function" value="null"/> | ||
</property> | ||
</properties> | ||
</rule> | ||
</ruleset> |
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,8 @@ | ||
includes: | ||
- phpstan.neon.dist | ||
|
||
parameters: | ||
bootstrapFiles: | ||
- ci/vendor/autoload.php | ||
scanFiles: | ||
- ci/vendor/drupal/core/tests/Drupal/Tests/UnitTestCase.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,28 @@ | ||
parameters: | ||
paths: | ||
- src | ||
#- tests | ||
#- civiremote_activity.module | ||
bootstrapFiles: | ||
- vendor/autoload.php | ||
scanDirectories: | ||
- ../civiremote_entity/src | ||
level: 9 | ||
checkTooWideReturnTypesInProtectedAndPublicMethods: true | ||
checkUninitializedProperties: true | ||
checkMissingCallableSignature: true | ||
treatPhpDocTypesAsCertain: false | ||
exceptions: | ||
check: | ||
missingCheckedExceptionInThrows: true | ||
tooWideThrowType: true | ||
checkedExceptionClasses: | ||
- \Assert\AssertionFailedException | ||
implicitThrows: false | ||
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 | ||
# Happens in classes implementing ContainerInjectionInterface::create() | ||
- '/ constructor expects [^\s]+, object(\|null)? given.$/' | ||
|
||
tmpDir: .phpstan |
Oops, something went wrong.