Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions easy-coding-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ services:

# Spaces
Symplify\CodingStandard\Fixer\Strict\BlankLineAfterStrictTypesFixer: ~
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
spacing: one

# Comments
Symplify\CodingStandard\Fixer\Commenting\RemoveSuperfluousDocBlockWhitespaceFixer: ~
Expand Down Expand Up @@ -79,22 +81,23 @@ services:
PhpCsFixer\Fixer\FunctionNotation\PhpdocToReturnTypeFixer: ~
PhpCsFixer\Fixer\Import\FullyQualifiedStrictTypesFixer: ~
PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer:
property: single

#please yoda no
SlevomatCodingStandard\Sniffs\ControlStructures\DisallowYodaComparisonSniff: ~

parameters:
cache_directory: var/cache/ecs
skip:
PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer: ~
PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer: ~
PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer: ~
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer: ~
PhpCsFixer\Fixer\Operator\IncrementStyleFixer: ~
PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer: ~
PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer: ~
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff: ~
Symplify\CodingStandard\Sniffs\Debug\CommentedOutCodeSniff: ~ #to be removed before beta release
Symplify\CodingStandard\Sniffs\Debug\DebugFunctionCallSniff: ~ #to be removed before beta release

# Deprecated. Todo: Find replacement
Symplify\CodingStandard\Fixer\ControlStructure\RequireFollowedByAbsolutePathFixer: ~
Symplify\CodingStandard\Fixer\Property\ArrayPropertyDefaultValueFixer: ~
5 changes: 5 additions & 0 deletions src/Command/AddUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
if ($errors->count() > 0) {
throw new InvalidArgumentException($errors->get(0)->getMessage());
}

return $username;
});
$input->setArgument('username', $username);
Expand All @@ -152,6 +153,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
if ($errors->count() > 0) {
throw new InvalidArgumentException($errors->get(0)->getMessage());
}

return $password;
});

Expand All @@ -169,6 +171,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
if ($errors->count() > 0) {
throw new InvalidArgumentException($errors->get(0)->getMessage());
}

return $email;
});
$input->setArgument('email', $email);
Expand All @@ -184,6 +187,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
if ($errors->count() > 0) {
throw new InvalidArgumentException($errors->get(0)->getMessage());
}

return $displayName;
});
$input->setArgument('display-name', $displayName);
Expand Down Expand Up @@ -219,6 +223,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($errors as $error) {
$errorMessages[] = $error->getMessage();
}

throw new RuntimeException(implode(', ', $errorMessages));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Command/CopyAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (file_exists(dirname(dirname(dirname(__DIR__))) . '/assets')) {
$baseDir = dirname(dirname(dirname(__DIR__))) . '/assets';
$dirs = [
$baseDir . '/assets' => $publicDir .'/assets/',
$baseDir . '/assets' => $publicDir . '/assets/',
// $baseDir . '/translations' => $projectDir . '/translations/',
];
} else {
$baseDir = dirname(dirname(__DIR__));
$dirs = [
$baseDir . '/public/assets' => $publicDir .'/assets/',
$baseDir . '/public/assets' => $publicDir . '/assets/',
// $baseDir . '/translations' => $projectDir . '/translations/',
];
}
Expand Down
6 changes: 4 additions & 2 deletions src/Command/CopyThemesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (file_exists(dirname(dirname(dirname(__DIR__))) . '/themes')) {
$baseDir = dirname(dirname(dirname(__DIR__))) . '/themes';
$dirs = [
$baseDir . '/base-2018' => $publicDir .'/theme/base-2018',
$baseDir . '/skeleton' => $publicDir .'/theme/skeleton',
$baseDir . '/base-2018' => $publicDir . '/theme/base-2018',
$baseDir . '/skeleton' => $publicDir . '/theme/skeleton',
];
} else {
if (Version::installType() === 'Git clone') {
$io->error('This command only works with the \'Composer install\' install type.');

return 1;
}
$io->error('Run \'composer require bolt/themes\' before using this command.');

return 1;
}

Expand Down
1 change: 1 addition & 0 deletions src/Command/DeleteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
if ($errors->count() > 0) {
throw new InvalidArgumentException($errors->get(0)->getMessage());
}

return $username;
});
$input->setArgument('username', $username);
Expand Down
1 change: 1 addition & 0 deletions src/Command/ExtensionsShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int

if (! $extension instanceof ExtensionInterface) {
$io->caution('No such extension.');

return 0;
}

Expand Down
1 change: 1 addition & 0 deletions src/Command/ImageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function outputImage(SymfonyStyle $io): void
{
if (getenv('TERM_PROGRAM') !== 'iTerm.app') {
$io->title('⚙️ Bolt');

return;
}

Expand Down
1 change: 1 addition & 0 deletions src/Command/ResetSecretCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$io->success('Secret replaced successfully!');

return null;
}
}
4 changes: 4 additions & 0 deletions src/Configuration/Parser/ContentTypesParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,19 @@ protected function parseContentType($key, array $contentType): ?ContentType
// neither 'singular_name' nor 'singular_slug' is set.
if (! isset($contentType['name']) && ! isset($contentType['slug'])) {
$error = sprintf("In content type <code>%s</code>, neither 'name' nor 'slug' is set. Please edit <code>contenttypes.yml</code>, and correct this.", $key);

throw new ConfigurationException($error);
}
if (! isset($contentType['singular_name']) && ! isset($contentType['singular_slug'])) {
$error = sprintf("In content type <code>%s</code>, neither 'singular_name' nor 'singular_slug' is set. Please edit <code>contenttypes.yml</code>, and correct this.", $key);

throw new ConfigurationException($error);
}

// Content types without fields make no sense.
if (! isset($contentType['fields'])) {
$error = sprintf("In content type <code>%s</code>, no 'fields' are set. Please edit <code>contenttypes.yml</code>, and correct this.", $key);

throw new ConfigurationException($error);
}

Expand Down Expand Up @@ -155,6 +158,7 @@ protected function parseContentType($key, array $contentType): ?ContentType
$forbidden = array_diff((array) $contentType['locales'], $this->localeCodes);
if (! empty($this->localeCodes) && ! empty($forbidden)) {
$error = sprintf('The <code>%s</code> locale was requested, but permitted locales are <code>%s</code>. Please check your services.yaml app_locales setting.', implode(', ', $forbidden), implode(', ', $this->localeCodes));

throw new ConfigurationException($error);
}

Expand Down
1 change: 1 addition & 0 deletions src/Configuration/Parser/GeneralParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ protected function parseConnectionParams($params, ?Collection $defaults = null):
'servicename', 'service', 'pooled', 'instancename', 'server', // Oracle
'persistent', // SQL Anywhere
];

return $params->intersectByKeys($validKeys);
}

Expand Down
1 change: 1 addition & 0 deletions src/Configuration/PathResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function resolve(string $path, bool $absolute = true, $additional = null)
}

$this->resolving[$alias] = true;

try {
return $this->resolve($alias, $absolute);
} finally {
Expand Down
1 change: 1 addition & 0 deletions src/Controller/Backend/Async/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public function handleUpload(Request $request): JsonResponse
} catch (\Throwable $e) {
// something wrong happened, we don't need the uploaded files anymore
$result->clear();

throw $e;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/Backend/BulkOperationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function status(Request $request, string $status): Response

$this->addFlash('success', 'content.status_changed_successfully');
$url = $request->headers->get('referer');

return new RedirectResponse($url);
}

Expand All @@ -79,6 +80,7 @@ public function delete(Request $request): Response

$this->addFlash('success', 'content.deleted_successfully');
$url = $request->headers->get('referer');

return new RedirectResponse($url);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Controller/Backend/ContentEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public function status(Request $request, Content $content): Response
{
if (! $this->isCsrfTokenValid('status', $request->get('token'))) {
$url = $this->urlGenerator->generate('bolt_dashboard');

return new RedirectResponse($url);
}

Expand All @@ -253,6 +254,7 @@ public function delete(Request $request, Content $content): Response
{
if (! $this->isCsrfTokenValid('delete', $request->get('token'))) {
$url = $this->urlGenerator->generate('bolt_dashboard');

return new RedirectResponse($url);
}

Expand Down
4 changes: 1 addition & 3 deletions src/Controller/Backend/ExtensionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class ExtensionsController extends AbstractController implements BackendZoneInte
/** @var ExtensionRegistry */
private $extensionRegistry;

/**
* @var Dependencies
*/
/** @var Dependencies */
private $dependenciesManager;

public function __construct(ExtensionRegistry $extensionRegistry)
Expand Down
3 changes: 3 additions & 0 deletions src/Controller/Backend/FileEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public function handleDelete(Request $request): Response
}

$this->addFlash('success', 'file.delete_success');

return $this->redirectToRoute('bolt_filemanager', ['location' => $locationName]);
}

Expand Down Expand Up @@ -181,6 +182,7 @@ public function handleDuplicate(Request $request): Response
}

$this->addFlash('success', 'file.delete_success');

return $this->redirectToRoute('bolt_filemanager', ['location' => $locationName]);
}

Expand All @@ -205,6 +207,7 @@ private function getCopyFilepath(string $path): string
private function verifyYaml(string $yaml): bool
{
$yamlParser = new Parser();

try {
$yamlParser->parse($yaml);
} catch (ParseException $e) {
Expand Down
1 change: 1 addition & 0 deletions src/Controller/Backend/FilemanagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ private function buildIndex(string $base)
private function getFileSummary($contents)
{
$contents = str_replace(['<?php', '# ', "\n"], ['', '', " \n"], $contents);

return Excerpt::getExcerpt($contents, 300);
}
}
1 change: 1 addition & 0 deletions src/Controller/Backend/UserEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public function delete(?User $user, Request $request): Response

$url = $this->urlGenerator->generate('bolt_users');
$this->addFlash('success', 'user.updated_profile');

return new RedirectResponse($url);
}

Expand Down
1 change: 1 addition & 0 deletions src/Controller/TwigAwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ protected function renderTemplate($template, array $parameters = [], ?Response $
if ($element instanceof TemplateselectField) {
return $element->__toString();
}

return $element;
})
->filter()
Expand Down
2 changes: 1 addition & 1 deletion src/DataFixtures/BaseFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getRandomReference(string $entityName)
$this->referencesIndex[$entityName] = [];

foreach (array_keys($this->referenceRepository->getReferences()) as $key) {
if (mb_strpos($key, $entityName.'_') === 0) {
if (mb_strpos($key, $entityName . '_') === 0) {
$this->referencesIndex[$entityName][] = $key;
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/DataFixtures/ContentFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,15 @@ private function getValuesforFieldType(string $name, DeepCollection $field, bool
switch ($field['type']) {
case 'html':
$data = [FakeContent::generateHTML($nb)];

break;
case 'markdown':
$data = [FakeContent::generateMarkdown($nb)];

break;
case 'textarea':
$data = [$this->faker->paragraphs(3, true)];

break;
case 'image':
case 'file':
Expand All @@ -221,32 +224,40 @@ private function getValuesforFieldType(string $name, DeepCollection $field, bool
'alt' => $this->faker->sentence(4, true),
'media' => '',
];

break;
case 'slug':
$data = $this->lastTitle ?? [$this->faker->sentence(3, true)];

break;
case 'text':
$words = isset($field['slug']) && in_array($field['slug'], ['title', 'heading'], true) ? 3 : 7;
$data = [$this->faker->sentence($words, true)];

break;
case 'email':
$data = [$this->faker->email];

break;
case 'templateselect':
$data = [];

break;
case 'date':
case 'datetime':
$data = [$this->faker->dateTime()->format('c')];

break;
case 'number':
$data = [$this->faker->numberBetween(-100, 1000)];

break;
case 'data':
$data = [];
for ($i = 1; $i < 5; $i++) {
$data[$this->faker->sentence(1)] = $this->faker->sentence(4, true);
}

break;
case 'imagelist':
case 'filelist':
Expand All @@ -259,6 +270,7 @@ private function getValuesforFieldType(string $name, DeepCollection $field, bool
'media' => '',
];
}

break;
default:
$data = [$this->faker->sentence(6, true)];
Expand Down
4 changes: 2 additions & 2 deletions src/Doctrine/TablePrefix.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
|| $classMetadata->getName() === $classMetadata->rootEntityName) {
$classMetadata->setPrimaryTable(
[
'name' => $tablePrefix.$classMetadata->getTableName(),
'name' => $tablePrefix . $classMetadata->getTableName(),
]
);
}

foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && $mapping['isOwningSide']) {
$mappedTableName = $mapping['joinTable']['name'];
$classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $tablePrefix.$mappedTableName;
$classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $tablePrefix . $mappedTableName;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public function __toString(): string
if ($this->getId()) {
return sprintf('%s #%d', $contentName, $this->getId());
}

return sprintf('New %s', $contentName);
}

Expand Down Expand Up @@ -551,6 +552,7 @@ public function getAuthorName(): ?string
if ($this->getAuthor() !== null) {
return $this->getAuthor()->getDisplayName();
}

return null;
}

Expand Down
Loading