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
2 changes: 1 addition & 1 deletion src/Command/BootstrapCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
return $parser
->setDescription(
'The BootstrapUI console provides commands for installing dependencies ' .
'and samples, and for modifying your application to use BootstrapUI.'
'and samples, and for modifying your application to use BootstrapUI.',
);
}
}
4 changes: 2 additions & 2 deletions src/Command/CopyLayoutsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
{
return $parser
->setDescription(
'Copies the sample layouts into the application\'s layout templates folder.'
'Copies the sample layouts into the application\'s layout templates folder.',
)
->addArgument('target', [
'help' => sprintf(
'The target path into which to copy the layout files. Defaults to `%s`.',
$this->_getDefaultTargetPath()
$this->_getDefaultTargetPath(),
),
'required' => false,
]);
Expand Down
4 changes: 2 additions & 2 deletions src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected function _bufferPackageAssets(ConsoleIo $io): bool
preg_match(
"/{$DS}font{$DS}(?P<subdirs>.+{$DS})?.+\\.(css|woff|woff2)$/",
$file->getPathname(),
$matches
$matches,
)
) {
$assetPath = $fontPath;
Expand Down Expand Up @@ -376,7 +376,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
{
return $parser
->setDescription(
'Installs Bootstrap dependencies and links the assets to the application\'s webroot.'
'Installs Bootstrap dependencies and links the assets to the application\'s webroot.',
)
->addOption('latest', [
'help' => 'To install the latest minor versions of required assets.',
Expand Down
12 changes: 6 additions & 6 deletions src/Command/ModifyViewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ protected function _modifyView(string $filePath): bool
$content = str_replace(
'use Cake\\View\\View',
'use BootstrapUI\\View\\UIView',
$content
$content,
);
$content = str_replace(
'class AppView extends View',
'class AppView extends UIView',
$content
$content,
);
$content = str_replace(
" public function initialize(): void\n {\n",
" public function initialize(): void\n {\n parent::initialize();\n",
$content
$content,
);

return $this->_writeFile($filePath, $content);
Expand Down Expand Up @@ -122,17 +122,17 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
{
return $parser
->setDescription(
'Modifies `AppView.php` to extend this plugin\'s `UIView` class.'
'Modifies `AppView.php` to extend this plugin\'s `UIView` class.',
)
->addArgument('file', [
'help' => sprintf(
'The path of the `AppView.php` file. Defaults to `%s`.',
$this->_getDefaultFilePath()
$this->_getDefaultFilePath(),
),
'required' => false,
])
->setEpilog(
'<warning>Don\'t run this command if you have a already modified the `AppView` class!</warning>'
'<warning>Don\'t run this command if you have a already modified the `AppView` class!</warning>',
);
}
}
2 changes: 1 addition & 1 deletion src/View/Helper/BreadcrumbsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function _clearActiveCrumb(): void

unset(
$this->crumbs[$key]['options']['innerAttrs']['aria-current'],
$this->crumbs[$key]['options']['aria-current']
$this->crumbs[$key]['options']['aria-current'],
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/FlashHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function render(string $key = 'flash', array $options = []): ?string
if (!is_array($stack)) {
throw new UnexpectedValueException(sprintf(
'Value for flash setting key "%s" must be an array.',
$key
$key,
));
}

Expand Down
33 changes: 20 additions & 13 deletions src/View/Helper/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace BootstrapUI\View\Helper;

use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
Expand Down Expand Up @@ -214,6 +215,7 @@ class FormHelper extends CoreFormHelper
'{{hidden}}<label{{attrs}}>{{input}}{{text}}{{tooltip}}</label>',
'submitContainer' =>
'<div{{containerAttrs}} class="{{containerClass}}submit">{{content}}</div>',
'errorClass' => 'is-invalid',
];

/**
Expand Down Expand Up @@ -342,7 +344,7 @@ public function __construct(View $View, array $config = [])
{
$this->_defaultConfig = [
'align' => static::ALIGN_DEFAULT,
'errorClass' => 'is-invalid',
'errorClass' => version_compare(Configure::version(), '5.2.0', '<') ? 'is-invalid' : null,
'grid' => [
static::GRID_COLUMN_ONE => 2,
static::GRID_COLUMN_TWO => 10,
Expand Down Expand Up @@ -380,6 +382,11 @@ public function create(mixed $context = null, array $options = []): string
'spacing' => null,
];

// This is only for backwards compatibility with CakePHP < 5.2
if ($this->getConfig('errorClass')) {
$this->setConfig('templates.errorClass', $this->getConfig('errorClass'));
}

return parent::create($context, $this->_processFormOptions($options));
}

Expand Down Expand Up @@ -498,7 +505,7 @@ public function control(string $fieldName, array $options = []): string
isset($options['append']) ||
isset($options['prepend'])
) {
$options['injectErrorClass'] = $this->_config['errorClass'];
$options['injectErrorClass'] = $this->getConfig('templates.errorClass');
}

unset(
Expand All @@ -507,7 +514,7 @@ public function control(string $fieldName, array $options = []): string
$options['spacing'],
$options['inline'],
$options['nestedInput'],
$options['switch']
$options['switch'],
);

$result = parent::control($fieldName, $options);
Expand Down Expand Up @@ -542,7 +549,7 @@ protected function _spacingOptions(string $fieldName, array $options): array
$options['templates'] += [
'multicheckboxWrapper' => sprintf(
$this->templater()->getConfig('multicheckboxWrapper'),
$options['spacing']
$options['spacing'],
),
];
}
Expand Down Expand Up @@ -997,7 +1004,7 @@ protected function _tooltipOptions(string $fieldName, array $options): array
) {
$tooltip = $this->templater()->format(
'tooltip',
['content' => $options['tooltip']]
['content' => $options['tooltip']],
);
$options['label']['templateVars']['tooltip'] = ' ' . $tooltip;
}
Expand Down Expand Up @@ -1134,7 +1141,7 @@ public function staticControl(string $fieldName, array $options = []): string

$options = $this->_initInputField(
$fieldName,
['secure' => static::SECURE_SKIP] + $options
['secure' => static::SECURE_SKIP] + $options,
);

$content = $options['escape'] ? h($options['val']) : $options['val'];
Expand All @@ -1151,7 +1158,7 @@ public function staticControl(string $fieldName, array $options = []): string
$this->formProtector->addField(
$options['name'],
true,
(string)$options['val']
(string)$options['val'],
);
}

Expand Down Expand Up @@ -1246,7 +1253,7 @@ protected function _processFormOptions(array $options): array

if (!in_array($options['align'], static::ALIGN_TYPES)) {
throw new InvalidArgumentException(
'Invalid valid for `align` option. Valid values are: ' . implode(', ', static::ALIGN_TYPES)
'Invalid valid for `align` option. Valid values are: ' . implode(', ', static::ALIGN_TYPES),
);
}

Expand Down Expand Up @@ -1278,7 +1285,7 @@ protected function _processFormOptions(array $options): array
$this->_spacing,
'align-items-center',
],
$options
$options,
);
$options['templates'] += $templates;

Expand All @@ -1287,19 +1294,19 @@ protected function _processFormOptions(array $options): array

$templates['label'] = sprintf(
$templates['label'],
$this->_gridClass(static::GRID_COLUMN_ONE)
$this->_gridClass(static::GRID_COLUMN_ONE),
);
$templates['radioLabel'] = sprintf(
$templates['radioLabel'],
$this->_gridClass(static::GRID_COLUMN_ONE)
$this->_gridClass(static::GRID_COLUMN_ONE),
);
$templates['multicheckboxLabel'] = sprintf(
$templates['multicheckboxLabel'],
$this->_gridClass(static::GRID_COLUMN_ONE)
$this->_gridClass(static::GRID_COLUMN_ONE),
);
$templates['formGroup'] = sprintf(
$templates['formGroup'],
$this->_gridClass(static::GRID_COLUMN_TWO)
$this->_gridClass(static::GRID_COLUMN_TWO),
);

$offsetGridClass = implode(' ', [
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/HtmlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function icon(string $name, array $options = []): string
'tag' => $options['tag'],
'attrs' => $this->templater()->formatAttributes(
$options,
['tag', 'namespace', 'prefix', 'size']
['tag', 'namespace', 'prefix', 'size'],
),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/View/Widget/InputGroupTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function _processOptions(array $attachment, array $attrs): array

unset(
$attachment['options']['size'],
$attachment['options']['class']
$attachment['options']['class'],
);

$attrs += $attachment['options'];
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Command/BootstrapCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testEntry()
$this->assertOutputEmpty();
$this->assertEquals(
['<warning>No command provided. Run `bootstrap --help` to get a list of commands.</warning>'],
$this->_err->messages()
$this->_err->messages(),
);
}

Expand All @@ -40,7 +40,7 @@ public function testHelp()
'To get help on a specific command, type <info>`bootstrap command_name --help`</info>',
'',
],
$this->_out->messages()
$this->_out->messages(),
);
$this->assertErrorEmpty();
}
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Command/CopyLayoutsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testCopyLayouts()
'<info>Copying sample layouts...</info>',
"<success>Sample layouts copied successfully to `$targetPath`.</success>",
],
$this->_out->messages()
$this->_out->messages(),
);
$this->assertErrorEmpty();
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public function testCustomTargetPath()
'<info>Copying sample layouts...</info>',
"<success>Sample layouts copied successfully to `$compatTargetPath`.</success>",
],
$this->_out->messages()
$this->_out->messages(),
);
$this->assertErrorEmpty();
}
Expand Down Expand Up @@ -132,11 +132,11 @@ public function testFilesCannotBeCopied()
$this->assertEquals(Command::CODE_ERROR, $result);
$this->assertEquals(
['<info>Copying sample layouts...</info>'],
$out->messages()
$out->messages(),
);
$this->assertEquals(
["<error>Sample layouts could not be copied to `$targetPath`.</error>"],
$err->messages()
$err->messages(),
);
}

Expand Down Expand Up @@ -165,7 +165,7 @@ public function testHelp()
`$targetPath`.
<comment>(optional)</comment>
"],
$this->_out->messages()
$this->_out->messages(),
);
$this->assertErrorEmpty();
}
Expand Down
Loading