Merge branch 'dev' into prod

This commit is contained in:
2026-03-17 02:01:13 -07:00
5 changed files with 22 additions and 15 deletions

View File

@@ -14,7 +14,7 @@
} }
], ],
"require": { "require": {
"php": ">=8.1", "php": ">=8.2",
"cakephp/cakephp": "^5.0" "cakephp/cakephp": "^5.0"
}, },
"require-dev": { "require-dev": {

View File

@@ -8,3 +8,5 @@ parameters:
bootstrapFiles: bootstrapFiles:
- tests/bootstrap.php - tests/bootstrap.php
treatPhpDocTypesAsCertain: false treatPhpDocTypesAsCertain: false
ignoreErrors:
- identifier: trait.unused

View File

@@ -3,7 +3,7 @@ declare(strict_types=1);
namespace CheeseCake\Controller; namespace CheeseCake\Controller;
use App\Controller\AppController as BaseController; use Cake\Controller\Controller;
class AppController extends BaseController { class AppController extends Controller {
} }

View File

@@ -5,12 +5,15 @@ namespace CheeseCake\View\Helper;
use Cake\Routing\Router; use Cake\Routing\Router;
use Cake\View\Helper; use Cake\View\Helper;
use Cake\View\Helper\HtmlHelper;
/** /**
* ActiveLink helper * ActiveLink helper
*
* @property HtmlHelper $Html
*/ */
class ActiveLinkHelper extends Helper { class ActiveLinkHelper extends Helper {
/** /**
* Default configuration. * Default configuration.
* *
@@ -42,12 +45,12 @@ class ActiveLinkHelper extends Helper {
if (!array_key_exists('target', $options) || !$currentUrl) { if (!array_key_exists('target', $options) || !$currentUrl) {
return $this->Html->link($title, $url, $options); return $this->Html->link($title, $url, $options);
} }
$target = $options['target']; $target = $options['target'];
$activeClass = $options['activeClass'] ?? $this->getConfig('activeClass'); $activeClass = $options['activeClass'] ?? $this->getConfig('activeClass');
unset($options['target']);
unset($options['target']); unset($options['activeClass']);
unset($options['activeClass']);
if (is_string($target)) { if (is_string($target)) {
return $this->_linkFromStringTarget($currentUrl, $target, $title, $url, $activeClass, $options); return $this->_linkFromStringTarget($currentUrl, $target, $title, $url, $activeClass, $options);
} }
@@ -78,7 +81,7 @@ class ActiveLinkHelper extends Helper {
} }
$options['class'] = $this->_addClass($options, $activeClass); $options['class'] = $this->_addClass($options, $activeClass);
return $this->Html->link($title, $url, $options); return $this->Html->link($title, $url, $options);
} }
@@ -113,18 +116,20 @@ class ActiveLinkHelper extends Helper {
/** /**
* @param array $providedOptions * @param array $providedOptions
* @param string $toAdd
* *
* @return string * @return string
*/ */
protected function _addClass(array $providedOptions, string $toAdd): string { protected function _addClass(array $providedOptions, string $toAdd): string {
return array_key_exists('class', $providedOptions) ? $providedOptions['class'] . ' ' . $toAdd : $toAdd; return array_key_exists('class', $providedOptions) ? $providedOptions['class'] . ' ' . $toAdd : $toAdd;
} }
/** /**
* @param array $current * @param array $current
* @param string $targetString * @param string $targetString
* @param string $title * @param string $title
* @param array|string|null $url * @param array|string|null $url
* @param string $activeClass
* @param array $options * @param array $options
* *
* @return string * @return string
@@ -138,8 +143,8 @@ class ActiveLinkHelper extends Helper {
return $this->Html->link($title, $url, $options); return $this->Html->link($title, $url, $options);
} }
/** /**
* @param array $current * @param array $current
* @param array $targetUrl * @param array $targetUrl
* *

View File

@@ -108,7 +108,7 @@ class ActiveLinkHelperTest extends TestCase {
// matches specific controller action // matches specific controller action
$specificActionResult = $helper->link('goto', ['prefix' => 'Admin', 'controller' => 'Users', 'action' => 'index'], [ $specificActionResult = $helper->link('goto', ['prefix' => 'Admin', 'controller' => 'Users', 'action' => 'index'], [
'target' => ['controller' => 'Events', 'action' => 'index'], 'target' => ['controller' => 'Events', 'action' => 'index'],
'current' => ['prefix' => 'Admin', 'controller' => 'Users', 'action' => 'index'], 'current' => ['prefix' => 'Admin', 'controller' => 'Users', 'action' => 'index'],
'activeClass' => 'awesome-active-class', 'activeClass' => 'awesome-active-class',
'class' => 'link-class', 'class' => 'link-class',
]); ]);