예제 #1
0
 /**
  * @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;
 }
예제 #2
0
 /**
  * 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();
 }
예제 #3
0
 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!');
 }
예제 #4
0
파일: Element.php 프로젝트: watoki/dom
 /**
  * @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;
 }
예제 #5
0
파일: WebRequest.php 프로젝트: watoki/curir
 /**
  * @return WebRequest
  */
 protected function copy()
 {
     return new WebRequest($this->getContext(), $this->getTarget(), $this->getMethod(), $this->getArguments()->copy(), $this->formats->copy(), $this->headers->copy());
 }
예제 #6
0
 /**
  * @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);
 }