コード例 #1
0
ファイル: MultiResponder.php プロジェクト: watoki/curir
 /**
  * @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
ファイル: MultiIterator.php プロジェクト: watoki/collections
 /**
  * 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
ファイル: RenderTest.php プロジェクト: watoki/stache
 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
ファイル: Liste.php プロジェクト: watoki/collections
 /**
  * @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);
 }