Esempio n. 1
0
 /**
  *This method sets the url string request parameters for this input string
  *
  *@param sting $value The new value to add to the parameters array
  *@param bool True|False Flag to indicated whether the additional value is to be prepended or appended
  *@return Object \UrlParser
  */
 public function setParameters($value = null, $appendParameter = true)
 {
     //check if the $urlComponentsArray has more than two element
     $this->parameters = count($this->urlComponentsArray) > 2 ? ArrayHelper::slice($this->urlComponentsArray, 2)->get() : array();
     //check if there is an additonal parameter to add to parameters array
     if ($value !== null) {
         //check if this parameter is to be prepended or appended
         if ($appendParameter === true) {
             //append
             $this->parameters[] = $value;
         } else {
             //prepend
             array_unshift($this->parameters, $value);
         }
     }
     //return this class instance
     return $this;
 }
Esempio n. 2
0
 /**
  *This method sets the value of the request parameter
  *
  *@param null
  *@return Object \RouteParser
  */
 public function setParameters()
 {
     //set the requestParamKeys
     $this->requestParamKeys = count($this->methodMetaDataArray) > 1 ? ArrayHelper::slice($this->methodMetaDataArray, 1)->get() : array();
     //check if the requestParamKeys contain values
     if (count($this->requestParamKeys) > 0) {
         //get the url parameter from the UrlParserObjectInstance
         $requestParamValues = $this->UrlParserObjectInstance->getParameters();
         //get the number of keys
         $requestParamKeysLen = count($this->requestParamKeys);
         //check if the keys are more than then values
         if ($requestParamKeysLen >= count($requestParamValues)) {
             //padd the $requestParamValues with null values
             $requestParamValues = array_pad($requestParamValues, $requestParamKeysLen, null);
             //combine the two arrays into one
             $requestParams = array_combine($this->requestParamKeys, $requestParamValues);
             //populate the Input Class data
             Input::setGet()->setPost()->setUrl($requestParams);
             //return this object instance
             return $this;
         } else {
             //split the array to only remain with the number defined inthe keys
             $requestParamValues = ArrayHelper::slice($requestParamValues, 0, $requestParamKeysLen)->get();
             //combine the two arrays into one
             $requestParams = array_combine($this->requestParamKeys, $requestParamValues);
             //populate the Input Class data
             Input::setGet()->setPost()->setUrl($requestParams);
             //return this object instance
             return $this;
         }
     } else {
         //populate the Input Class data
         Input::setUrl($this->UrlParserObjectInstance->getParameters())->setGet()->setPost();
         //return this object instance
         return $this;
     }
 }