diff --git a/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/README.md b/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/README.md index f7aad01..7d9fda7 100644 --- a/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/README.md +++ b/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/README.md @@ -16,9 +16,12 @@ class Manager << (F,LightGreen) >> #RoyalBlue { # Items $items # Type $type # Handler $handler + # string $table + __construct(Item $item, Items $items, ...) + upload(string $guid, string $entity, ...) : void + delete(string $guid, string $entity, ...) : void + + table(string $table) : self + + getTable() : string # modelFileDetails(array $details, string $guid, ...) : object } @@ -58,6 +61,20 @@ note right of Manager::delete string $target end note +note right of Manager::table + Set the current active table + + since: 5.0.2 + return: self +end note + +note right of Manager::getTable + Get the current active table + + since: 5.0.2 + return: string +end note + note right of Manager::modelFileDetails model the file details to store in the file table diff --git a/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/code.php b/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/code.php index 479f41b..1a74e4d 100644 --- a/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/code.php +++ b/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/code.php @@ -66,6 +66,14 @@ final class Manager */ protected Handler $handler; + /** + * Table Name + * + * @var string + * @since 5.0.2 + */ + protected string $table = 'file'; + /** * Constructor. * @@ -120,7 +128,7 @@ final class Manager } // store file in the file table - $this->item->set( + $this->item->table($this->getTable())->set( $this->modelFileDetails($details, $guid, $entity, $target) ); } @@ -140,6 +148,32 @@ final class Manager } + /** + * Set the current active table + * + * @param string $table The table that should be active + * + * @return self + * @since 5.0.2 + */ + public function table(string $table): self + { + $this->table = $table; + + return $this; + } + + /** + * Get the current active table + * + * @return string + * @since 5.0.2 + */ + public function getTable(): string + { + return $this->table; + } + /** * model the file details to store in the file table * @@ -156,12 +190,12 @@ final class Manager return (object) [ 'name' => $details['name'], 'file_type' => $guid, - 'ext' => 'me', - 'size_kb' => 45, + 'ext' => $details['extension'] ?? 'error', + 'size_kb' => $details['size'] ?? 0, 'filepath' => $details['full_path'], 'entity_type' => $target, 'entity' => $entity, - 'guid' => $this->getGuid('file'), + 'guid' => $this->getGuid('guid'), ]; } } diff --git a/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/code.power b/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/code.power index 7dbcc49..270fa86 100644 --- a/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/code.power +++ b/src/67a5e0ca-0ff0-4979-9b41-da0b09988016/code.power @@ -37,6 +37,14 @@ */ protected Handler $handler; + /** + * Table Name + * + * @var string + * @since 5.0.2 + */ + protected string $table = 'file'; + /** * Constructor. * @@ -91,7 +99,7 @@ } // store file in the file table - $this->item->set( + $this->item->table($this->getTable())->set( $this->modelFileDetails($details, $guid, $entity, $target) ); } @@ -111,6 +119,32 @@ } + /** + * Set the current active table + * + * @param string $table The table that should be active + * + * @return self + * @since 5.0.2 + */ + public function table(string $table): self + { + $this->table = $table; + + return $this; + } + + /** + * Get the current active table + * + * @return string + * @since 5.0.2 + */ + public function getTable(): string + { + return $this->table; + } + /** * model the file details to store in the file table * @@ -127,11 +161,11 @@ return (object) [ 'name' => $details['name'], 'file_type' => $guid, - 'ext' => 'me', - 'size_kb' => 45, + 'ext' => $details['extension'] ?? 'error', + 'size_kb' => $details['size'] ?? 0, 'filepath' => $details['full_path'], 'entity_type' => $target, 'entity' => $entity, - 'guid' => $this->getGuid('file'), + 'guid' => $this->getGuid('guid'), ]; } \ No newline at end of file diff --git a/src/d7600b43-771a-4747-9f5d-952765721799/code.php b/src/d7600b43-771a-4747-9f5d-952765721799/code.php index 0cfb5c3..8ef7004 100644 --- a/src/d7600b43-771a-4747-9f5d-952765721799/code.php +++ b/src/d7600b43-771a-4747-9f5d-952765721799/code.php @@ -240,7 +240,7 @@ abstract class UploadHelper $upload_path = Path::clean($upload['full_path']); // Get file extension/format - $format = MimeHelper::extension($upload_path); + $upload['extension'] = $format = MimeHelper::extension($upload_path); // Legal file formats $legal = []; diff --git a/src/d7600b43-771a-4747-9f5d-952765721799/code.power b/src/d7600b43-771a-4747-9f5d-952765721799/code.power index 2e0115e..4076d81 100644 --- a/src/d7600b43-771a-4747-9f5d-952765721799/code.power +++ b/src/d7600b43-771a-4747-9f5d-952765721799/code.power @@ -211,7 +211,7 @@ $upload_path = Path::clean($upload['full_path']); // Get file extension/format - $format = MimeHelper::extension($upload_path); + $upload['extension'] = $format = MimeHelper::extension($upload_path); // Legal file formats $legal = [];