Skip to content

Commit

Permalink
Add ImagePropertyAutoconfigureConfigPass
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Dec 27, 2018
1 parent efbfa91 commit 93ac2a7
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ projects/open-training/public/build/*/glyphicons-*

.env

public/uploads/images
projects/open-training/public/uploads/images
projects/*/composer.lock
4 changes: 2 additions & 2 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<?php declare(strict_types=1);

# switch as needed
return require_once __DIR__ . '/../projects/open-training/bin/console';
//return require_once __DIR__ . '/../projects/open-real-estate/bin/console';
require_once __DIR__ . '/../projects/open-training/bin/console';
//require_once __DIR__ . '/../projects/open-real-estate/bin/console';
1 change: 1 addition & 0 deletions packages/better-easy-admin/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ services:
resource: '../src'

Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory: ~
Symplify\PackageBuilder\Reflection\PrivatesAccessor: ~
28 changes: 18 additions & 10 deletions packages/better-easy-admin/src/Command/DebugConfigPassCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Configuration\ConfigManager;
use EasyCorp\Bundle\EasyAdminBundle\Configuration\ConfigPassInterface;
use Nette\Utils\Strings;
use ReflectionClass;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -14,11 +15,6 @@

final class DebugConfigPassCommand extends Command
{
/**
* @var array
*/
private $configPasses = [];

/**
* @var ConfigManager
*/
Expand All @@ -29,11 +25,20 @@ final class DebugConfigPassCommand extends Command
*/
private $symfonyStyle;

public function __construct(ConfigManager $configManager, SymfonyStyle $symfonyStyle)
{
/**
* @var PrivatesAccessor
*/
private $privatesAccessor;

public function __construct(
ConfigManager $configManager,
SymfonyStyle $symfonyStyle,
PrivatesAccessor $privatesAccessor
) {
parent::__construct();
$this->configManager = $configManager;
$this->symfonyStyle = $symfonyStyle;
$this->privatesAccessor = $privatesAccessor;
}

protected function configure(): void
Expand All @@ -44,15 +49,18 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): void
{
$configPasses = (new PrivatesAccessor())->getPrivateProperty($this->configManager, 'configPasses');
$configPasses = $this->privatesAccessor->getPrivateProperty($this->configManager, 'configPasses');

$this->symfonyStyle->section('Active config passes');
$this->symfonyStyle->section('Active config passes in order of execution');

foreach ($configPasses as $configPass) {
$bareClass = Strings::after(get_class($configPass), '\\', -1);
$mainNamespace = Strings::before(get_class($configPass), '\\', 1);

$this->symfonyStyle->writeln(sprintf(' * %s (%s)', $bareClass, $mainNamespace));
$reflectionClass = new ReflectionClass($configPass);
$filePath = $reflectionClass->getFileName();

$this->symfonyStyle->writeln(sprintf(' * %s (%s) - %s', $bareClass, $mainNamespace, $filePath));
}

$this->symfonyStyle->newLine();
Expand Down
2 changes: 1 addition & 1 deletion projects/open-training/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ services:
OpenTraining\EasyAdmin\ConfigPass\ImagePropertyAutoconfigureConfigPass:
tags:
# after ViewConfigPass
- { name: 'easyadmin.config_pass', priority: 5 }
- { name: 'easyadmin.config_pass', priority: 2 }
Original file line number Diff line number Diff line change
@@ -1,50 +1,12 @@
parameters:
training_grid_fields:
- 'name'
- { property: 'image', type: 'image', base_path: '%image_uploads%' }
- 'perex'
- 'description'
- 'capacity'
- 'price'
- 'place'
- 'trainer'

trainer_grid_fields:
- 'name'
- { property: 'image', type: 'image', base_path: '%image_uploads%' }
- 'email'
- 'phone'
- 'website'
- 'bio'

place_grid_fields:
- 'name'
- { property: 'image', type: 'image', base_path: '%image_uploads%' }
- 'description'
- 'mapUrl'

easy_admin:
entities:
Training:
label: 'Školení'
class: 'OpenTraining\Training\Entity\Training'
list:
fields: "%training_grid_fields%"
show:
fields: "%training_grid_fields%"
form:
exclude_fields:
- 'trainingReferences'
# - 'imageUploadedAt'
# fields:
# - 'name'
# - { property: 'imageFile', type: 'file' }
# - 'perex'
# - 'description'
# - 'capacity'
# - 'price'
# - 'place'
# - 'trainer'
- 'trainingTerms'

TrainingTerm:
label: 'Termíny školení'
Expand All @@ -53,31 +15,13 @@ easy_admin:
Trainer:
label: 'Školitelé'
class: 'OpenTraining\Training\Entity\Trainer'
list:
fields: '%trainer_grid_fields%'
show:
fields: '%trainer_grid_fields%'
form:
fields:
- 'name'
- { property: 'imageFile', type: 'file' }
- 'email'
- 'phone'
- 'website'
- 'bio'
exclude_fields:
- 'trainings'

Place:
label: 'Školící místa'
class: 'OpenTraining\Training\Entity\Place'
list:
fields: '%place_grid_fields%'
show:
fields: '%place_grid_fields%'
form:
fields:
- 'name'
- { property: 'imageFile', type: 'file' }
- 'description'
- 'mapUrl'

Reference:
label: 'Zpětné vazby'
Expand Down
Binary file not shown.
Loading

0 comments on commit 93ac2a7

Please sign in to comment.