Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 89 changed files with 914 additions and 1,703 deletions.
14 changes: 0 additions & 14 deletions .travis/run-tests.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/skipped-components

This file was deleted.

61 changes: 0 additions & 61 deletions .travis/tested-components

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use Traversable;
use Zend\Stdlib\ArrayUtils;
use Zend\Http\PhpEnvironment\Response as PhpResponse;

/**
* @category Zend
Expand All @@ -31,14 +32,14 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AbstractCallbackInterface implements CallbackInterface
abstract class AbstractCallback implements CallbackInterface
{
/**
* An instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionPersistence used
* to background save any verification tokens associated with a subscription
* An instance of Zend\Feed\Pubsubhubbub\Model\SubscriptionPersistenceInterface
* used to background save any verification tokens associated with a subscription
* or other.
*
* @var \Zend\Feed\PubSubHubbub\Model\SubscriptionPersistenceInterface
* @var Model\SubscriptionPersistenceInterface
*/
protected $_storage = null;

Expand All @@ -47,7 +48,7 @@ abstract class AbstractCallbackInterface implements CallbackInterface
* Zend\Feed\Pubsubhubbub\HttpResponse which shares an unenforced interface with
* (i.e. not inherited from) Zend\Controller\Response\Http.
*
* @var httpResponse|\Zend\Controller\Response\Http
* @var HttpResponse|PhpResponse
*/
protected $_httpResponse = null;

Expand Down Expand Up @@ -76,7 +77,7 @@ public function __construct($options = null)
* Process any injected configuration options
*
* @param array|Traversable $options Options array or Traversable object
* @return AbstractCallbackInterface
* @return AbstractCallback
* @throws Exception\InvalidArgumentException
*/
public function setOptions($options)
Expand All @@ -86,7 +87,7 @@ public function setOptions($options)
}

if (!is_array($options)) {
throw new Exception('Array or Traversable object'
throw new Exception\InvalidArgumentException('Array or Traversable object'
. 'expected, got ' . gettype($options));
}

Expand All @@ -102,15 +103,15 @@ public function setOptions($options)

/**
* Send the response, including all headers.
* If you wish to handle this via Zend_Controller, use the getter methods
* If you wish to handle this via Zend_Http, use the getter methods
* to retrieve any data needed to be set on your HTTP Response object, or
* simply give this object the HTTP Response instance to work with for you!
*
* @return void
*/
public function sendResponse()
{
$this->getHttpResponse()->sendResponse();
$this->getHttpResponse()->send();
}

/**
Expand All @@ -119,7 +120,7 @@ public function sendResponse()
* or other.
*
* @param Model\SubscriptionPersistenceInterface $storage
* @return AbstractCallbackInterface
* @return AbstractCallback
*/
public function setStorage(Model\SubscriptionPersistenceInterface $storage)
{
Expand Down Expand Up @@ -149,19 +150,16 @@ public function getStorage()
* Zend\Feed\Pubsubhubbub\HttpResponse which shares an unenforced interface with
* (i.e. not inherited from) Zend\Controller\Response\Http.
*
* @param HttpResponse|\Zend\Controller\Response\Http $httpResponse
* @return AbstractCallbackInterface
* @param HttpResponse|PhpResponse $httpResponse
* @return AbstractCallback
* @throws Exception\InvalidArgumentException
*/
public function setHttpResponse($httpResponse)
{
if (!is_object($httpResponse)
|| (!$httpResponse instanceof HttpResponse
&& !$httpResponse instanceof \Zend\Controller\Response\Http)
) {
if (!$httpResponse instanceof HttpResponse && !$httpResponse instanceof PhpResponse) {
throw new Exception\InvalidArgumentException('HTTP Response object must'
. ' implement one of Zend\Feed\Pubsubhubbub\HttpResponse or'
. ' Zend\Controller\Response\Http');
. ' Zend\Http\PhpEnvironment\Response');
}
$this->_httpResponse = $httpResponse;
return $this;
Expand All @@ -172,7 +170,7 @@ public function setHttpResponse($httpResponse)
* Zend\Feed\Pubsubhubbub\HttpResponse which shares an unenforced interface with
* (i.e. not inherited from) Zend\Controller\Response\Http.
*
* @return HttpResponse|\Zend\Controller\Response\Http
* @return HttpResponse|PhpResponse
*/
public function getHttpResponse()
{
Expand All @@ -188,7 +186,7 @@ public function getHttpResponse()
* Defaults to 1 if left unchanged.
*
* @param string|int $count
* @return AbstractCallbackInterface
* @return AbstractCallback
* @throws Exception\InvalidArgumentException
*/
public function setSubscriberCount($count)
Expand All @@ -215,6 +213,7 @@ public function getSubscriberCount()

/**
* Attempt to detect the callback URL (specifically the path forward)
* @return string
*/
protected function _detectCallbackUrl()
{
Expand Down Expand Up @@ -269,6 +268,7 @@ protected function _getHttpHost()
* Retrieve a Header value from either $_SERVER or Apache
*
* @param string $header
* @return bool|string
*/
protected function _getHeader($header)
{
Expand Down
4 changes: 2 additions & 2 deletions src/PubSubHubbub/CallbackInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function sendResponse();
* Zend_Feed_Pubsubhubbub_HttpResponse which shares an unenforced interface with
* (i.e. not inherited from) Zend_Controller_Response_Http.
*
* @param Zend\Feed\PubSubHubbub\HttpResponse|\Zend\Controller\Response\Http $httpResponse
* @param HttpResponse|\Zend\Http\PhpEnvironment\Response $httpResponse
*/
public function setHttpResponse($httpResponse);

Expand All @@ -64,7 +64,7 @@ public function setHttpResponse($httpResponse);
* Zend_Feed_Pubsubhubbub_HttpResponse which shares an unenforced interface with
* (i.e. not inherited from) Zend_Controller_Response_Http.
*
* @return Zend\Feed\PubSubHubbub\HttpResponse|\Zend\Controller\Response\Http
* @return HttpResponse|\Zend\Http\PhpEnvironment\Response
*/
public function getHttpResponse();
}
34 changes: 17 additions & 17 deletions src/PubSubHubbub/HttpResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HttpResponse
*
* @var string
*/
protected $_body = '';
protected $content = '';

/**
* Array of headers. Each header is an array with keys 'name' and 'value'
Expand All @@ -47,17 +47,17 @@ class HttpResponse
*
* @var int
*/
protected $_httpResponseCode = 200;
protected $statusCode = 200;

/**
* Send the response, including all headers
*
* @return void
*/
public function sendResponse()
public function send()
{
$this->sendHeaders();
echo $this->getBody();
echo $this->getContent();
}

/**
Expand All @@ -70,22 +70,22 @@ public function sendResponse()
*/
public function sendHeaders()
{
if (count($this->_headers) || (200 != $this->_httpResponseCode)) {
if (count($this->_headers) || (200 != $this->statusCode)) {
$this->canSendHeaders(true);
} elseif (200 == $this->_httpResponseCode) {
} elseif (200 == $this->statusCode) {
return;
}
$httpCodeSent = false;
foreach ($this->_headers as $header) {
if (!$httpCodeSent && $this->_httpResponseCode) {
header($header['name'] . ': ' . $header['value'], $header['replace'], $this->_httpResponseCode);
if (!$httpCodeSent && $this->statusCode) {
header($header['name'] . ': ' . $header['value'], $header['replace'], $this->statusCode);
$httpCodeSent = true;
} else {
header($header['name'] . ': ' . $header['value'], $header['replace']);
}
}
if (!$httpCodeSent) {
header('HTTP/1.1 ' . $this->_httpResponseCode);
header('HTTP/1.1 ' . $this->statusCode);
$httpCodeSent = true;
}
}
Expand Down Expand Up @@ -170,13 +170,13 @@ public function canSendHeaders($throw = false)
* @return HttpResponse
* @throws Exception\InvalidArgumentException
*/
public function setHttpResponseCode($code)
public function setStatusCode($code)
{
if (!is_int($code) || (100 > $code) || (599 < $code)) {
throw new Exception\InvalidArgumentException('Invalid HTTP response'
. ' code:' . $code);
}
$this->_httpResponseCode = $code;
$this->statusCode = $code;
return $this;
}

Expand All @@ -185,9 +185,9 @@ public function setHttpResponseCode($code)
*
* @return int
*/
public function getHttpResponseCode()
public function getStatusCode()
{
return $this->_httpResponseCode;
return $this->statusCode;
}

/**
Expand All @@ -196,9 +196,9 @@ public function getHttpResponseCode()
* @param string $content
* @return \Zend\Feed\PubSubHubbub\HttpResponse
*/
public function setBody($content)
public function setContent($content)
{
$this->_body = (string) $content;
$this->content = (string) $content;
$this->setHeader('content-length', strlen($content));
return $this;
}
Expand All @@ -208,9 +208,9 @@ public function setBody($content)
*
* @return string
*/
public function getBody()
public function getContent()
{
return $this->_body;
return $this->content;
}

/**
Expand Down
20 changes: 9 additions & 11 deletions src/PubSubHubbub/Model/AbstractModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

namespace Zend\Feed\PubSubHubbub\Model;

use Zend\Db\TableGateway;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\TableGateway\TableGatewayInterface;

/**
* @category Zend
Expand All @@ -31,28 +32,25 @@
class AbstractModel
{
/**
* Zend_Db_Table instance to host database methods
* Zend\Db\TableGateway\TableGatewayInterface instance to host database methods
*
* @var TableGateway\TableGatewayInterface
* @var TableGatewayInterface
*/
protected $_db = null;

/**
* Constructor
*
* @param array $data
* @param TableGateway\TableGatewayInterface $tableGateway
* @return void
*
* @param null|TableGatewayInterface $tableGateway
*/
public function __construct(TableGateway\TableGatewayInterface $tableGateway = null)
public function __construct(TableGatewayInterface $tableGateway = null)
{
if ($tableGateway === null) {
$parts = explode('\\', get_called_class());
$table = strtolower(array_pop($parts));
$this->_db = new TableGateway\TableGateway($table);
$this->_db = new TableGateway($table, null);
} else {
$this->_db = $tableGateway;
}
}

}
Loading

0 comments on commit c2cd236

Please sign in to comment.