mirror of
https://github.com/Karaka-Management/oms-Script.git
synced 2026-01-11 12:28:41 +00:00
add virtual paths
This commit is contained in:
parent
469a06b0ff
commit
479fdc4a57
|
|
@ -44,6 +44,11 @@
|
|||
"type": "TEXT",
|
||||
"null": false
|
||||
},
|
||||
"helper_template_virtual": {
|
||||
"name": "helper_template_virtual",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"helper_template_media": {
|
||||
"name": "helper_template_media",
|
||||
"type": "INT",
|
||||
|
|
|
|||
|
|
@ -144,6 +144,14 @@ class Template implements \JsonSerializable
|
|||
*/
|
||||
private array $tags = [];
|
||||
|
||||
/**
|
||||
* Path for organizing.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $virtualPath = '/';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
|
@ -239,6 +247,32 @@ class Template implements \JsonSerializable
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getVirtualPath() : string
|
||||
{
|
||||
return $this->virtualPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the path if file
|
||||
*
|
||||
* @param string $path Path to file
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setVirtualPath(string $path)
|
||||
{
|
||||
$this->virtualPath = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set description
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use Modules\Media\Models\CollectionMapper;
|
|||
use Modules\Organization\Models\UnitMapper;
|
||||
use Modules\Tag\Models\TagMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\RelationType;
|
||||
|
||||
/**
|
||||
* Report mapper class.
|
||||
|
|
@ -46,6 +47,7 @@ final class TemplateMapper extends DataMapperAbstract
|
|||
'helper_template_desc' => ['name' => 'helper_template_desc', 'type' => 'string', 'internal' => 'description'],
|
||||
'helper_template_desc_raw' => ['name' => 'helper_template_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
|
||||
'helper_template_media' => ['name' => 'helper_template_media', 'type' => 'int', 'internal' => 'source'],
|
||||
'helper_template_virtual' => ['name' => 'helper_template_virtual', 'type' => 'string', 'internal' => 'virtualPath'],
|
||||
'helper_template_creator' => ['name' => 'helper_template_creator', 'type' => 'int', 'internal' => 'createdBy'],
|
||||
'helper_template_unit' => ['name' => 'helper_template_unit', 'type' => 'int', 'internal' => 'unit'],
|
||||
'helper_template_created' => ['name' => 'helper_template_created', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'],
|
||||
|
|
@ -125,4 +127,23 @@ final class TemplateMapper extends DataMapperAbstract
|
|||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'helper_template_id';
|
||||
|
||||
/**
|
||||
* Get editor doc based on virtual path.
|
||||
*
|
||||
* @param string $virtualPath Virtual path
|
||||
* @param int $account Account id
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getByVirtualPath(string $virtualPath = '/') : array
|
||||
{
|
||||
$depth = 3;
|
||||
$query = self::getQuery();
|
||||
$query->where(self::$table . '_' . $depth . '.helper_template_virtual', '=', $virtualPath);
|
||||
|
||||
return self::getAllByQuery($query, RelationType::ALL, $depth);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user