Skip to content

Commit 147590a

Browse files
committed
[C0-3370] Вынести CMS из skysmart в отдельный бандл
0 parents  commit 147590a

File tree

108 files changed

+3407
-0
lines changed

Some content is hidden

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

108 files changed

+3407
-0
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 4
9+
10+
[{*.yaml,*.yml,*.json}]
11+
indent_size = 2

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea/
2+
/vendor/
3+
composer.lock

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# MarketingCmsBundle
2+
3+
## Краткое описание
4+
Добавляет в проект с easyadmin функционал CMS (статические файлы, редиректы и конструктор страниц).
5+
6+
## Ответственные:
7+
* Code owner: Сергей Романов
8+
* Product Owner: Иван Бодяк
9+
* Команда: Marketing Core (C0)
10+
11+
## Slack-каналы
12+
* [#marketing-core](https://skyeng.slack.com/archives/CNJ4ZEQ1Z)
13+
* [#marketing-code-review](https://skyeng.slack.com/archives/CS3911LA1)
14+
15+
## Ссылка на общую документацию
16+
https://confluence.skyeng.tech/x/SLMhBQ
17+
18+
## Технологический стек
19+
* PHP 7.3 + Symfony 4.4
20+
21+
# Установка
22+
23+
* Добавляем в composer.json новый репозиторий:
24+
```json
25+
{
26+
"type": "vcs",
27+
"url": "[email protected]:skyeng/marketing-cms-bundle.git"
28+
}
29+
```
30+
* Подключаем пакет
31+
32+
`composer require skyeng/marketing-cms-bundle:^1.0`
33+
34+
* Добавляем бандл в bundles.php
35+
```php
36+
Skyeng\MarketingCmsBundle\MarketingCmsBundle::class => ['all' => true]
37+
```
38+
39+
* Прописываем роуты для API
40+
```yaml
41+
# config/routes/marketing_cms.yaml
42+
43+
marketing_cms:
44+
resource: '@MarketingCmsBundle/Resources/config/routes.yaml'
45+
```
46+
* При наличии NelmioApiDocBundle копируем в его конфиг definitions из `vendor/skyeng/marketing-cms-bundle/src/Resources/config/packages/nelmio_api_doc.yaml`
47+
48+
* Генерим миграции для сущностей CMS
49+
50+
`bin/console make:migration`

codeception.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace: Skyeng\MarketingCmsBundle\Tests
2+
paths:
3+
tests: tests
4+
output: tests/_output
5+
data: tests/_data
6+
support: tests/_support
7+
envs: tests/_envs
8+
actor_suffix: Tester
9+
extensions:
10+
enabled:
11+
- Codeception\Extension\RunFailed
12+
13+
coverage:
14+
enabled: true
15+
low_limit: 30
16+
high_limit: 60
17+
include:
18+
- src/*

composer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "skyeng/marketing-cms-bundle",
3+
"description": "Marketing CMS Bundle",
4+
"type": "symfony-bundle",
5+
"require": {
6+
"php": "^7.3.3",
7+
"easycorp/easyadmin-bundle": "^3.2",
8+
"psr/http-message": "*",
9+
"ramsey/uuid": "^4.1",
10+
"ramsey/uuid-doctrine": "^1.6",
11+
"symfony/validator": "4.4.*"
12+
},
13+
"require-dev": {
14+
"codeception/codeception": "^2.5",
15+
"doctrine/doctrine-fixtures-bundle": "^3.4",
16+
"doctrine/doctrine-migrations-bundle": "^3.0",
17+
"nelmio/api-doc-bundle": "^3.6"
18+
},
19+
"suggest": {
20+
"nelmio/api-doc-bundle": "Highly recommended for api documentation"
21+
},
22+
"autoload": {
23+
"psr-4": {
24+
"Skyeng\\MarketingCmsBundle\\": "src/",
25+
"DoctrineMigrations\\": "src/Infrastructure/Doctrine/Migrations/"
26+
}
27+
},
28+
"autoload-dev": {
29+
"psr-4": {
30+
"Skyeng\\MarketingCmsBundle\\Tests\\": [
31+
"tests/",
32+
"tests/_support/"
33+
],
34+
"Skyeng\\MarketingCmsBundle\\Tests\\Api\\": "tests/api/",
35+
"Skyeng\\MarketingCmsBundle\\Tests\\Functional\\": "tests/functional/",
36+
"Skyeng\\MarketingCmsBundle\\Tests\\Integrational\\": "tests/integrational/",
37+
"Skyeng\\MarketingCmsBundle\\Tests\\Unit\\": "tests/unit/"
38+
}
39+
},
40+
"config": {
41+
"sort-packages": true
42+
}
43+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Skyeng\MarketingCmsBundle\Application\Cms\File\Assembler;
6+
7+
use Skyeng\MarketingCmsBundle\Application\Cms\File\Dto\GetFileV1ResultDto;
8+
use Skyeng\MarketingCmsBundle\Domain\Entity\File;
9+
10+
class GetFileV1ResultAssembler implements GetFileV1ResultAssemblerInterface
11+
{
12+
public function assemble(File $file): GetFileV1ResultDto
13+
{
14+
return new GetFileV1ResultDto(
15+
$file->getContent(),
16+
$file->getContentType()->getValue(),
17+
$file->getResource()->getUri()->getPathname(),
18+
$file->getCacheTime()->getValue(),
19+
);
20+
}
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Skyeng\MarketingCmsBundle\Application\Cms\File\Assembler;
6+
7+
use Skyeng\MarketingCmsBundle\Application\Cms\File\Dto\GetFileV1ResultDto;
8+
use Skyeng\MarketingCmsBundle\Domain\Entity\File;
9+
10+
interface GetFileV1ResultAssemblerInterface
11+
{
12+
public function assemble(File $file): GetFileV1ResultDto;
13+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Skyeng\MarketingCmsBundle\Application\Cms\File\Dto;
6+
7+
use Swagger\Annotations as SWG;
8+
9+
/**
10+
* @SWG\Definition(
11+
* required={"uri"}
12+
* )
13+
*/
14+
class GetFileV1RequestDto
15+
{
16+
/**
17+
* @var string
18+
* @SWG\Property(example="/test.txt")
19+
*/
20+
public $uri;
21+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Skyeng\MarketingCmsBundle\Application\Cms\File\Dto;
6+
7+
class GetFileV1ResultDto
8+
{
9+
/**
10+
* @var string
11+
*/
12+
public $content;
13+
14+
/**
15+
* @var string
16+
*/
17+
public $contentType;
18+
19+
/**
20+
* @var string
21+
*/
22+
public $filename;
23+
24+
/**
25+
* @var string
26+
*/
27+
public $cacheTime;
28+
29+
public function __construct(string $content, string $contentType, string $filename, string $cacheTime)
30+
{
31+
$this->content = $content;
32+
$this->contentType = $contentType;
33+
$this->filename = $filename;
34+
$this->cacheTime = $cacheTime;
35+
}
36+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Skyeng\MarketingCmsBundle\Application\Cms\File\Exception;
6+
7+
use Skyeng\MarketingCmsBundle\Application\Exception\ApplicationException;
8+
use Throwable;
9+
10+
class FileRedirectException extends ApplicationException
11+
{
12+
/**
13+
* @var string
14+
*/
15+
private $targetUrl;
16+
17+
/**
18+
* @var int
19+
*/
20+
private $httpCode;
21+
22+
public function __construct(string $targetUrl, int $httpCode, $message = "", $code = 0, Throwable $previous = null)
23+
{
24+
parent::__construct($message, $code, $previous);
25+
$this->targetUrl = $targetUrl;
26+
$this->httpCode = $httpCode;
27+
}
28+
29+
public function getTargetUrl(): string
30+
{
31+
return $this->targetUrl;
32+
}
33+
34+
public function getHttpCode(): int
35+
{
36+
return $this->httpCode;
37+
}
38+
}

0 commit comments

Comments
 (0)