Skip to content

Commit 5f8b3ea

Browse files
committed
Initial commit
0 parents  commit 5f8b3ea

16 files changed

+437
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
.env
3+
.editorconfig
4+

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Vladyslav Podorozhnyi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: Magento CLI Constructor Arg Auto Proxy
3+
keywords: Magento, CLI, Proxy, ObjectManager
4+
author: Vlad Podorozhnyi
5+
send_questions_to: vpodorozh@gmail.com | vlad.podorozhnyi@run-as-root.sh
6+
category: System
7+
---
8+
![Magento 2](https://img.shields.io/badge/Magento-2.4.*-orange)
9+
![PHP](https://img.shields.io/badge/php-7.4-blue)
10+
![composer](https://shields.io/badge/composer-v2-darkgreen)
11+
![packagist](https://img.shields.io/badge/packagist-f28d1a)
12+
13+
<br />
14+
<div align="center">
15+
<img src="images/logo.png" alt="Logo" width="100" height="80">
16+
17+
<h3 align="center">Magento 2 - Auto Proxy to CLI class arguments</h3>
18+
19+
<p align="center">
20+
Automatically injects Proxy for any argument defined in CLI command class constructor.
21+
<br />
22+
</p>
23+
</div>
24+
25+
## About The Project
26+
27+
### Purpose:
28+
* speed up `php bin/magento` command execution;
29+
* eliminate `.flag table not found` issues while installation of your project with fresh database (usually used with integration tests) - caused by not using Proxy in CLI of 3rd parties.
30+
31+
## Getting Started
32+
33+
### Prerequisites
34+
* Magento v2.4.* and upper
35+
* composer v2 and upper
36+
37+
### Structure
38+
* magento2-component - see [README.md](component/README.md)
39+
* library - see [README.md](lib/README.md)
40+
41+
### Installation
42+
43+
```bash
44+
composer req vpodorozh/magento-cli-auto-proxy:*
45+
```
46+
47+
## Roadmap
48+
49+
- [x] MVP release
50+
- [x] Documentation
51+
- [ ] PHP 8 support (mostl likely supported already :suspect: )
52+
- [ ] Unit tests coverage
53+
- [ ] Static tests coverage
54+
- [ ] php linting
55+
- [ ] phpcs
56+
- [ ] phpmd
57+
- [ ] phpstan
58+
- [ ] Integration tests coverage
59+
- [ ] Pipelines tests automation
60+
- [ ] Static tests
61+
- [ ] Unit tests
62+
- [ ] Integration tests
63+
- [ ] Magento multiversions tests
64+
65+
## License
66+
67+
Distributed under the MIT License. See `LICENSE.txt` for more information.
68+
69+
## Contact
70+
71+
_Vlad Podorozhnyi_
72+
Twitter: [![@vpodorozh](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2Fvpodorozh)](https://twitter.com/vpodorozh)
73+
Email: `vpodorozh@gmail.com` | `vlad.podorozhnyi@run-as-root.sh`

component/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: [component] CLI Constructor Arg Auto Proxy
3+
keywords: CLI, Proxy, ObjectManager
4+
author: Vlad Podorozhnyi
5+
send_questions_to: vpodorozh@gmail.com | vlad.podorozhnyi@run-as-root.sh
6+
category: System
7+
---
8+
![Magento 2](https://img.shields.io/badge/Magento-2.4.*-orange)
9+
![composer](https://shields.io/badge/composer-v2-darkgreen)
10+
![packagist](https://img.shields.io/badge/packagist-f28d1a)
11+
12+
## \[magento2-component\] Cli Constructor Arg Auto Proxy Component
13+
14+
15+
Magneto 2 component that provides global DI config via `app/etc/di.xml` to create entry point for configuration enrichment.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
3+
<preference for="Magento\Framework\ObjectManager\Config\Reader\Dom"
4+
type="Vpodorozh\CliConstructorArgAutoProxy\Preference\Framework\ObjectManager\Config\Reader\Dom\Interceptor" />
5+
</config>

composer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "vpodorozh/magento-cli-auto-proxy",
3+
"description": "Makes all Magento CLI commands construct dependencies be injected as Proxy.",
4+
"type": "magento2-component",
5+
"require": {
6+
"magento/framework": "*"
7+
},
8+
"require-dev": {
9+
"roave/security-advisories": "dev-latest"
10+
},
11+
"autoload": {
12+
"psr-4": {
13+
"Vpodorozh\\CliConstructorArgAutoProxy\\": "lib"
14+
}
15+
},
16+
"extra": {
17+
"map": [
18+
[
19+
"component/app/etc/cli_arg_auto_proxy_di.xml",
20+
"app/etc/cli_arg_auto_proxy_di.xml"
21+
]
22+
]
23+
}
24+
}

images/logo.png

265 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Vpodorozh\CliConstructorArgAutoProxy\Enum;
5+
6+
interface ProxyClassEntityInterfaceEnum
7+
{
8+
public const PROXY_CLASS_SUFFIX = '\Proxy';
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Vpodorozh\CliConstructorArgAutoProxy\Exception;
5+
6+
use Exception;
7+
8+
class ClassIsNotEligibleForProxyException extends Exception
9+
{}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Vpodorozh\CliConstructorArgAutoProxy\Mapper;
5+
6+
class ProxiedConstructArgsToDiConfigMapper
7+
{
8+
public function map(array $diConfig, string $instanceClassName, array $proxiedConstructArgsConfig): array
9+
{
10+
$cliInstanceConfig = $diConfig[$instanceClassName] ?? [];
11+
$cliInstanceConfig['arguments'] = isset($cliInstanceConfig['arguments']) ?
12+
array_merge($cliInstanceConfig['arguments'], $proxiedConstructArgsConfig) : $proxiedConstructArgsConfig;
13+
14+
$diConfig[$instanceClassName] = $cliInstanceConfig;
15+
16+
return $diConfig;
17+
}
18+
}

0 commit comments

Comments
 (0)