/** * @param \watoki\collections\Liste $formats * @throws HttpError If no renderer for accepted format and no default renderer is set * @return WebResponse */ private function respondWithDefault(Liste $formats) { if (!isset($this->renderers[''])) { throw new HttpError(WebResponse::STATUS_NOT_ACCEPTABLE, "Could not render the resource in an accepted format.", "Invalid accepted types: " . "[" . $formats->join(', ') . "] not supported by " . "[" . implode(', ', array_keys($this->renderers)) . "]"); } $response = new WebResponse(call_user_func($this->renderers[''])); if (!$formats->isEmpty()) { $response->getHeaders()->set(WebResponse::HEADER_CONTENT_TYPE, MimeTypes::getType($formats->first())); } return $response; }
/** * Rewinds all iterators * * @link http://php.net/manual/en/iterator.rewind.php * @return void Any returned value is ignored. */ public function rewind() { for ($this->index = 0; $this->index < $this->iterators->count(); $this->index++) { $this->getCurrentIterator()->rewind(); } $this->index = 0; $this->moveToNextValidIterator(); }
public function testArrayBlockWithListtAndMap() { $this->givenATemplate('Hello{{#myTag}} {{foo}}{{#isLast}}!{{/isLast}}{{/myTag}}'); $this->givenAViewObject(); $myTag = new Liste(); $myTag->append(new Map(array('foo' => 'Hi'))); $myTag->append(new Map(array('foo' => 'You', 'isLast' => true))); $this->givenTheViewObjectContainsTheProperty_WithValue('myTag', $myTag); $this->whenTheTemplateIsRenderedWithThisView(); $this->thenTheOutputShouldBe('Hello Hi You!'); }
/** * @param null $name * @return Liste|Element[] */ public function getChildElements($name = null) { $children = new Liste(); foreach ($this->children as $child) { if ($child instanceof Element && ($name === null || $child->getName() == $name)) { $children->append($child); } } return $children; }
/** * @return WebRequest */ protected function copy() { return new WebRequest($this->getContext(), $this->getTarget(), $this->getMethod(), $this->getArguments()->copy(), $this->formats->copy(), $this->headers->copy()); }
/** * @param $start * @param null $length * @param Liste $replacement * @return Liste */ public function splice($start, $length = null, Liste $replacement = null) { $retval = array_splice($this->elements, $start, $length, $replacement ? $replacement->toArray() : null); $this->clean(); return new Liste($retval); }