{"id":1165,"date":"2022-09-15T19:50:00","date_gmt":"2022-09-15T18:50:00","guid":{"rendered":"https:\/\/editjournal.redakt.eu\/faxmodem\/?p=1165"},"modified":"2023-03-01T08:46:21","modified_gmt":"2023-03-01T08:46:21","slug":"get-current-plugin-name","status":"publish","type":"post","link":"https:\/\/editjournal.redakt.eu\/faxmodem\/blog\/development\/cakephp\/get-current-plugin-name\/","title":{"rendered":"Get the current plugin name in CakePHP"},"content":{"rendered":"<p>If you need the current plugin name in e.g. <code>config\/routes.php<\/code> or <code>config\/bootstrap.php<\/code>, and don't want to hardcode it by hand, you can use <code>$this-&gt;getName()<\/code> instead. Example:<\/p>\n<pre><code>Router::plugin($this-&gt;getName(), function (RouteBuilder $routes) {\n    $routes-&gt;fallbacks(DashedRoute::class);\n});<\/code><\/pre>\n<p>The above is effectively the same as:<\/p>\n<pre><code>Router::plugin(&#039;MyPlugin&#039;, function (RouteBuilder $routes) {\n    $routes-&gt;fallbacks(DashedRoute::class);\n});<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you need the current plugin name in e.g. config\/routes.php or config\/bootstrap.php, and don&#8217;t want to hardcode it by hand, you can use $this-&gt;getName() instead. Example: Router::plugin($this-&gt;getName(), function (RouteBuilder $routes) { $routes-&gt;fallbacks(DashedRoute::class); }); The above is effectively the same as: Router::plugin(&#039;MyPlugin&#039;, function (RouteBuilder $routes) { $routes-&gt;fallbacks(DashedRoute::class); });<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1047],"tags":[715,1050],"class_list":["post-1165","post","type-post","status-publish","format-standard","hentry","category-cakephp","tag-cakephp","tag-cakephp-plugin-development","entry"],"_links":{"self":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/comments?post=1165"}],"version-history":[{"count":1,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1165\/revisions"}],"predecessor-version":[{"id":1167,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1165\/revisions\/1167"}],"wp:attachment":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/media?parent=1165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/categories?post=1165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/tags?post=1165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}