[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Plugin 5 * @subpackage Webservices.Content 6 * 7 * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 10 * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace 11 */ 12 13 use Joomla\CMS\Plugin\CMSPlugin; 14 use Joomla\CMS\Router\ApiRouter; 15 use Joomla\Router\Route; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Web Services adapter for com_content. 23 * 24 * @since 4.0.0 25 */ 26 class PlgWebservicesContent extends CMSPlugin 27 { 28 /** 29 * Load the language file on instantiation. 30 * 31 * @var boolean 32 * @since 4.0.0 33 */ 34 protected $autoloadLanguage = true; 35 36 /** 37 * Registers com_content's API's routes in the application 38 * 39 * @param ApiRouter &$router The API Routing object 40 * 41 * @return void 42 * 43 * @since 4.0.0 44 */ 45 public function onBeforeApiRoute(&$router) 46 { 47 $router->createCRUDRoutes( 48 'v1/content/articles', 49 'articles', 50 ['component' => 'com_content'] 51 ); 52 53 $router->createCRUDRoutes( 54 'v1/content/categories', 55 'categories', 56 ['component' => 'com_categories', 'extension' => 'com_content'] 57 ); 58 59 $this->createFieldsRoutes($router); 60 61 $this->createContentHistoryRoutes($router); 62 } 63 64 /** 65 * Create fields routes 66 * 67 * @param ApiRouter &$router The API Routing object 68 * 69 * @return void 70 * 71 * @since 4.0.0 72 */ 73 private function createFieldsRoutes(&$router) 74 { 75 $router->createCRUDRoutes( 76 'v1/fields/content/articles', 77 'fields', 78 ['component' => 'com_fields', 'context' => 'com_content.article'] 79 ); 80 81 $router->createCRUDRoutes( 82 'v1/fields/content/categories', 83 'fields', 84 ['component' => 'com_fields', 'context' => 'com_content.categories'] 85 ); 86 87 $router->createCRUDRoutes( 88 'v1/fields/groups/content/articles', 89 'groups', 90 ['component' => 'com_fields', 'context' => 'com_content.article'] 91 ); 92 93 $router->createCRUDRoutes( 94 'v1/fields/groups/content/categories', 95 'groups', 96 ['component' => 'com_fields', 'context' => 'com_content.categories'] 97 ); 98 } 99 100 /** 101 * Create contenthistory routes 102 * 103 * @param ApiRouter &$router The API Routing object 104 * 105 * @return void 106 * 107 * @since 4.0.0 108 */ 109 private function createContentHistoryRoutes(&$router) 110 { 111 $defaults = [ 112 'component' => 'com_contenthistory', 113 'type_alias' => 'com_content.article', 114 'type_id' => 1, 115 ]; 116 $getDefaults = array_merge(['public' => false], $defaults); 117 118 $routes = [ 119 new Route(['GET'], 'v1/content/articles/:id/contenthistory', 'history.displayList', ['id' => '(\d+)'], $getDefaults), 120 new Route(['PATCH'], 'v1/content/articles/:id/contenthistory/keep', 'history.keep', ['id' => '(\d+)'], $defaults), 121 new Route(['DELETE'], 'v1/content/articles/:id/contenthistory', 'history.delete', ['id' => '(\d+)'], $defaults), 122 ]; 123 124 $router->addRoutes($routes); 125 } 126 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |