17 'name' =>
true,
'httpMethod' =>
true,
'uri' =>
true,
'class' =>
true,
'responseClass' =>
true,
18 'responseType' =>
true,
'responseNotes' =>
true,
'notes' =>
true,
'summary' =>
true,
'documentationUrl' =>
true,
19 'deprecated' =>
true,
'data' =>
true,
'parameters' =>
true,
'additionalParameters' =>
true,
20 'errorResponses' =>
true
104 foreach (array_intersect_key($config, self::$properties) as $key => $value) {
105 $this->{$key} = $value;
108 $this->
class = $this->class ?: self::DEFAULT_COMMAND_CLASS;
109 $this->deprecated = (bool) $this->deprecated;
110 $this->errorResponses = $this->errorResponses ?: array();
111 $this->data = $this->data ?: array();
113 if (!$this->responseClass) {
114 $this->responseClass =
'array';
115 $this->responseType =
'primitive';
116 } elseif ($this->responseType) {
125 if ($this->parameters) {
126 foreach ($this->parameters as
$name => $param) {
127 if ($param instanceof Parameter) {
128 $param->setName(
$name)->setParent($this);
129 } elseif (is_array($param)) {
130 $param[
'name'] =
$name;
131 $this->
addParam(
new Parameter($param, $this->description));
136 if ($this->additionalParameters) {
137 if ($this->additionalParameters instanceof Parameter) {
138 $this->additionalParameters->setParent($this);
139 } elseif (is_array($this->additionalParameters)) {
140 $this->setadditionalParameters(
new Parameter($this->additionalParameters, $this->description));
149 foreach (array_keys(self::$properties) as $check) {
150 if ($value = $this->{$check}) {
151 $result[$check] = $value;
155 unset($result[
'name']);
157 $result[
'parameters'] = array();
158 foreach ($this->parameters as $key => $param) {
159 $result[
'parameters'][$key] = $param->toArray();
162 if ($this->additionalParameters instanceof Parameter) {
163 $result[
'additionalParameters'] = $this->additionalParameters->toArray();
188 return array_keys($this->parameters);
193 return isset($this->parameters[
$name]);
198 return isset($this->parameters[$param]) ? $this->parameters[$param] :
null;
208 public function addParam(Parameter $param)
210 $this->parameters[$param->getName()] = $param;
211 $param->setParent($this);
225 unset($this->parameters[
$name]);
261 public function setClass($className)
263 $this->
class = $className;
339 $this->documentationUrl = $docUrl;
380 static $types = array(
381 self::TYPE_PRIMITIVE =>
true,
382 self::TYPE_CLASS =>
true,
383 self::TYPE_MODEL =>
true,
384 self::TYPE_DOCUMENTATION =>
true
409 $this->responseNotes =
$notes;
428 $this->deprecated = $isDeprecated;
468 $this->errorResponses[] = array(
'code' => $code,
'reason' => $reason,
'class' =>
$class);
489 return isset($this->data[
$name]) ? $this->data[
$name] :
null;
502 $this->data[
$name] = $value;
526 if ($this->additionalParameters = $parameter) {
527 $this->additionalParameters->setParent($this);
538 static $primitives = array(
'array' => 1,
'boolean' => 1,
'string' => 1,
'integer' => 1,
'' => 1);
539 if (isset($primitives[$this->responseClass])) {
541 } elseif ($this->description && $this->description->hasModel($this->responseClass)) {