code quality improvements + add boolean in a ctive link helper to check if url is active without displaying link
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.1",
|
"php": ">=8.2",
|
||||||
"cakephp/cakephp": "^5.0"
|
"cakephp/cakephp": "^5.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|||||||
@@ -8,3 +8,5 @@ parameters:
|
|||||||
bootstrapFiles:
|
bootstrapFiles:
|
||||||
- tests/bootstrap.php
|
- tests/bootstrap.php
|
||||||
treatPhpDocTypesAsCertain: false
|
treatPhpDocTypesAsCertain: false
|
||||||
|
ignoreErrors:
|
||||||
|
- identifier: trait.unused
|
||||||
|
|||||||
@@ -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 {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ 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 {
|
||||||
|
|
||||||
@@ -42,9 +45,9 @@ 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']);
|
||||||
|
|
||||||
@@ -113,6 +116,7 @@ class ActiveLinkHelper extends Helper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $providedOptions
|
* @param array $providedOptions
|
||||||
|
* @param string $toAdd
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -125,6 +129,7 @@ class ActiveLinkHelper extends Helper {
|
|||||||
* @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
|
||||||
|
|||||||
Reference in New Issue
Block a user