====== PostApplicationService ====== **Layer:** ''Service'' · **Source:** ''lib/service/PostApplicationService.php:23'' (lines 23–411) ---- class PostApplicationService Application service orchestrating post creation and update workflows. Contains the business logic extracted from PostController: filter definitions, image processing, protected-content encryption, PostService field assembly. The controller delegates here after validation and security checks. ======= Docblock Metadata ======= ^ Tag ^ Value ^ | ''@category'' | Service | | ''@author'' | M.Noermoehammad | | ''@license'' | MIT | | ''@version'' | 1.0 | | ''@since'' | Since Release 1.0 | ======= Inheritance ======= //No parent, interface or trait. This is a root type.// ======= Constants (0) ======= //None.// ======= Properties (1) ======= ^ Visibility ^ Type ^ Name ^ Default ^ Line ^ | ''private'' | ''(untyped)'' | ''$postService'' | | 29 | ======= Methods (10) ======= ^ Visibility ^ Method ^ Summary ^ Line ^ | public | ''__construct()'' | Constructor. | 36 | | public | ''createPost()'' | Create a new post. | 57 | | public | ''updatePost()'' | Update an existing post. | 122 | | private | ''getPostFilters()'' | Return filter definitions for new-post form. | 206 | | private | ''getPostUpdateFilters()'' | Return filter definitions for edit-post form. | 230 | | private | ''setPostServiceData()'' | Populate PostService fields for a new post. | 258 | | private | ''setProtectedPostContent()'' | Handle protected-post content re-encryption for updates. | 326 | | private | ''setPostHeadlines()'' | Set post headline flag (featured / not featured). | 362 | | private | ''resolvePostDate()'' | Resolve the post publication datetime in site timezone. | 381 | | private | ''normalizePostStatus()'' | Normalize a submitted post status against its publication datetime. | 397 | ======== __construct() ======== public function __construct(PostService $postService) //lines 36–39 (4)// Constructor. ^ Parameter ^ Type ^ Default ^ Description ^ | ''$postService'' | [[scriptlog:lib:service:postservice|''PostService'']] | //required// | //none// | ======== createPost() ======== public function createPost($file_location, $file_type, $file_name, $file_size, $file_extension, $new_filename, $user_level, ?array $filtered = null) //lines 57–101 (45)// Create a new post. Handles filter retrieval, distillation, image processing, PostService field population and the final addPost() call. ^ Parameter ^ Type ^ Default ^ Description ^ | ''$file_location'' | ''(untyped)'' | //required// | //none// | | ''$file_type'' | ''(untyped)'' | //required// | //none// | | ''$file_name'' | ''(untyped)'' | //required// | //none// | | ''$file_size'' | ''(untyped)'' | //required// | //none// | | ''$file_extension'' | ''(untyped)'' | //required// | //none// | | ''$new_filename'' | ''(untyped)'' | //required// | //none// | | ''$user_level'' | ''(untyped)'' | //required// | //none// | | ''$filtered'' | ''?array'' | ''null'' | Pre-distilled data; computed from $_POST when null | **Returns:** ''(none declared)'' — void ======== updatePost() ======== public function updatePost($id, $file_location, $file_type, $file_name, $file_size, $file_extension, $new_filename, $user_level, $oldMediaId = null, ?array $filtered = null) //lines 122–199 (78)// Update an existing post. Handles filter retrieval, distillation, image processing, protected-content re-encryption, PostService field population and the final modifyPost() call. ^ Parameter ^ Type ^ Default ^ Description ^ | ''$id'' | ''(untyped)'' | //required// | //none// | | ''$file_location'' | ''(untyped)'' | //required// | //none// | | ''$file_type'' | ''(untyped)'' | //required// | //none// | | ''$file_name'' | ''(untyped)'' | //required// | //none// | | ''$file_size'' | ''(untyped)'' | //required// | //none// | | ''$file_extension'' | ''(untyped)'' | //required// | //none// | | ''$new_filename'' | ''(untyped)'' | //required// | //none// | | ''$user_level'' | ''(untyped)'' | //required// | //none// | | ''$oldMediaId'' | ''(untyped)'' | ''null'' | //none// | | ''$filtered'' | ''?array'' | ''null'' | Pre-distilled data; computed from $_POST when null | **Returns:** ''(none declared)'' — void ======== getPostFilters() ======== private function getPostFilters() //lines 206–223 (18)// Return filter definitions for new-post form. //Takes no parameters.// **Returns:** ''(none declared)'' — array ======== getPostUpdateFilters() ======== private function getPostUpdateFilters() //lines 230–249 (20)// Return filter definitions for edit-post form. //Takes no parameters.// **Returns:** ''(none declared)'' — array ======== setPostServiceData() ======== private function setPostServiceData($filters, ?array $filtered = null) //lines 258–311 (54)// Populate PostService fields for a new post. ^ Parameter ^ Type ^ Default ^ Description ^ | ''$filters'' | ''(untyped)'' | //required// | //none// | | ''$filtered'' | ''?array'' | ''null'' | //none// | **Returns:** ''(none declared)'' — void ======== setProtectedPostContent() ======== private function setProtectedPostContent($id, $filters, ?array $filtered = null) //lines 326–353 (28)// Handle protected-post content re-encryption for updates. Three branches: 1. visibility=protected + new password → encrypt with new passphrase 2. visibility=protected + no password → re-encrypt with existing passphrase 3. visibility ≠ protected → store plain content ^ Parameter ^ Type ^ Default ^ Description ^ | ''$id'' | ''(untyped)'' | //required// | //none// | | ''$filters'' | ''(untyped)'' | //required// | //none// | | ''$filtered'' | ''?array'' | ''null'' | //none// | **Returns:** ''(none declared)'' — void ======== setPostHeadlines() ======== private function setPostHeadlines($filters, ?array $filtered = null) //lines 362–373 (12)// Set post headline flag (featured / not featured). ^ Parameter ^ Type ^ Default ^ Description ^ | ''$filters'' | ''(untyped)'' | //required// | //none// | | ''$filtered'' | ''?array'' | ''null'' | //none// | **Returns:** ''(none declared)'' — void ======== resolvePostDate() ======== private function resolvePostDate(array $filtered): string //lines 381–384 (4)// Resolve the post publication datetime in site timezone. ^ Parameter ^ Type ^ Default ^ Description ^ | ''$filtered'' | ''array'' | //required// | Distilled post request data | **Returns:** ''string'' — string Datetime 'Y-m-d H:i:s' ======== normalizePostStatus() ======== private function normalizePostStatus(string $status, string $date): string //lines 397–410 (14)// Normalize a submitted post status against its publication datetime. \- 'publish' + future date → 'scheduled' (auto-detect scheduling) \- 'scheduled' + past date → 'publish' (due immediately) \- anything else unchanged ^ Parameter ^ Type ^ Default ^ Description ^ | ''$status'' | ''string'' | //required// | Submitted post status | | ''$date'' | ''string'' | //required// | Publication datetime 'Y-m-d H:i:s' | **Returns:** ''string'' — string Normalized post status ======= Imports ======= ^ Alias ^ Fully-qualified name ^ | ''Sanitize'' | [[scriptlog:lib:core:sanitize|''Scriptlog\Core\Sanitize'']] | ---- //This page is generated from source by 'tools/gendoc'. Edits will be overwritten.//