Initial import of animal_management module
This commit is contained in:
51
components/UrlRule.php
Normal file
51
components/UrlRule.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace humhub\modules\animal_management\components;
|
||||
|
||||
use humhub\components\ContentContainerUrlRuleInterface;
|
||||
use humhub\modules\content\components\ContentContainerActiveRecord;
|
||||
use yii\base\Component;
|
||||
use yii\web\UrlManager;
|
||||
use yii\web\UrlRuleInterface;
|
||||
|
||||
class UrlRule extends Component implements UrlRuleInterface, ContentContainerUrlRuleInterface
|
||||
{
|
||||
public const CONTAINER_ROUTE = 'animal_management/animals/index';
|
||||
private const ROUTE_SEGMENT = 'animals';
|
||||
|
||||
public function parseContentContainerRequest(ContentContainerActiveRecord $container, UrlManager $manager, string $containerUrlPath, array $urlParams)
|
||||
{
|
||||
if ($containerUrlPath === self::ROUTE_SEGMENT) {
|
||||
return [self::CONTAINER_ROUTE, $urlParams];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createContentContainerUrl(UrlManager $manager, string $containerUrlPath, string $route, array $params)
|
||||
{
|
||||
if (ltrim($route, '/') !== self::CONTAINER_ROUTE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$url = $containerUrlPath . '/' . self::ROUTE_SEGMENT;
|
||||
if (!empty($params)) {
|
||||
$query = http_build_query($params);
|
||||
if ($query !== '') {
|
||||
$url .= '?' . $query;
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function createUrl($manager, $route, $params)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function parseRequest($manager, $request)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user