{"id":375,"date":"2025-05-28T07:02:48","date_gmt":"2025-05-28T07:02:48","guid":{"rendered":"https:\/\/docs.quantri.online\/?docs=developer-guide\/coding\/entrypoints"},"modified":"2025-07-07T02:37:29","modified_gmt":"2025-07-07T02:37:29","slug":"entrypoints","status":"publish","type":"docs","link":"https:\/\/docs.quantri.online\/?docs=developer-guide\/business-management\/entrypoints","title":{"rendered":"Entrypoints"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng entrypoint<br><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">L\u1eddi m\u1edf \u0111\u1ea7u<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Tr\u01b0\u1edbc \u0111\u00e2y, khi mu\u1ed1n t\u1ea1o entrypoint, ta s\u1ebd t\u1ea1o m\u1ed9t file x\u1eed l\u00fd v\u00e0 khai b\u00e1o \u0111\u01b0\u1eddng d\u1eabn trong entry point registry. \u0110i\u1ec1u n\u00e0y l\u00e0m m\u1ea5t nhi\u1ec1u thao t\u00e1c, ch\u01b0a k\u1ec3 n\u1ebfu x\u1eed l\u00fd ph\u1ee9c t\u1ea1p s\u1ebd d\u1eabn \u0111\u1ebfn code r\u01b0\u1eddm r\u00e0, kh\u00f4ng th\u1ec3 t\u00e1i s\u1eed d\u1ee5ng. Th\u00eam v\u00e0o \u0111\u00f3, m\u1ed7i entrypoint khai b\u00e1o l\u00e0 m\u1ed9t th\u1ebf gi\u1edbi ri\u00eang, kh\u00f4ng \u0111\u1ed3ng nh\u1ea5t c\u1ea5u tr\u00fac, ki\u1ec3u d\u1eef li\u1ec7u tr\u1ea3 v\u1ec1 d\u1eabn \u0111\u1ebfn kh\u00f3 ki\u1ec3m so\u00e1t, s\u1eeda l\u1ed7i.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br>Ch\u00ednh v\u00ec th\u1ebf, hai coder gi\u1ea5u t\u00ean \u0111\u00e3 n\u1ea3y ra \u00fd t\u01b0\u1edfng \u0111\u1ec3 t\u1ed1i \u01b0u h\u00f3a nh\u1eefng khuy\u1ebft \u0111i\u1ec3m tr\u00ean. M\u1ed9t ng\u01b0\u1eddi cho \u00fd t\u01b0\u1edfng x\u1eed l\u00fd entrypoint qua <strong>class<\/strong> v\u1edbi m\u1ee5c \u0111\u00edch d\u1ec5 ki\u1ec3m so\u00e1t, d\u1ec5 t\u00e1i s\u1eed d\u1ee5ng, d\u1ec5 b\u1ea3o tr\u00ec v\u00e0 n\u00e2ng c\u1ea5p. M\u1ed7i <strong>method<\/strong> \u0111\u00f3ng vai tr\u00f2 l\u00e0 m\u1ed9t <strong>action<\/strong>, <strong>parameters<\/strong> c\u1ee7a <strong>method<\/strong> \u0111\u00f3 s\u1ebd l\u00e0 <strong>body request<\/strong>. Ng\u01b0\u1eddi c\u00f2n l\u1ea1i ph\u1ee5 tr\u00e1ch gom t\u1ea5t c\u1ea3 c\u00e1c entrypoint v\u1ec1 m\u1ed9t entrypoint duy nh\u1ea5t. C\u1ea5u tr\u00fac ch\u00fang th\u00e0nh m\u1ed9t Entrypoint Factory (t\u00ecm hi\u1ec3u th\u00eam v\u1ec1 Design Patterns &#8211; Factory) \u0111\u1ec3 d\u1ec5 x\u1eed l\u00fd.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">V\u00e0 v\u00ec v\u1eady, n\u1ebfu c\u1ea7n d\u00f9ng \u0111\u1ebfn entrypoint \u0111\u1ec3 x\u1eed l\u00fd ajax, send HTTP request, c\u00e1c b\u1ea1n ch\u1ec9 c\u1ea7n l\u00e0m nh\u01b0 sau:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">T\u1ea1o entrypoint class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">V\u00e0o \u0111\u01b0\u1eddng d\u1eabn custom\/entrypoints\/entrypoints_class t\u1ea1o class v\u1edbi c\u00fa ph\u00e1p sau<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ep<mark style=\"background-color:#ffffff;color:#cf2e2e\" class=\"has-inline-color\">&lt;ClassName&gt;<\/mark>Class.php<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">N\u1ed9i dung b\u00ean trong class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-contrast-color\">&lt;?php\nclass ep<\/mark><mark style=\"background-color:#ffffff;color:#cf2e2e\" class=\"has-inline-color\">&lt;ClassName&gt;<\/mark><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-contrast-color\">Class extends epClass {\n    public function __construct($request) {\n        $this-&gt;request = $request;\n    }\n}<\/mark><\/code><\/pre>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><em>Trong \u0111\u00f3 thu\u1ed9c t\u00ednh request l\u00e0 gi\u00e1 tr\u1ecb body request khi send HTTP request<\/em><br><em>B\u1ea1n kh\u00f4ng c\u1ea7n ph\u1ea3i quan t\u00e2m gi\u00e1 tr\u1ecb n\u00e0y \u1edf \u0111\u00e2u. Coder gi\u1ea5u t\u00ean \u0111\u00e3 l\u00e0m cho b\u1ea1n<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">M\u1ed7i <strong>method<\/strong> trong <strong>class<\/strong> s\u1ebd l\u00e0 <strong>action<\/strong> b\u1ea1n mu\u1ed1n th\u1ef1c hi\u1ec7n v\u1edbi <strong>params<\/strong> t\u01b0\u01a1ng \u1ee9ng<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nclass ep<mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">&lt;ClassName&gt;<\/mark>Class extends epClass {\n    public function __construct($request) {\n        $this-&gt;request = $request;\n    }\n\n    public function <mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">&lt;methodName&gt;<\/mark>($<mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">&lt;param 1&gt;<\/mark>, $<mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">&lt;param 2&gt;<\/mark>) {\n        \/\/ Code here\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">T\u1ea5t c\u1ea3 method \u0111\u00f3ng vai tr\u00f2 l\u00e0 action \u0111\u1ec1u ph\u1ea3i tr\u1ea3 v\u1ec1 JSON string.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>L\u01b0u \u00fd: Ch\u1ed7 n\u00e0o m\u00e0u \u0111\u1ecf c\u00e1c b\u1ea1n t\u1ef1 \u0111i\u1ec1n nh\u00e9, m\u00e0u \u0111en copy paste l\u00e0 \u0111\u01b0\u1ee3c<\/strong><\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">V\u1eady l\u00e0 xong, t\u1edbi b\u01b0\u1edbc ti\u1ebfp theo.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Call \u0111\u1ebfn entrypoint<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Endpoint (URL)<\/td><td>index.php?entryPoint=epGeneral<\/td><\/tr><tr><td>Method<\/td><td>POST, GET<\/td><\/tr><tr><td>Body request (POST)<br>URL Params (GET)<\/td><td>class: <mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">&lt;ClassName&gt;<\/mark><br>method: <mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">&lt;methodName&gt;<\/mark><br>params: [<br><mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">&lt;param 1&gt;<\/mark> : value_1<br><mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">&lt;param 2&gt;<\/mark> : value_2<br>]<\/td><\/tr><tr><td>Content type<\/td><td>multipart\/form-data<br>application\/x-www-form-urlencoded<br>application\/json<\/td><\/tr><tr><td>Return<\/td><td>JSON string<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng entrypoint L\u1eddi m\u1edf \u0111\u1ea7u Tr\u01b0\u1edbc \u0111\u00e2y, khi mu\u1ed1n t\u1ea1o entrypoint, ta s\u1ebd t\u1ea1o m\u1ed9t file x\u1eed l\u00fd v\u00e0 khai b\u00e1o \u0111\u01b0\u1eddng d\u1eabn trong entry point registry. \u0110i\u1ec1u n\u00e0y l\u00e0m m\u1ea5t nhi\u1ec1u thao t\u00e1c, ch\u01b0a k\u1ec3 n\u1ebfu x\u1eed l\u00fd ph\u1ee9c t\u1ea1p s\u1ebd d\u1eabn \u0111\u1ebfn code r\u01b0\u1eddm r\u00e0, kh\u00f4ng th\u1ec3 t\u00e1i s\u1eed d\u1ee5ng. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":281,"menu_order":4,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-375","docs","type-docs","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/docs\/375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=375"}],"version-history":[{"count":4,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/docs\/375\/revisions"}],"predecessor-version":[{"id":382,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/docs\/375\/revisions\/382"}],"up":[{"embeddable":true,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=\/wp\/v2\/docs\/281"}],"wp:attachment":[{"href":"https:\/\/docs.quantri.online\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=375"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/docs.quantri.online\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}