[ 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.Contact 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_contact. 23 * 24 * @since 4.0.0 25 */ 26 class PlgWebservicesContact 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_contact'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 $route = new Route( 48 ['POST'], 49 'v1/contacts/form/:id', 50 'contact.submitForm', 51 ['id' => '(\d+)'], 52 ['component' => 'com_contact'] 53 ); 54 55 $router->addRoute($route); 56 57 $router->createCRUDRoutes( 58 'v1/contacts', 59 'contact', 60 ['component' => 'com_contact'] 61 ); 62 63 $router->createCRUDRoutes( 64 'v1/contacts/categories', 65 'categories', 66 ['component' => 'com_categories', 'extension' => 'com_contact'] 67 ); 68 69 $this->createFieldsRoutes($router); 70 71 $this->createContentHistoryRoutes($router); 72 } 73 74 /** 75 * Create fields routes 76 * 77 * @param ApiRouter &$router The API Routing object 78 * 79 * @return void 80 * 81 * @since 4.0.0 82 */ 83 private function createFieldsRoutes(&$router) 84 { 85 $router->createCRUDRoutes( 86 'v1/fields/contacts/contact', 87 'fields', 88 ['component' => 'com_fields', 'context' => 'com_contact.contact'] 89 ); 90 91 $router->createCRUDRoutes( 92 'v1/fields/contacts/mail', 93 'fields', 94 ['component' => 'com_fields', 'context' => 'com_contact.mail'] 95 ); 96 97 $router->createCRUDRoutes( 98 'v1/fields/contacts/categories', 99 'fields', 100 ['component' => 'com_fields', 'context' => 'com_contact.categories'] 101 ); 102 103 $router->createCRUDRoutes( 104 'v1/fields/groups/contacts/contact', 105 'groups', 106 ['component' => 'com_fields', 'context' => 'com_contact.contact'] 107 ); 108 109 $router->createCRUDRoutes( 110 'v1/fields/groups/contacts/mail', 111 'groups', 112 ['component' => 'com_fields', 'context' => 'com_contact.mail'] 113 ); 114 115 $router->createCRUDRoutes( 116 'v1/fields/groups/contacts/categories', 117 'groups', 118 ['component' => 'com_fields', 'context' => 'com_contact.categories'] 119 ); 120 } 121 122 /** 123 * Create contenthistory routes 124 * 125 * @param ApiRouter &$router The API Routing object 126 * 127 * @return void 128 * 129 * @since 4.0.0 130 */ 131 private function createContentHistoryRoutes(&$router) 132 { 133 $defaults = [ 134 'component' => 'com_contenthistory', 135 'type_alias' => 'com_contact.contact', 136 'type_id' => 2, 137 ]; 138 $getDefaults = array_merge(['public' => false], $defaults); 139 140 $routes = [ 141 new Route(['GET'], 'v1/contacts/:id/contenthistory', 'history.displayList', ['id' => '(\d+)'], $getDefaults), 142 new Route(['PATCH'], 'v1/contacts/:id/contenthistory/keep', 'history.keep', ['id' => '(\d+)'], $defaults), 143 new Route(['DELETE'], 'v1/contacts/:id/contenthistory', 'history.delete', ['id' => '(\d+)'], $defaults), 144 ]; 145 146 $router->addRoutes($routes); 147 } 148 }
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 |