From 69c271d471a0ed1953fe5f5d184ed19b49ea751c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Turek?= Date: Thu, 27 Apr 2017 15:47:54 +0200 Subject: [PATCH] Revert "Merge pull request #12611 from Wikia/IRIS-3983" This reverts commit bdc8e60d7eab97cede692c5c055d1e2c1b5c1c5d. --- .../wikia/Discussions/Discussions.setup.php | 27 +- .../Discussions/api/LegacyRedirect.class.php | 80 ----- .../SpecialForumRedirectController.class.php | 140 +------- extensions/wikia/Forum/Forum.setup.php | 4 +- includes/wikia/nirvana/WikiaApp.class.php | 44 +-- .../src/Discussion/Api/LegacyRedirectsApi.php | 315 ------------------ .../Models/LegacyRedirectResponse.php | 281 ---------------- 7 files changed, 26 insertions(+), 865 deletions(-) delete mode 100644 extensions/wikia/Discussions/api/LegacyRedirect.class.php delete mode 100644 lib/Swagger/src/Discussion/Api/LegacyRedirectsApi.php delete mode 100644 lib/Swagger/src/Discussion/Models/LegacyRedirectResponse.php diff --git a/extensions/wikia/Discussions/Discussions.setup.php b/extensions/wikia/Discussions/Discussions.setup.php index 2dec8faf95b3..4a71eaef2306 100644 --- a/extensions/wikia/Discussions/Discussions.setup.php +++ b/extensions/wikia/Discussions/Discussions.setup.php @@ -20,7 +20,6 @@ $wgAutoloadClasses['DiscussionsVarTogglerException'] = $dir . 'DiscussionsVarToggler.class.php'; $wgAutoloadClasses['ThreadCreator'] = $dir . 'api/ThreadCreator.class.php'; $wgAutoloadClasses['DiscussionsActivator'] = $dir . 'api/DiscussionsActivator.class.php'; -$wgAutoloadClasses['LegacyRedirect'] = $dir . 'api/LegacyRedirect.class.php'; $wgAutoloadClasses['StaffWelcomePoster'] = $dir . 'maintenance/StaffWelcomePoster.class.php'; // register special page @@ -30,25 +29,7 @@ // is enabled and Forums are disabled. if ( !empty( $wgEnableDiscussions ) && empty( $wgEnableForumExt ) ) { $wgAutoloadClasses['SpecialForumRedirectController'] = $dir . 'controllers/SpecialForumRedirectController.class.php'; - $wgHooks['ArticleViewHeader'][] = 'SpecialForumRedirectController::onArticleViewHeader'; - $wgHooks['BeforePageHistory'][] = 'SpecialForumRedirectController::onBeforePageHistory'; $wgSpecialPages['Forum'] = 'SpecialForumRedirectController'; - - // Make sure we recognize the Forum namespaces so we can redirect them if requested - $wgExtensionNamespacesFiles['Discussions'] = $dir . '../Forum/Forum.namespaces.php'; - wfLoadExtensionNamespaces( 'Forum', - [ - NS_WIKIA_FORUM_BOARD, - NS_WIKIA_FORUM_BOARD_THREAD, - NS_WIKIA_FORUM_TOPIC_BOARD - ] - ); - - $app->registerNamespaceController( - NS_WIKIA_FORUM_BOARD, - 'SpecialForumRedirectController', - 'redirectBoardToCategory' - ); } // message files @@ -67,13 +48,17 @@ $wgHooks['WikiaSkinTopScripts'][] = 'addDiscussionJsVariable'; /** + * MW1.19 - ResourceLoaderStartUpModule class adds more variables * @param array $vars JS variables to be added at the bottom of the page - * @param $scripts - * + * @param OutputPage $out * @return bool return true - it's a hook */ function addDiscussionJsVariable(Array &$vars, &$scripts) { + wfProfileIn(__METHOD__); + $vars['wgDiscussionsApiUrl'] = F::app()->wg->DiscussionsApiUrl; + + wfProfileOut(__METHOD__); return true; } diff --git a/extensions/wikia/Discussions/api/LegacyRedirect.class.php b/extensions/wikia/Discussions/api/LegacyRedirect.class.php deleted file mode 100644 index 1b73a2562d2f..000000000000 --- a/extensions/wikia/Discussions/api/LegacyRedirect.class.php +++ /dev/null @@ -1,80 +0,0 @@ -siteId = $siteId; - - $this->legacyRedirectApi = $this->getLegacyRedirectApi(); - $this->logger = Wikia\Logger\WikiaLogger::instance(); - } - - /** - * Return a path to redirect the client to based on a board ID - * - * @param int $boardId - * @return string - */ - public function getBoardRedirect( $boardId ) { - try { - $response = $this->legacyRedirectApi->getForumRedirect( $this->siteId, $boardId ); - return $response->getPath(); - } catch ( ApiException $e ) { - $this->logAndThrowError( $e ); - } - - return ''; - } - - /** - * Return a path to redirect the client to based on a thread ID - * - * @param int $threadId - * @return string - */ - public function getThreadRedirect( $threadId ) { - try { - $response = $this->legacyRedirectApi->getThreadRedirect( $this->siteId, $threadId ); - return $response->getPath(); - } catch ( ApiException $e ) { - $this->logAndThrowError( $e ); - } - - return ''; - } - - private function getLegacyRedirectApi() { - /** @var ApiProvider $apiProvider */ - $apiProvider = Injector::getInjector()->get( ApiProvider::class ); - /** @var LegacyRedirectsApi $api */ - $api = $apiProvider->getApi( self::SERVICE_NAME, LegacyRedirectsApi::class ); - $api->getApiClient()->getConfig()->setCurlTimeout( self::TIMEOUT ); - - return $api; - } - - private function logAndThrowError( Exception $e ) { - $this->logger->error( - 'DISCUSSIONS Retrieving legacy Forum redirect caused an error', - [ - 'siteId' => $this->siteId, - 'error' => $e->getMessage() - ] - ); - throw new ErrorPageError( 'unknown-error', 'discussions-activate-error' ); - } -} diff --git a/extensions/wikia/Discussions/controllers/SpecialForumRedirectController.class.php b/extensions/wikia/Discussions/controllers/SpecialForumRedirectController.class.php index 3e44ff899523..a76560b8c41e 100644 --- a/extensions/wikia/Discussions/controllers/SpecialForumRedirectController.class.php +++ b/extensions/wikia/Discussions/controllers/SpecialForumRedirectController.class.php @@ -4,147 +4,11 @@ class SpecialForumRedirectController extends WikiaSpecialPageController { const DISCUSSIONS_LINK = '/d/f'; - private $legacyRedirect; - public function __construct() { parent::__construct( 'Forum', '', false ); - - $this->legacyRedirect = new LegacyRedirect( F::App()->wg->CityId ); } public function index() { - $this->redirectForumToDiscussions(); - } - - /** - * Redirect requests for Special:Forum to discussions, e.g. from: - * - * http://garth.wikia.com/wiki/Special:Forum - * - * to: - * - * http://garth.wikia.com/d/f?sort=latest - */ - public function redirectForumToDiscussions() { - $discussionUrl = $this->getDiscussionUrl(); - $this->response->redirect( $discussionUrl ); - } - - /** - * Redirect requests for the board page to discussions, e.g, from: - * - * http://garth.wikia.com/wiki/Board:Some_Board_Name - * - * to: - * - * http://garth.wikia.com/d/f?catId=2016136434548737693 - * - * This is handled by registering a namespace controller (deprecated currently, but how wall - * works) e.g. this line in Discussions.setup.php: - * - * $app->registerNamespaceController( - * NS_WIKIA_FORUM_BOARD, - * 'SpecialForumRedirectController', - * 'redirectBoardToCategory', - * ); - * - */ - public function redirectBoardToCategory() { - // No template for this, we're only interested in setting the redirect. - $this->skipRendering(); - - $boardId = $this->getBoardId(); - $categoryUrl = $this->legacyRedirect->getBoardRedirect( $boardId ); - - $this->response->redirect( $categoryUrl ); - } - - /** - * Redirect requests for a thread to discussions, e.g. from: - * - * http://garth.garth.wikia-dev.us/wiki/Thread:2892 - * - * to: - * - * http://garth.wikia.com/d/p/2914856863801542335 - * - * @param Title $thread - */ - public static function redirectThreadToPost( Title $thread ) { - $threadId = $thread->getArticleID(); - - $legacyRedirect = new LegacyRedirect( F::App()->wg->CityId ); - $postUrl = $legacyRedirect->getThreadRedirect( $threadId ); - - F::app()->wg->Out->redirect( $postUrl ); - } - - private function getDiscussionUrl() { - return self::DISCUSSIONS_LINK; - } - - private function getBoardId() { - return $this->wg->Title->getArticleID(); - } - - /** - * @param Article $article - * - * @return bool - */ - public static function onBeforePageHistory( &$article ) { - self::redirectPage( $article ); - return true; - } - - /** - * @param Article $article - * @param bool $outputDone - * @param bool $useParserCache - * - * @return bool - */ - public static function onArticleViewHeader( &$article, &$outputDone, &$useParserCache ) { - self::redirectPage( $article ); - return true; - } - - private static function redirectPage( &$article ) { - $mainTitle = self::getMainTitle( $article ); - if ( empty( $mainTitle ) ) { - return; - } - - // Redirect to discussions - self::redirectThreadToPost( $mainTitle ); - } - - /** - * Some of this logic has been borrowed from WallHooksHelper::onArticleViewHeader - * - * @param Article $article - * @return null|Title - */ - private static function getMainTitle( Article $article ) { - $title = $article->getTitle(); - - if ( $title->getNamespace() != NS_USER_WALL_MESSAGE || $title->getText() <= 0 ) { - return null; - } - - $mainTitle = Title::newFromId( $title->getText() ); - - if ( empty( $mainTitle ) ) { - return null; - } - - $dbKey = $mainTitle->getDBkey(); - - $helper = new WallHelper(); - if ( !$helper->isDbkeyFromWall( $dbKey ) ) { - return null; - } - - return $mainTitle; + $this->response->redirect( self::DISCUSSIONS_LINK ); } -} +} \ No newline at end of file diff --git a/extensions/wikia/Forum/Forum.setup.php b/extensions/wikia/Forum/Forum.setup.php index e60593b18360..87a973ec2fc2 100644 --- a/extensions/wikia/Forum/Forum.setup.php +++ b/extensions/wikia/Forum/Forum.setup.php @@ -88,8 +88,8 @@ include ( $dir . '/Forum.namespace.setup.php' ); // add this namespace to list of wall namespaces -$app->registerNamespaceController( NS_WIKIA_FORUM_BOARD, 'ForumController', 'board', true ); -$app->registerNamespaceController( NS_WIKIA_FORUM_TOPIC_BOARD, 'ForumController', 'board', true ); +$app->registerNamespaceControler( NS_WIKIA_FORUM_BOARD, 'ForumController', 'board', true ); +$app->registerNamespaceControler( NS_WIKIA_FORUM_TOPIC_BOARD, 'ForumController', 'board', true ); JSMessages::registerPackage( 'Forum', [ 'back', diff --git a/includes/wikia/nirvana/WikiaApp.class.php b/includes/wikia/nirvana/WikiaApp.class.php index 9fbdbea861bf..1e4a8a36968c 100644 --- a/includes/wikia/nirvana/WikiaApp.class.php +++ b/includes/wikia/nirvana/WikiaApp.class.php @@ -84,10 +84,7 @@ class WikiaApp { * @param WikiaFunctionWrapper $functionWrapper */ - public function __construct(WikiaGlobalRegistry $globalRegistry = null, - WikiaLocalRegistry $localRegistry = null, - WikiaHookDispatcher $hookDispatcher = null, - WikiaFunctionWrapper $functionWrapper = null) { + public function __construct(WikiaGlobalRegistry $globalRegistry = null, WikiaLocalRegistry $localRegistry = null, WikiaHookDispatcher $hookDispatcher = null, WikiaFunctionWrapper $functionWrapper = null) { if(!is_object($globalRegistry)) { $globalRegistry = (new WikiaGlobalRegistry); @@ -392,27 +389,28 @@ public function registerHook( $hookName, $className, $methodName, Array $options } /** - * If the namespace is registered using registerNamespaceController $className, $methodName - * will be executed instead of regular article path. The title is passed as a request - * attribute, e.g.: + * registerNamespaceControler + * if the namespace is registered using registerNamespaceControler + * $className, $methodName will be exexuted instead of regular article path * - * $app->renderView( $className, $methodName, [ 'title' => $wgTitle ] ) + * title is passed as a request attribute. ($app->renderView($className, $methodName, array( 'title' => $wgTitle ) ) * * @param integer $namespace * @param string $className * @param string $methodName - * + * @param string $exists - Controler will be only executed if wgTitle exists * @deprecated */ - public function registerNamespaceController( $namespace, $className, $methodName ) { + public function registerNamespaceControler( $namespace, $className, $methodName, $exists ) { if(empty($this->namespaceRegistry)) { $this->registerHook( 'ArticleViewHeader', 'WikiaApp', 'onArticleViewHeader', array(), false, $this ); } $this->namespaceRegistry[$namespace] = array( 'className' => $className, - 'methodName' => $methodName + 'methodName' => $methodName, + 'exists' => $exists ); } @@ -435,7 +433,7 @@ public function registerApiController( $className, $path ) { * * onArticleViewHeader * - * This is a hook which serves the needs of registerNamespaceController + * This is a hook which serves the needs of registerNamespaceControler * * @param Article $article * @param bool $outputDone @@ -443,18 +441,12 @@ public function registerApiController( $className, $path ) { * @return bool */ - public function onArticleViewHeader( &$article, &$outputDone, &$useParserCache ) { + public function onArticleViewHeader(&$article, &$outputDone, &$useParserCache) { $title = $article->getTitle(); $namespace = $title->getNamespace(); - if ( !empty( $this->namespaceRegistry[$namespace] ) && $title->exists() ) { - $this->wg->Out->addHTML( - $this->renderView( - $this->namespaceRegistry[$namespace]['className'], - $this->namespaceRegistry[$namespace]['methodName'], - [ 'title' => $article->getTitle() ] - ) - ); + if( !empty($this->namespaceRegistry[$namespace]) && (empty($this->namespaceRegistry['exists']) || $title->exists()) ) { + $this->wg->Out->addHTML($this->renderView($this->namespaceRegistry[$namespace]['className'], $this->namespaceRegistry[$namespace]['methodName'], array( 'title' => $article->getTitle() ) )); $outputDone = true; } @@ -574,13 +566,10 @@ public function getGlobal( $globalVarName ) { /** * set global variable (alias: WikiaGlobalRegistry::set(var, value, key)) - * * @param string $globalVarName variable name * @param mixed $value value * @param string $key key (optional) - * - * @return WikiaGlobalRegistry - * + * @return WikiaApp * @deprecated */ public function setGlobal( $globalVarName, $value, $key = null ) { @@ -614,13 +603,12 @@ public function getGlobals() { * @param string $controllerName The name of the controller, without the 'Controller' or 'Model' suffix * @param string $methodName The name of the Controller method to call * @param array $params An array with the parameters to pass to the specified method - * @param bool $internal * @param int $exceptionMode exception mode * * @return WikiaResponse a response object with the data produced by the method call */ - public function sendRequest( $controllerName = null, $methodName = null, $params = array(), - $internal = true, $exceptionMode = null ) { + public function sendRequest( $controllerName = null, $methodName = null, $params = array(), $internal = true, + $exceptionMode = null ) { wfProfileIn(__METHOD__); $values = array(); diff --git a/lib/Swagger/src/Discussion/Api/LegacyRedirectsApi.php b/lib/Swagger/src/Discussion/Api/LegacyRedirectsApi.php deleted file mode 100644 index 76cc6adf79d5..000000000000 --- a/lib/Swagger/src/Discussion/Api/LegacyRedirectsApi.php +++ /dev/null @@ -1,315 +0,0 @@ -apiClient = $apiClient; - } - - /** - * Get API client - * - * @return \Swagger\Client\ApiClient get the API client - */ - public function getApiClient() - { - return $this->apiClient; - } - - /** - * Set the API client - * - * @param \Swagger\Client\ApiClient $apiClient set the API client - * - * @return LegacyRedirectsApi - */ - public function setApiClient(\Swagger\Client\ApiClient $apiClient) - { - $this->apiClient = $apiClient; - return $this; - } - - /** - * Operation getForumRedirect - * - * Legacy Board to Discussion Forum - * - * @param int $site_id The id of the site (required) - * @param int $board_id Legacy Forum board ID (required) - * @throws \Swagger\Client\ApiException on non-2xx response - * @return \Swagger\Client\Discussion\Models\LegacyRedirectResponse - */ - public function getForumRedirect($site_id, $board_id) - { - list($response) = $this->getForumRedirectWithHttpInfo($site_id, $board_id); - return $response; - } - - /** - * Operation getForumRedirectWithHttpInfo - * - * Legacy Board to Discussion Forum - * - * @param int $site_id The id of the site (required) - * @param int $board_id Legacy Forum board ID (required) - * @throws \Swagger\Client\ApiException on non-2xx response - * @return array of \Swagger\Client\Discussion\Models\LegacyRedirectResponse, HTTP status code, - * HTTP response headers (array of strings) - */ - public function getForumRedirectWithHttpInfo($site_id, $board_id) - { - // verify the required parameter 'site_id' is set - if ($site_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $site_id when calling getForumRedirect'); - } - // verify the required parameter 'board_id' is set - if ($board_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $board_id when calling getForumRedirect'); - } - // parse inputs - $resourcePath = "/{siteId}/redirect/board/{boardId}"; - $httpBody = ''; - $queryParams = []; - $headerParams = []; - $formParams = []; - $_header_accept = $this->apiClient->selectHeaderAccept(['application/hal+json']); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); - - // path params - if ($site_id !== null) { - $resourcePath = str_replace( - "{" . "siteId" . "}", - $this->apiClient->getSerializer()->toPathValue($site_id), - $resourcePath - ); - } - // path params - if ($board_id !== null) { - $resourcePath = str_replace( - "{" . "boardId" . "}", - $this->apiClient->getSerializer()->toPathValue($board_id), - $resourcePath - ); - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - $httpBody = $formParams; // for HTTP post (form) - } - // this endpoint requires API key authentication - $apiKey = $this->apiClient->getApiKeyWithPrefix('X-Wikia-AccessToken'); - if (strlen($apiKey) !== 0) { - $headerParams['X-Wikia-AccessToken'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->apiClient->getApiKeyWithPrefix('X-Wikia-UserId'); - if (strlen($apiKey) !== 0) { - $headerParams['X-Wikia-UserId'] = $apiKey; - } - // make the API Call - try { - list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( - $resourcePath, - 'GET', - $queryParams, - $httpBody, - $headerParams, - '\Swagger\Client\Discussion\Models\LegacyRedirectResponse', - '/{siteId}/redirect/board/{boardId}' - ); - - return [$this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Discussion\Models\LegacyRedirectResponse', $httpHeader), $statusCode, $httpHeader]; - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), - '\Swagger\Client\Discussion\Models\LegacyRedirectResponse', - $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\HalProblem', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - - throw $e; - } - } - - /** - * Operation getThreadRedirect - * - * Legacy Thread to Discussion Thread - * - * @param int $site_id The id of the site (required) - * @param int $thread_id Legacy Forum thread ID (required) - * @throws \Swagger\Client\ApiException on non-2xx response - * @return \Swagger\Client\Discussion\Models\LegacyRedirectResponse - */ - public function getThreadRedirect($site_id, $thread_id) - { - list($response) = $this->getThreadRedirectWithHttpInfo($site_id, $thread_id); - return $response; - } - - /** - * Operation getThreadRedirectWithHttpInfo - * - * Legacy Thread to Discussion Thread - * - * @param int $site_id The id of the site (required) - * @param int $thread_id Legacy Forum thread ID (required) - * @throws \Swagger\Client\ApiException on non-2xx response - * @return array of \Swagger\Client\Discussion\Models\LegacyRedirectResponse, HTTP status code, - * HTTP response headers (array of strings) - */ - public function getThreadRedirectWithHttpInfo($site_id, $thread_id) - { - // verify the required parameter 'site_id' is set - if ($site_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $site_id when calling getThreadRedirect'); - } - // verify the required parameter 'thread_id' is set - if ($thread_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $thread_id when calling getThreadRedirect'); - } - // parse inputs - $resourcePath = "/{siteId}/redirect/thread/{threadId}"; - $httpBody = ''; - $queryParams = []; - $headerParams = []; - $formParams = []; - $_header_accept = $this->apiClient->selectHeaderAccept(['application/hal+json']); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); - - // path params - if ($site_id !== null) { - $resourcePath = str_replace( - "{" . "siteId" . "}", - $this->apiClient->getSerializer()->toPathValue($site_id), - $resourcePath - ); - } - // path params - if ($thread_id !== null) { - $resourcePath = str_replace( - "{" . "threadId" . "}", - $this->apiClient->getSerializer()->toPathValue($thread_id), - $resourcePath - ); - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - $httpBody = $formParams; // for HTTP post (form) - } - // this endpoint requires API key authentication - $apiKey = $this->apiClient->getApiKeyWithPrefix('X-Wikia-AccessToken'); - if (strlen($apiKey) !== 0) { - $headerParams['X-Wikia-AccessToken'] = $apiKey; - } - // this endpoint requires API key authentication - $apiKey = $this->apiClient->getApiKeyWithPrefix('X-Wikia-UserId'); - if (strlen($apiKey) !== 0) { - $headerParams['X-Wikia-UserId'] = $apiKey; - } - // make the API Call - try { - list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( - $resourcePath, - 'GET', - $queryParams, - $httpBody, - $headerParams, - '\Swagger\Client\Discussion\Models\LegacyRedirectResponse', - '/{siteId}/redirect/thread/{threadId}' - ); - - return [$this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Discussion\Models\LegacyRedirectResponse', $httpHeader), $statusCode, $httpHeader]; - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), - '\Swagger\Client\Discussion\Models\LegacyRedirectResponse', - $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - case 404: - $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\HalProblem', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - - throw $e; - } - } -} diff --git a/lib/Swagger/src/Discussion/Models/LegacyRedirectResponse.php b/lib/Swagger/src/Discussion/Models/LegacyRedirectResponse.php deleted file mode 100644 index 8bbf0c2ab570..000000000000 --- a/lib/Swagger/src/Discussion/Models/LegacyRedirectResponse.php +++ /dev/null @@ -1,281 +0,0 @@ - 'int', - 'path' => 'string', - 'type' => 'string' - ]; - - public static function swaggerTypes() - { - return self::$swaggerTypes; - } - - /** - * Array of attributes where the key is the local name, and the value is the original name - * @var string[] - */ - protected static $attributeMap = [ - 'id' => 'id', - 'path' => 'path', - 'type' => 'type' - ]; - - - /** - * Array of attributes to setter functions (for deserialization of responses) - * @var string[] - */ - protected static $setters = [ - 'id' => 'setId', - 'path' => 'setPath', - 'type' => 'setType' - ]; - - - /** - * Array of attributes to getter functions (for serialization of requests) - * @var string[] - */ - protected static $getters = [ - 'id' => 'getId', - 'path' => 'getPath', - 'type' => 'getType' - ]; - - public static function attributeMap() - { - return self::$attributeMap; - } - - public static function setters() - { - return self::$setters; - } - - public static function getters() - { - return self::$getters; - } - - - - - - /** - * Associative array for storing property values - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * @param mixed[] $data Associated array of property values initializing the model - */ - public function __construct(array $data = null) - { - $this->container['id'] = isset($data['id']) ? $data['id'] : null; - $this->container['path'] = isset($data['path']) ? $data['path'] : null; - $this->container['type'] = isset($data['type']) ? $data['type'] : null; - } - - /** - * show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalid_properties = []; - - return $invalid_properties; - } - - /** - * validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - - return true; - } - - - /** - * Gets id - * @return int - */ - public function getId() - { - return $this->container['id']; - } - - /** - * Sets id - * @param int $id - * @return $this - */ - public function setId($id) - { - $this->container['id'] = $id; - - return $this; - } - - /** - * Gets path - * @return string - */ - public function getPath() - { - return $this->container['path']; - } - - /** - * Sets path - * @param string $path - * @return $this - */ - public function setPath($path) - { - $this->container['path'] = $path; - - return $this; - } - - /** - * Gets type - * @return string - */ - public function getType() - { - return $this->container['type']; - } - - /** - * Sets type - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->container['type'] = $type; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * @param integer $offset Offset - * @return boolean - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * @param integer $offset Offset - * @return mixed - */ - public function offsetGet($offset) - { - return isset($this->container[$offset]) ? $this->container[$offset] : null; - } - - /** - * Sets value based on offset. - * @param integer $offset Offset - * @param mixed $value Value to be set - * @return void - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * @param integer $offset Offset - * @return void - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } - - /** - * Gets the string presentation of the object - * @return string - */ - public function __toString() - { - if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } - - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); - } -} - -