Improved tag module and media virtual paths

This commit is contained in:
Dennis Eichhorn 2019-05-22 07:47:03 +02:00
parent b906b79e92
commit 598bd93f7e
4 changed files with 131 additions and 12 deletions

View File

@ -18,6 +18,18 @@
"name": "tag_color",
"type": "VARCHAR(8)",
"null": false
},
"tag_type": {
"name": "tag_type",
"type": "TINYINT(1)",
"null": false
},
"tag_created_by": {
"name": "tag_created_by",
"type": "INT",
"null": false,
"foreignTable": "account",
"foreignKey": "account_id"
}
}
}

View File

@ -49,7 +49,75 @@ class Tag implements ArrayableInterface, \JsonSerializable
* @var string
* @since 1.0.0
*/
private $color = '000000';
private $color = '00000000';
/**
* Creator.
*
* @var int
* @since 1.0.0
*/
protected $createdBy = 0;
/**
* Tag type.
*
* @var string
* @since 1.0.0
*/
private $type = TagType::SINGLE;
/**
* Get created by
*
* @return int|\phpOMS\Account\Account
*
* @since 1.0.0
*/
public function getCreatedBy()
{
return $this->createdBy;
}
/**
* Set created by
*
* @param mixed $id Created by
*
* @return void
*
* @since 1.0.0
*/
public function setCreatedBy($id) : void
{
$this->createdBy = $id;
}
/**
* Get type.
*
* @return int
*
* @since 1.0.0
*/
public function getType() : int
{
return $this->type;
}
/**
* Set type.
*
* @param int $type Tag type
*
* @return void
*
* @since 1.0.0
*/
public function setType(int $type = TagType::SINGLE) : void
{
$this->type = $type;
}
/**
* Get color

View File

@ -34,9 +34,25 @@ final class TagMapper extends DataMapperAbstract
* @since 1.0.0
*/
protected static $columns = [
'tag_id' => ['name' => 'tag_id', 'type' => 'int', 'internal' => 'id'],
'tag_title' => ['name' => 'tag_title', 'type' => 'string', 'internal' => 'title'],
'tag_color' => ['name' => 'tag_color', 'type' => 'string', 'internal' => 'color'],
'tag_id' => ['name' => 'tag_id', 'type' => 'int', 'internal' => 'id'],
'tag_title' => ['name' => 'tag_title', 'type' => 'string', 'internal' => 'title'],
'tag_color' => ['name' => 'tag_color', 'type' => 'string', 'internal' => 'color'],
'tag_type' => ['name' => 'tag_type', 'type' => 'int', 'internal' => 'type'],
'tag_color' => ['name' => 'tag_color', 'type' => 'string', 'internal' => 'color'],
'tag_created_by' => ['name' => 'tag_created_by', 'type' => 'int', 'internal' => 'createdBy'],
];
/**
* Belongs to.
*
* @var array<string, array<string, string>>
* @since 1.0.0
*/
protected static $belongsTo = [
'createdBy' => [
'mapper' => AccountMapper::class,
'src' => 'tag_created_by',
],
];
/**
@ -54,12 +70,4 @@ final class TagMapper extends DataMapperAbstract
* @since 1.0.0
*/
protected static $primaryField = 'tag_id';
/**
* Created at.
*
* @var string
* @since 1.0.0
*/
protected static $createdAt = 'tag_created_at';
}

31
Models/TagType.php Normal file
View File

@ -0,0 +1,31 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package Modules\Tag
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Tag\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Tag type enum.
*
* @package Modules\Tag
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
abstract class TagType extends Enum
{
public const SINGLE = 1;
public const SHARED = 2;
}