Skip to content

Commit cdea07e

Browse files
Merge pull request #292 from eileenmcnaughton/namespace
Namespace Vendor
2 parents 819e1f4 + 115cf8e commit cdea07e

1,568 files changed

Lines changed: 5142 additions & 129617 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
.phpunit.result.cache
22
vendor/bin/
3+
lib/*/vendor/
4+
lib/*/vendor.phar
5+
lib/*/pathload.json
6+
lib/*/pathload.main.php

CRM/Core/Payment/OmnipayMultiProcessor.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626
*/
2727

2828
use Civi\Core\Lock\LockInterface;
29-
use Omnipay\Omnipay;
30-
use Omnipay\Common\AbstractGateway;
31-
use Omnipay\Common\Exception\InvalidRequestException;
29+
use CiviOmniPay\Omnipay\Omnipay;
30+
use CiviOmniPay\Omnipay\Common\AbstractGateway;
3231
use CRM_Omnipaymultiprocessor_ExtensionUtil as E;
33-
use GuzzleHttp\Middleware;
34-
use GuzzleHttp\HandlerStack;
35-
use Omnipay\Common\Http\Client;
36-
use GuzzleHttp\Client as GuzzleClient;
37-
use Http\Adapter\Guzzle6\Client as HttpPlugClient;
32+
use CiviOmniPay\GuzzleHttp\Middleware;
33+
use CiviOmniPay\GuzzleHttp\HandlerStack;
34+
use CiviOmniPay\Omnipay\Common\Http\Client;
35+
use CiviOmniPay\Http\Adapter\Guzzle6\Client as HttpPlugClient;
3836
use Civi\Api4\Contribution;
3937

4038
/**
@@ -125,7 +123,9 @@ public function unserialize($data) {
125123
*/
126124
public function __unserialize(array $data): void {
127125
foreach ($data as $key => $value) {
128-
$this->$key = $value;
126+
if (property_exists($this, $key)) {
127+
$this->$key = $value;
128+
}
129129
}
130130
}
131131

CRM/Core/Payment/PaymentExtended.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ protected function getReturnUrl() {
154154
*
155155
* @return void
156156
*/
157-
public function setReturnUrl(string $returnUrl = null) {
157+
public function setReturnUrl(?string $returnUrl = null) {
158158
$this->returnUrl = $returnUrl;
159159
}
160160

3.88 MB
Binary file not shown.

lib/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This folder contains build instructions for embedded libraries.
2+
3+
The output will go to `../dist/`.

lib/civicrm-omnipay/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
This folder defines the PHAR library (`civicrm-omnipay@X.phar`). Sources are downloaded
2+
via `composer` and moved into an isolated namespace (`CiviOmniPay`). The resulting
3+
library is tracked as `dist/civicrm-omnipay@X.Y.Z.phar`.
4+
5+
## Prefixing
6+
7+
Packages in this folder use namespace-prefixes. Compare:
8+
9+
* __Original Class__: `\Symfony\Component\Mailer\MailerInterface`
10+
* __Prefixed Class__: `\CiviOmniPay\Symfony\Component\Mailer\MailerInterface`
11+
12+
## Autoloader
13+
14+
To use the PHAR library, register via Pathload:
15+
16+
```php
17+
pathload()->addSearchDir(__DIR__ . '/dist');
18+
pathload()->addNamespace('civicrm-omnipay@6', ['CiviOmniPay\\']);
19+
```
20+
21+
When any classes from `CiviOmniPay\\` are used, the PHAR file is mounted. Within
22+
the PHAR, we inherit autoloading rules from the `composer.json` of each
23+
nested library.
24+
25+
## Managing packages
26+
27+
To add, remove, or update the packages within `civicrm-omnipay.phar`, you can use
28+
`composer` commands, e.g.
29+
30+
```bash
31+
cd lib/civicrm-omnipay
32+
composer update foo/bar
33+
compsoer remove baz/quux
34+
composer require whiz/bang
35+
```
36+
37+
When you test the new libraries, you may find that you need to fine-tune:
38+
39+
* The list of files/directories/filters (`box.json`). By default, this
40+
includes most `*.php` files from `vendor/` - but other may require tweaking.
41+
* The namespace-prefixing (`scoper.inc.php`). By default, this skips
42+
prefixing some top-level packages (like `Psr\*`).
43+
44+
## Building
45+
46+
The `ctrl.sh` script will run `composer` and `box` to produce a suitable PHAR.
47+
48+
> TIP: This will also leave an extra folder called `vendor/` that contains the original files.
49+
> If you use an IDE like PhpStorm, then the folder will create extra noise
50+
> that makes it harder to use auto-completion. You should delete the leftover `vendor/`
51+
52+
Here is how I typically run it:
53+
54+
```bash
55+
nix-shell --run './lib/civicrm-omnipay/lib.sh build clean'
56+
```

lib/civicrm-omnipay/box.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"chmod": "0644",
3+
"check-requirements": false,
4+
"exclude-composer-files": false,
5+
"files": [
6+
"composer.json",
7+
"composer.lock",
8+
"pathload.main.php"
9+
],
10+
"directories": [
11+
"vendor/composer"
12+
],
13+
"finder": [
14+
{
15+
"name": "*.php",
16+
"exclude": ["phpunit", "Tests", "Test", "tests", "test"],
17+
"in": "vendor"
18+
}
19+
],
20+
"compactors": ["KevinGH\\Box\\Compactor\\Php", "KevinGH\\Box\\Compactor\\PhpScoper"],
21+
"git-version": "package_version",
22+
"main": false,
23+
"output": "vendor.phar",
24+
"shebang": false,
25+
"stub": true
26+
}

lib/civicrm-omnipay/composer.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"repositories": [
3+
{
4+
"type": "git",
5+
"url": "https://github.com/eileenmcnaughton/omnipay-razorpay.git"
6+
},
7+
{
8+
"type": "git",
9+
"url": "https://github.com/eileenmcnaughton/omnipay-eway.git"
10+
},
11+
{
12+
"type": "git",
13+
"url": "https://github.com/eileenmcnaughton/omnipay-paypal.git"
14+
},
15+
{
16+
"type": "git",
17+
"url": "https://github.com/eileenmcnaughton/omnipay-firstatlanticcommerce-gateway.git"
18+
},
19+
{
20+
"type": "vcs",
21+
"url": "https://github.com/adixon/omnipay-beanstream.git"
22+
}
23+
],
24+
"require": {
25+
"league/omnipay": "^3",
26+
"guzzlehttp/guzzle": "^7.0",
27+
"psr/log": "~1.0 || ~2.0 || ~3.0",
28+
"php-http/mock-client": "^1",
29+
"omnipay/tests": "*@dev",
30+
"omnipay/paypal": "^3.0@dev",
31+
"omnipay/authorizenet": "^3.0@dev",
32+
"omnipay/eway": "^3.0@dev",
33+
"omnipay/mollie": "^5.1@dev",
34+
"sudiptpa/omnipay-nabtransact": "^3.0@dev",
35+
"omnipay/sagepay": "^4.1",
36+
"omnipay/securepay": "^3.0@dev",
37+
"omnipay/stripe": "^3.0@dev",
38+
"omnipay/worldpay": "^3.0@dev",
39+
"omnipay/paymentexpress": "^3.0@dev",
40+
"omnipay/common": "^3.5",
41+
"dioscouri/omnipay-cybersource": "^3.0@dev",
42+
"fuzion/omnipay-mercanet": "^3.0@dev",
43+
"razorpay/omnipay-razorpay": "^3.0@dev",
44+
"clue/stream-filter": "^1.7",
45+
"cloudcogsio/omnipay-firstatlanticcommerce-gateway": "*@dev",
46+
"hounddd/omnipay-systempay": "dev-master",
47+
"ext-json": "*"
48+
},
49+
"replace": {
50+
"psr/log": "^1.0 || ^2.0 || ^3.0"
51+
},
52+
"minimum-stability": "stable",
53+
"prefer-stable": true,
54+
"config": {
55+
"allow-plugins": {
56+
"php-http/discovery": false
57+
},
58+
"process-timeout": 300,
59+
"platform": {
60+
"php": "8.1"
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)