mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-04 18:29:40 +02:00
Add php-tmdb-api module
This commit is contained in:
parent
786c234d5f
commit
d5d84d6462
189 changed files with 20018 additions and 1 deletions
|
@ -101,7 +101,8 @@ Ampache includes some external modules that carry their own licensing.
|
||||||
* [Bootstrap] (http://getbootstrap.com): MIT
|
* [Bootstrap] (http://getbootstrap.com): MIT
|
||||||
* [jQuery Knob] (https://github.com/aterrien/jQuery-Knob): MIT
|
* [jQuery Knob] (https://github.com/aterrien/jQuery-Knob): MIT
|
||||||
* [jQuery File Upload] (https://github.com/blueimp/jQuery-File-Upload): MIT
|
* [jQuery File Upload] (https://github.com/blueimp/jQuery-File-Upload): MIT
|
||||||
* [jsTree] (http://www.jstree.com/): MIT
|
* [jsTree] (http://www.jstree.com): MIT
|
||||||
|
* [php-tmdb-api] (https://github.com/wtfzdotnet/php-tmdb-api) : MIT
|
||||||
|
|
||||||
|
|
||||||
Translations
|
Translations
|
||||||
|
|
169
modules/Tmdb/Api/AbstractApi.php
Normal file
169
modules/Tmdb/Api/AbstractApi.php
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
use Guzzle\Http\Message\Response;
|
||||||
|
use Tmdb\Client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AbstractApi
|
||||||
|
* @package Tmdb\Api
|
||||||
|
*/
|
||||||
|
abstract class AbstractApi
|
||||||
|
implements ApiInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The client
|
||||||
|
*
|
||||||
|
* @var Client
|
||||||
|
*/
|
||||||
|
protected $client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param Client $client
|
||||||
|
*/
|
||||||
|
public function __construct(Client $client)
|
||||||
|
{
|
||||||
|
$this->client = $client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a GET request
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function get($path, array $parameters = array(), $headers = array())
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Response $response
|
||||||
|
*/
|
||||||
|
$response = $this->client->getHttpClient()->get($path, $parameters, $headers);
|
||||||
|
return $response->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a HEAD request
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function head($path, array $parameters = array(), $headers = array())
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Response $response
|
||||||
|
*/
|
||||||
|
$response = $this->client->getHttpClient()->head($path, $parameters, $headers);
|
||||||
|
return $response->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a POST request
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
* @param null $postBody
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function post($path, $postBody = null, array $parameters = array(), $headers = array())
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Response $response
|
||||||
|
*/
|
||||||
|
$response = $this->client->getHttpClient()->post($path, $postBody, $parameters, $headers);
|
||||||
|
return $response->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a POST request but json_encode the post body in the request
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
* @param null $postBody
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function postJson($path, $postBody = null, array $parameters = array(), $headers = array())
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Response $response
|
||||||
|
*/
|
||||||
|
if (is_array($postBody)) {
|
||||||
|
$postBody = json_encode($postBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $this->client->getHttpClient()->postJson($path, $postBody, $parameters, $headers);
|
||||||
|
return $response->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a PUT request
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
* @param null $body
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function put($path, $body = null, array $parameters = array(), $headers = array())
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Response $response
|
||||||
|
*/
|
||||||
|
$response = $this->client->getHttpClient()->put($path, $body, $parameters, $headers);
|
||||||
|
return $response->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a DELETE request
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
* @param null $body
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function delete($path, $body = null, array $parameters = array(), $headers = array())
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Response $response
|
||||||
|
*/
|
||||||
|
$response = $this->client->getHttpClient()->delete($path, $body, $parameters, $headers);
|
||||||
|
return $response->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a PATCH request
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
* @param null $body
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function patch($path, $body = null, array $parameters = array(), $headers = array())
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Response $response
|
||||||
|
*/
|
||||||
|
$response = $this->client->getHttpClient()->patch($path, $body, $parameters, $headers);
|
||||||
|
return $response->json();
|
||||||
|
}
|
||||||
|
}
|
118
modules/Tmdb/Api/Account.php
Normal file
118
modules/Tmdb/Api/Account.php
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Account
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#account
|
||||||
|
*/
|
||||||
|
class Account
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the basic information for an account. You will need to have a valid session id.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getAccount(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('account', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the lists that you have created and marked as a favorite.
|
||||||
|
*
|
||||||
|
* @param integer $accountId
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getLists($accountId, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('account/' . $accountId . '/lists', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of favorite movies for an account.
|
||||||
|
*
|
||||||
|
* @param integer $accountId
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getFavoriteMovies($accountId, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('account/' . $accountId . '/favorite_movies', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add or remove a movie to an accounts favorite list.
|
||||||
|
*
|
||||||
|
* @param integer $accountId
|
||||||
|
* @param integer $movieId
|
||||||
|
* @param boolean $isFavorite
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function favorite($accountId, $movieId, $isFavorite = true)
|
||||||
|
{
|
||||||
|
return $this->postJson('account/' . $accountId . '/favorite', array(
|
||||||
|
'movie_id' => $movieId,
|
||||||
|
'favorite' => $isFavorite
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of rated movies (and associated rating) for an account.
|
||||||
|
*
|
||||||
|
* @param integer $accountId
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getRatedMovies($accountId, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('account/' . $accountId . '/rated_movies', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of movies on an accounts watchlist.
|
||||||
|
*
|
||||||
|
* @param integer $accountId
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getMovieWatchlist($accountId, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('account/' . $accountId . '/movie_watchlist', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add or remove a movie to an accounts watch list.
|
||||||
|
*
|
||||||
|
* @param integer $accountId
|
||||||
|
* @param integer $movieId
|
||||||
|
* @param boolean $isOnWatchlist
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function watchlist($accountId, $movieId, $isOnWatchlist = true)
|
||||||
|
{
|
||||||
|
return $this->postJson('account/' . $accountId . '/movie_watchlist', array(
|
||||||
|
'movie_id' => $movieId,
|
||||||
|
'movie_watchlist' => $isOnWatchlist
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
20
modules/Tmdb/Api/ApiInterface.php
Normal file
20
modules/Tmdb/Api/ApiInterface.php
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface ApiInterface
|
||||||
|
* @package Tmdb\Api
|
||||||
|
*/
|
||||||
|
interface ApiInterface {
|
||||||
|
}
|
93
modules/Tmdb/Api/Authentication.php
Normal file
93
modules/Tmdb/Api/Authentication.php
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
use Symfony\Component\Yaml\Exception\RuntimeException;
|
||||||
|
use Tmdb\Exception\UnauthorizedRequestTokenException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Authentication
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#authentication
|
||||||
|
*/
|
||||||
|
class Authentication
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
const REQUEST_TOKEN_URI = 'https://www.themoviedb.org/authenticate';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to generate a valid request token for user based authentication.
|
||||||
|
* A request token is required in order to request a session id.
|
||||||
|
*
|
||||||
|
* You can generate any number of request tokens but they will expire after 60 minutes.
|
||||||
|
* As soon as a valid session id has been created the token will be destroyed.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getNewToken()
|
||||||
|
{
|
||||||
|
return $this->get('authentication/token/new');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect the user to authenticate the request token
|
||||||
|
*
|
||||||
|
* @param $token
|
||||||
|
*/
|
||||||
|
public function authenticateRequestToken($token)
|
||||||
|
{
|
||||||
|
header(sprintf(
|
||||||
|
'Location: %s/%s',
|
||||||
|
self::REQUEST_TOKEN_URI,
|
||||||
|
$token
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to generate a session id for user based authentication.
|
||||||
|
* A session id is required in order to use any of the write methods.
|
||||||
|
*
|
||||||
|
* @param string $requestToken
|
||||||
|
* @throws UnauthorizedRequestTokenException
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getNewSession($requestToken)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->get('authentication/session/new', array('request_token' => $requestToken));
|
||||||
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
if ($e->getCode() == 401) {
|
||||||
|
throw new UnauthorizedRequestTokenException("The request token has not been validated yet.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to generate a guest session id.
|
||||||
|
*
|
||||||
|
* A guest session can be used to rate movies without having a registered TMDb user account.
|
||||||
|
* You should only generate a single guest session per user (or device)
|
||||||
|
* as you will be able to attach the ratings to a TMDb user account in the future.
|
||||||
|
*
|
||||||
|
* There is also IP limits in place so you should always make sure it's the end user doing the guest session actions.
|
||||||
|
*
|
||||||
|
* If a guest session is not used for the first time within 24 hours, it will be automatically discarded.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getNewGuestSession()
|
||||||
|
{
|
||||||
|
return $this->get('authentication/guest_session/new');
|
||||||
|
}
|
||||||
|
}
|
36
modules/Tmdb/Api/Certifications.php
Normal file
36
modules/Tmdb/Api/Certifications.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Certifications
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#certifications
|
||||||
|
*/
|
||||||
|
class Certifications
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the list of supported certifications for movies.
|
||||||
|
*
|
||||||
|
* These can be used in conjunction with the certification_country and certification.lte parameters when using discover.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getMovieList(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('certification/movie/list', $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
62
modules/Tmdb/Api/Changes.php
Normal file
62
modules/Tmdb/Api/Changes.php
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Changes
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* http://docs.themoviedb.apiary.io/#changes
|
||||||
|
*/
|
||||||
|
class Changes
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get a list of movie ids that have been edited.
|
||||||
|
*
|
||||||
|
* By default we show the last 24 hours and only 100 items per page.
|
||||||
|
* The maximum number of days that can be returned in a single request is 14.
|
||||||
|
*
|
||||||
|
* You can then use the movie changes API to get the actual data that has been changed.
|
||||||
|
*
|
||||||
|
* Please note that the change log system to support this was changed
|
||||||
|
* on October 5, 2012 and will only show movies that have been edited since.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getMovieChanges(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/changes', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of people ids that have been edited.
|
||||||
|
*
|
||||||
|
* By default we show the last 24 hours and only 100 items per page.
|
||||||
|
* The maximum number of days that can be returned in a single request is 14.
|
||||||
|
*
|
||||||
|
* You can then use the movie changes API to get the actual data that has been changed.
|
||||||
|
*
|
||||||
|
* Please note that the change log system to support this was changed
|
||||||
|
* on October 5, 2012 and will only show movies that have been edited since.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getPersonChanges(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('person/changes', $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
54
modules/Tmdb/Api/Collections.php
Normal file
54
modules/Tmdb/Api/Collections.php
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Collections
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#collections
|
||||||
|
*/
|
||||||
|
class Collections
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the basic collection information for a specific collection id.
|
||||||
|
*
|
||||||
|
* You can get the ID needed for this method by making a /movie/{id} request
|
||||||
|
* and paying attention to the belongs_to_collection hash.
|
||||||
|
*
|
||||||
|
* Movie parts are not sorted in any particular order.
|
||||||
|
* If you would like to sort them yourself you can use the provided release_date.
|
||||||
|
*
|
||||||
|
* @param $collection_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getCollection($collection_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('collection/' . $collection_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all of the images for a particular collection by collection id.
|
||||||
|
*
|
||||||
|
* @param $collection_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getImages($collection_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('collection/' . $collection_id . '/images', $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
48
modules/Tmdb/Api/Companies.php
Normal file
48
modules/Tmdb/Api/Companies.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Companies
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#companies
|
||||||
|
*/
|
||||||
|
class Companies
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* This method is used to retrieve all of the basic information about a company.
|
||||||
|
*
|
||||||
|
* @param $company_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getCompany($company_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('company/' . $company_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of movies associated with a particular company.
|
||||||
|
*
|
||||||
|
* @param integer $company_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getMovies($company_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('company/' . $company_id . '/movies', $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
48
modules/Tmdb/Api/Configuration.php
Normal file
48
modules/Tmdb/Api/Configuration.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Configuration
|
||||||
|
* @package Tmdb\Api
|
||||||
|
*
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#configuration
|
||||||
|
*/
|
||||||
|
class Configuration
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the system wide configuration information.
|
||||||
|
*
|
||||||
|
* Some elements of the API require some knowledge of this configuration data.
|
||||||
|
*
|
||||||
|
* The purpose of this is to try and keep the actual API responses as light as possible.
|
||||||
|
* It is recommended you store this data within your application and check for updates every so often.
|
||||||
|
*
|
||||||
|
* This method currently holds the data relevant to building image URLs as well as the change key map.
|
||||||
|
*
|
||||||
|
* To build an image URL, you will need 3 pieces of data.
|
||||||
|
* The base_url, size and file_path.
|
||||||
|
*
|
||||||
|
* Simply combine them all and you will have a fully qualified URL. Here’s an example URL:
|
||||||
|
*
|
||||||
|
* http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w500/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg
|
||||||
|
*
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getConfiguration(array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('configuration', array(), $headers);
|
||||||
|
}
|
||||||
|
}
|
42
modules/Tmdb/Api/Credits.php
Normal file
42
modules/Tmdb/Api/Credits.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Credits
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#credits
|
||||||
|
*/
|
||||||
|
class Credits
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the detailed information about a particular credit record. This is currently only supported with the new credit model found in TV.
|
||||||
|
* These ids can be found from any TV credit response as well as the tv_credits and combined_credits methods for people.
|
||||||
|
*
|
||||||
|
* The episodes object returns a list of episodes and are generally going to be guest stars.
|
||||||
|
* The season array will return a list of season numbers.
|
||||||
|
*
|
||||||
|
* Season credits are credits that were marked with the "add to every season" option in the editing interface
|
||||||
|
* and are assumed to be "season regulars".
|
||||||
|
*
|
||||||
|
* @param $credit_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getCredit($credit_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('credit/' . $credit_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
46
modules/Tmdb/Api/Discover.php
Normal file
46
modules/Tmdb/Api/Discover.php
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Discover
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#discover
|
||||||
|
*/
|
||||||
|
class Discover
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Discover movies by different types of data like average rating, number of votes, genres and certifications.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function discoverMovies(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('discover/movie', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discover TV shows by different types of data like average rating, number of votes, genres, the network they aired on and air dates.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function discoverTv(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('discover/tv', $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
45
modules/Tmdb/Api/Find.php
Normal file
45
modules/Tmdb/Api/Find.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Find
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#find
|
||||||
|
*/
|
||||||
|
class Find
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The find method makes it easy to search for objects in our database by an external id. For instance, an IMDB ID. This will search all objects (movies, TV shows and people) and return the results in a single response. TV season and TV episode searches will be supported shortly.
|
||||||
|
*
|
||||||
|
* The supported external sources for each object are as follows:
|
||||||
|
*
|
||||||
|
* Movies: imdb_id
|
||||||
|
* People: imdb_id, freebase_mid, freebase_id, tvrage_id
|
||||||
|
* TV Series: imdb_id, freebase_mid, freebase_id, tvdb_id, tvrage_id
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function find($id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get(
|
||||||
|
sprintf('find/%s', $id),
|
||||||
|
$parameters,
|
||||||
|
$headers
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
81
modules/Tmdb/Api/Genres.php
Normal file
81
modules/Tmdb/Api/Genres.php
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Genres
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#genres
|
||||||
|
*/
|
||||||
|
class Genres
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the list of genres, and return one by id
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getGenre($id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
$response = $this->getGenres($parameters, $headers);
|
||||||
|
|
||||||
|
if (array_key_exists('genres', $response)) {
|
||||||
|
return $this->extractGenreByIdFromResponse($id, $response['genres']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of genres.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getGenres(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('genre/list', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of movies for a particular genre by id. By default, only movies with 10 or more votes are included.
|
||||||
|
*
|
||||||
|
* @param $genre_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getMovies($genre_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('genre/' . $genre_id . '/movies', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param integer $id
|
||||||
|
* @param array $data
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
private function extractGenreByIdFromResponse($id, array $data = array())
|
||||||
|
{
|
||||||
|
foreach($data as $genre) {
|
||||||
|
if ($id == $genre['id'])
|
||||||
|
return $genre;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
34
modules/Tmdb/Api/Jobs.php
Normal file
34
modules/Tmdb/Api/Jobs.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Jobs
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#jobs
|
||||||
|
*/
|
||||||
|
class Jobs
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get a list of valid jobs.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getJobs(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('job/list', $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
48
modules/Tmdb/Api/Keywords.php
Normal file
48
modules/Tmdb/Api/Keywords.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Keywords
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#keywords
|
||||||
|
*/
|
||||||
|
class Keywords
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the basic information for a specific keyword id.
|
||||||
|
*
|
||||||
|
* @param int $keyword_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getKeyword($keyword_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('keyword/' . $keyword_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of movies for a particular keyword by id.
|
||||||
|
*
|
||||||
|
* @param int $keyword_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getMovies($keyword_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('keyword/' . $keyword_id . '/movies', $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
102
modules/Tmdb/Api/Lists.php
Normal file
102
modules/Tmdb/Api/Lists.php
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Lists
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#lists
|
||||||
|
*/
|
||||||
|
class Lists
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get a list by id.
|
||||||
|
*
|
||||||
|
* @param $list_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getList($list_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('list/' . $list_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method lets users create a new list. A valid session id is required.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $description
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function createList($name, $description, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->postJson('list', array('name' => $name, 'description' => $description), $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if a movie ID is already added to a list.
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @param int $movieId
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getItemStatus($id, $movieId, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get(
|
||||||
|
'list/' . $id . '/item_status',
|
||||||
|
array_merge($parameters, array('movie_id' => $movieId)),
|
||||||
|
$headers
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method lets users add new movies to a list that they created. A valid session id is required.
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @param string $mediaId
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function addMediaToList($id, $mediaId)
|
||||||
|
{
|
||||||
|
return $this->postJson('list/' . $id . '/add_item', array('media_id' => $mediaId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method lets users delete movies from a list that they created. A valid session id is required.
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @param string $mediaId
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function removeMediaFromList($id, $mediaId)
|
||||||
|
{
|
||||||
|
return $this->postJson('list/' . $id . '/remove_item', array('media_id' => $mediaId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method lets users delete a list that they created. A valid session id is required.
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function deleteList($id)
|
||||||
|
{
|
||||||
|
return $this->delete('list/' . $id);
|
||||||
|
}
|
||||||
|
}
|
262
modules/Tmdb/Api/Movies.php
Normal file
262
modules/Tmdb/Api/Movies.php
Normal file
|
@ -0,0 +1,262 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Movies
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#movies
|
||||||
|
*/
|
||||||
|
class Movies
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the basic movie information for a specific movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getMovie($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the alternative titles for a specific movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getAlternativeTitles($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/alternative_titles', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the cast and crew information for a specific movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getCredits($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/credits', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the images (posters and backdrops) for a specific movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getImages($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/images', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the plot keywords for a specific movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getKeywords($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/keywords', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the release date by country for a specific movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getReleases($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/releases', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the trailers for a specific movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTrailers($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/trailers', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the translations for a specific movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTranslations($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/translations', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the similar movies for a specific movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getSimilarMovies($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/similar_movies', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the reviews for a particular movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getReviews($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/reviews', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the lists that the movie belongs to.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getLists($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/lists', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the changes for a specific movie id.
|
||||||
|
*
|
||||||
|
* @param $movie_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getChanges($movie_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $movie_id . '/changes', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the latest movie id.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getLatest(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/latest', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of upcoming movies. This list refreshes every day. The maximum number of items this list will include is 100.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getUpcoming(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/upcoming', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of movies playing in theatres. This list refreshes every day. The maximum number of items this list will include is 100.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getNowPlaying(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/now_playing', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of popular movies on The Movie Database. This list refreshes every day.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getPopular(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/popular', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of top rated movies. By default, this list will only include movies that have 10 or more votes. This list refreshes every day.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTopRated(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('movie/top_rated', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method lets users get the status of whether or not the movie has been rated or added to their favourite or watch lists.
|
||||||
|
*
|
||||||
|
* A valid session id is required.
|
||||||
|
*
|
||||||
|
* @throws \Tmdb\Exception\NotImplementedException
|
||||||
|
*/
|
||||||
|
public function getAccountStates($id)
|
||||||
|
{
|
||||||
|
return $this->get('movie/' . $id . '/account_states');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TThis method lets users rate a movie.
|
||||||
|
*
|
||||||
|
* A valid session id or guest session id is required.
|
||||||
|
*
|
||||||
|
* @throws \Tmdb\Exception\NotImplementedException
|
||||||
|
*/
|
||||||
|
public function rateMovie($id, $rating)
|
||||||
|
{
|
||||||
|
return $this->postJson('movie/' . $id . '/rating', array('value' => (float) $rating));
|
||||||
|
}
|
||||||
|
}
|
38
modules/Tmdb/Api/Networks.php
Normal file
38
modules/Tmdb/Api/Networks.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Networks
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#networks
|
||||||
|
*/
|
||||||
|
class Networks
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* This method is used to retrieve the basic information about a TV network.
|
||||||
|
*
|
||||||
|
* You can use this ID to search for TV shows with the discover.
|
||||||
|
* At this time we don't have much but this will be fleshed out over time.
|
||||||
|
*
|
||||||
|
* @param int $network_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getNetwork($network_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('network/' . $network_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
160
modules/Tmdb/Api/People.php
Normal file
160
modules/Tmdb/Api/People.php
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class People
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#people
|
||||||
|
*/
|
||||||
|
class People
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the general person information for a specific id.
|
||||||
|
*
|
||||||
|
* @param $person_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getPerson($person_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('person/' . $person_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the credits for a specific person id.
|
||||||
|
*
|
||||||
|
* @param $person_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getCredits($person_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->getCombinedCredits($person_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the movie credits for a specific person id.
|
||||||
|
*
|
||||||
|
* @param $person_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getMovieCredits($person_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('person/' . $person_id . '/movie_credits', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the TV credits for a specific person id.
|
||||||
|
*
|
||||||
|
* To get the expanded details for each record, call the /credit method with the provided credit_id.
|
||||||
|
* This will provide details about which episode and/or season the credit is for.
|
||||||
|
*
|
||||||
|
* @param $person_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTvCredits($person_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('person/' . $person_id . '/tv_credits', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the combined (movie and TV) credits for a specific person id.
|
||||||
|
*
|
||||||
|
* To get the expanded details for each TV record, call the /credit method with the provided credit_id.
|
||||||
|
* This will provide details about which episode and/or season the credit is for.
|
||||||
|
*
|
||||||
|
* @param $person_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getCombinedCredits($person_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('person/' . $person_id . '/combined_credits', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the images for a specific person id.
|
||||||
|
*
|
||||||
|
* @param $person_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getImages($person_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('person/' . $person_id . '/images', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the changes for a specific person id.
|
||||||
|
*
|
||||||
|
* Changes are grouped by key, and ordered by date in descending order.
|
||||||
|
*
|
||||||
|
* By default, only the last 24 hours of changes are returned.
|
||||||
|
* The maximum number of days that can be returned in a single request is 14.
|
||||||
|
* The language is present on fields that are translatable.
|
||||||
|
*
|
||||||
|
* @param $person_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getChanges($person_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('person/' . $person_id . '/changes', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the external ids for a specific person id.
|
||||||
|
*
|
||||||
|
* @param $person_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getExternalIds($person_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('person/' . $person_id . '/external_ids', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of popular people on The Movie Database. This list refreshes every day.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getPopular(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('person/popular', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the latest person id.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getLatest()
|
||||||
|
{
|
||||||
|
return $this->get('person/latest');
|
||||||
|
}
|
||||||
|
}
|
35
modules/Tmdb/Api/Reviews.php
Normal file
35
modules/Tmdb/Api/Reviews.php
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Reviews
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#reviews
|
||||||
|
*/
|
||||||
|
class Reviews
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the full details of a review by ID.
|
||||||
|
*
|
||||||
|
* @param $review_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getReview($review_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('review/' . $review_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
127
modules/Tmdb/Api/Search.php
Normal file
127
modules/Tmdb/Api/Search.php
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Search
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#search
|
||||||
|
*/
|
||||||
|
class Search
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Search for movies by title.
|
||||||
|
*
|
||||||
|
* @param $query
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function searchMovies($query, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('search/movie', array_merge($parameters, array(
|
||||||
|
'query' => urlencode($query)
|
||||||
|
), $headers));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for collections by name.
|
||||||
|
*
|
||||||
|
* @param $query
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function searchCollection($query, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('search/collection', array_merge($parameters, array(
|
||||||
|
'query' => urlencode($query)
|
||||||
|
), $headers));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for TV shows by title.
|
||||||
|
*
|
||||||
|
* @param $query
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function searchTv($query, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('search/tv', array_merge($parameters, array(
|
||||||
|
'query' => urlencode($query)
|
||||||
|
), $headers));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for people by name.
|
||||||
|
*
|
||||||
|
* @param $query
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function searchPersons($query, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('search/person', array_merge($parameters, array(
|
||||||
|
'query' => urlencode($query)
|
||||||
|
), $headers));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for lists by name and description.
|
||||||
|
*
|
||||||
|
* @param $query
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function searchList($query, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('search/list', array_merge($parameters, array(
|
||||||
|
'query' => urlencode($query)
|
||||||
|
), $headers));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for companies by name.
|
||||||
|
*
|
||||||
|
* @param $query
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function searchCompany($query, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('search/company', array_merge($parameters, array(
|
||||||
|
'query' => urlencode($query)
|
||||||
|
), $headers));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for companies by name.
|
||||||
|
*
|
||||||
|
* @param $query
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function searchKeyword($query, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('search/keyword', array_merge($parameters, array(
|
||||||
|
'query' => urlencode($query)
|
||||||
|
), $headers));
|
||||||
|
}
|
||||||
|
}
|
118
modules/Tmdb/Api/Tv.php
Normal file
118
modules/Tmdb/Api/Tv.php
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Tv
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#tv
|
||||||
|
*/
|
||||||
|
class Tv
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the primary information about a TV series by id.
|
||||||
|
*
|
||||||
|
* @param integer $tvshow_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTvshow($tvshow_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('tv/' . $tvshow_id, $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the cast & crew information about a TV series.
|
||||||
|
* Just like the website, we pull this information from the last season of the series.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getCredits($tvshow_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('tv/' . $tvshow_id . '/credits', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the external ids that we have stored for a TV series.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getExternalIds($tvshow_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('tv/' . $tvshow_id . '/external_ids', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the images (posters and backdrops) for a TV series.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getImages($tvshow_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('tv/' . $tvshow_id . '/images', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of popular TV shows. This list refreshes every day.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getPopular(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('tv/popular', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of top rated TV shows.
|
||||||
|
*
|
||||||
|
* By default, this list will only include TV shows that have 2 or more votes.
|
||||||
|
* This list refreshes every day.
|
||||||
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTopRated(array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get('tv/top_rated', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of translations that exist for a TV series.
|
||||||
|
*
|
||||||
|
* These translations cascade down to the episode level.
|
||||||
|
*
|
||||||
|
* @param int $tvshow_id
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTranslations($tvshow_id, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
$this->get('tv/' . $tvshow_id . '/translations', $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
82
modules/Tmdb/Api/TvEpisode.php
Normal file
82
modules/Tmdb/Api/TvEpisode.php
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TvEpisode
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#tvepisodes
|
||||||
|
*/
|
||||||
|
class TvEpisode
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the primary information about a TV episode by combination of a season and episode number.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param $season_number
|
||||||
|
* @param $episode_number
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getEpisode($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get(sprintf('tv/%s/season/%s/episode/%s', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the TV episode credits by combination of season and episode number.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param $season_number
|
||||||
|
* @param $episode_number
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getCredits($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get(sprintf('tv/%s/season/%s/episode/%s/credits', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the external ids for a TV episode by comabination of a season and episode number.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param $season_number
|
||||||
|
* @param $episode_number
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getExternalIds($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get(sprintf('tv/%s/season/%s/episode/%s/external_ids', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the images (episode stills) for a TV episode by combination of a season and episode number.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param $season_number
|
||||||
|
* @param $episode_number
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getImages($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get(sprintf('tv/%s/season/%s/episode/%s/images', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
78
modules/Tmdb/Api/TvSeason.php
Normal file
78
modules/Tmdb/Api/TvSeason.php
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TvSeason
|
||||||
|
* @package Tmdb\Api
|
||||||
|
* @see http://docs.themoviedb.apiary.io/#tvseasons
|
||||||
|
*/
|
||||||
|
class TvSeason
|
||||||
|
extends AbstractApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the primary information about a TV season by its season number.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param $season_number
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getSeason($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get(sprintf('tv/%s/season/%s', $tvshow_id, $season_number), $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the cast & crew credits for a TV season by season number.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param $season_number
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getCredits($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get(sprintf('tv/%s/season/%s/credits', $tvshow_id, $season_number), $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the external ids that we have stored for a TV season by season number.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param $season_number
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getExternalIds($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get(sprintf('tv/%s/season/%s/external_ids', $tvshow_id, $season_number), $parameters, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the images (posters) that we have stored for a TV season by season number.
|
||||||
|
*
|
||||||
|
* @param $tvshow_id
|
||||||
|
* @param $season_number
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $headers
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getImages($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
return $this->get(sprintf('tv/%s/season/%s/images', $tvshow_id, $season_number), $parameters, $headers);
|
||||||
|
}
|
||||||
|
}
|
49
modules/Tmdb/ApiToken.php
Normal file
49
modules/Tmdb/ApiToken.php
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ApiToken
|
||||||
|
* @package Tmdb
|
||||||
|
*/
|
||||||
|
class ApiToken {
|
||||||
|
private $apiToken = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token bag
|
||||||
|
*
|
||||||
|
* @param $api_token
|
||||||
|
*/
|
||||||
|
public function __construct($api_token = null)
|
||||||
|
{
|
||||||
|
$this->apiToken = $api_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param null $apiToken
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setToken($apiToken)
|
||||||
|
{
|
||||||
|
$this->apiToken = $apiToken;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function getToken()
|
||||||
|
{
|
||||||
|
return $this->apiToken;
|
||||||
|
}
|
||||||
|
}
|
355
modules/Tmdb/Client.php
Normal file
355
modules/Tmdb/Client.php
Normal file
|
@ -0,0 +1,355 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb;
|
||||||
|
|
||||||
|
use Guzzle\Http\Client as GuzzleClient;
|
||||||
|
use Guzzle\Http\ClientInterface;
|
||||||
|
use Tmdb\HttpClient\HttpClient;
|
||||||
|
use Tmdb\HttpClient\HttpClientInterface;
|
||||||
|
use Tmdb\ApiToken as Token;
|
||||||
|
use Tmdb\HttpClient\Plugin\AcceptJsonHeaderPlugin;
|
||||||
|
use Tmdb\HttpClient\Plugin\ApiTokenPlugin;
|
||||||
|
use Tmdb\HttpClient\Plugin\SessionTokenPlugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client wrapper for TMDB
|
||||||
|
* @package Tmdb
|
||||||
|
*/
|
||||||
|
class Client {
|
||||||
|
/**
|
||||||
|
* Base API URI
|
||||||
|
*/
|
||||||
|
const TMDB_URI = '//api.themoviedb.org/3/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insecure schema
|
||||||
|
*/
|
||||||
|
const SCHEME_INSECURE = 'http';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Secure schema
|
||||||
|
*/
|
||||||
|
const SCHEME_SECURE = 'https';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores API authentication token
|
||||||
|
*
|
||||||
|
* @var Token
|
||||||
|
*/
|
||||||
|
private $token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores API user session token
|
||||||
|
*
|
||||||
|
* @var SessionToken
|
||||||
|
*/
|
||||||
|
private $sessionToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the request is supposed to use a secure schema
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $secure = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the HTTP Client
|
||||||
|
*
|
||||||
|
* @var HttpClientInterface
|
||||||
|
*/
|
||||||
|
private $httpClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct our client
|
||||||
|
*
|
||||||
|
* @param ClientInterface|null $httpClient
|
||||||
|
* @param ApiToken $token
|
||||||
|
* @param boolean $secure
|
||||||
|
*/
|
||||||
|
public function __construct(Token $token, ClientInterface $httpClient = null, $secure = false)
|
||||||
|
{
|
||||||
|
$this->setToken($token);
|
||||||
|
$this->setSecure($secure);
|
||||||
|
|
||||||
|
$httpClient = $httpClient ?: new GuzzleClient($this->getBaseUrl());
|
||||||
|
|
||||||
|
if ($httpClient instanceof \Guzzle\Common\HasDispatcherInterface) {
|
||||||
|
$apiTokenPlugin = new ApiTokenPlugin($token);
|
||||||
|
$httpClient->addSubscriber($apiTokenPlugin);
|
||||||
|
|
||||||
|
$acceptJsonHeaderPlugin = new AcceptJsonHeaderPlugin();
|
||||||
|
$httpClient->addSubscriber($acceptJsonHeaderPlugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->httpClient = new HttpClient($this->getBaseUrl(), array(), $httpClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the token subscriber
|
||||||
|
*
|
||||||
|
* @param Token $token
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setToken(Token $token)
|
||||||
|
{
|
||||||
|
$this->token = $token;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Configuration
|
||||||
|
*/
|
||||||
|
public function getConfigurationApi()
|
||||||
|
{
|
||||||
|
return new Api\Configuration($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Authentication
|
||||||
|
*/
|
||||||
|
public function getAuthenticationApi()
|
||||||
|
{
|
||||||
|
return new Api\Authentication($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Account
|
||||||
|
*/
|
||||||
|
public function getAccountApi()
|
||||||
|
{
|
||||||
|
return new Api\Account($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Collections
|
||||||
|
*/
|
||||||
|
public function getCollectionsApi()
|
||||||
|
{
|
||||||
|
return new Api\Collections($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Find
|
||||||
|
*/
|
||||||
|
public function getFindApi()
|
||||||
|
{
|
||||||
|
return new Api\Find($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Movies
|
||||||
|
*/
|
||||||
|
public function getMoviesApi()
|
||||||
|
{
|
||||||
|
return new Api\Movies($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Tv
|
||||||
|
*/
|
||||||
|
public function getTvApi()
|
||||||
|
{
|
||||||
|
return new Api\Tv($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\TvSeason
|
||||||
|
*/
|
||||||
|
public function getTvSeasonApi()
|
||||||
|
{
|
||||||
|
return new Api\TvSeason($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\TvEpisode
|
||||||
|
*/
|
||||||
|
public function getTvEpisodeApi()
|
||||||
|
{
|
||||||
|
return new Api\TvEpisode($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\People
|
||||||
|
*/
|
||||||
|
public function getPeopleApi()
|
||||||
|
{
|
||||||
|
return new Api\People($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Lists
|
||||||
|
*/
|
||||||
|
public function getListsApi()
|
||||||
|
{
|
||||||
|
return new Api\Lists($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Companies
|
||||||
|
*/
|
||||||
|
public function getCompaniesApi()
|
||||||
|
{
|
||||||
|
return new Api\Companies($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Genres
|
||||||
|
*/
|
||||||
|
public function getGenresApi()
|
||||||
|
{
|
||||||
|
return new Api\Genres($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Keywords
|
||||||
|
*/
|
||||||
|
public function getKeywordsApi()
|
||||||
|
{
|
||||||
|
return new Api\Keywords($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Discover
|
||||||
|
*/
|
||||||
|
public function getDiscoverApi()
|
||||||
|
{
|
||||||
|
return new Api\Discover($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Search
|
||||||
|
*/
|
||||||
|
public function getSearchApi()
|
||||||
|
{
|
||||||
|
return new Api\Search($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Reviews
|
||||||
|
*/
|
||||||
|
public function getReviewsApi()
|
||||||
|
{
|
||||||
|
return new Api\Reviews($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Changes
|
||||||
|
*/
|
||||||
|
public function getChangesApi()
|
||||||
|
{
|
||||||
|
return new Api\Changes($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Jobs
|
||||||
|
*/
|
||||||
|
public function getJobsApi()
|
||||||
|
{
|
||||||
|
return new Api\Jobs($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Networks
|
||||||
|
*/
|
||||||
|
public function getNetworksApi()
|
||||||
|
{
|
||||||
|
return new Api\Networks($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Credits
|
||||||
|
*/
|
||||||
|
public function getCreditsApi()
|
||||||
|
{
|
||||||
|
return new Api\Credits($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Api\Certifications
|
||||||
|
*/
|
||||||
|
public function getCertificationsApi()
|
||||||
|
{
|
||||||
|
return new Api\Certifications($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return HttpClientInterface
|
||||||
|
*/
|
||||||
|
public function getHttpClient()
|
||||||
|
{
|
||||||
|
return $this->httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param HttpClientInterface $httpClient
|
||||||
|
*/
|
||||||
|
public function setHttpClient(HttpClientInterface $httpClient)
|
||||||
|
{
|
||||||
|
$this->httpClient = $httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the base url with preferred schema
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBaseUrl()
|
||||||
|
{
|
||||||
|
return sprintf(
|
||||||
|
'%s:%s',
|
||||||
|
$this->getSecure() ? self::SCHEME_SECURE : self::SCHEME_INSECURE,
|
||||||
|
self::TMDB_URI
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param boolean $secure
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setSecure($secure)
|
||||||
|
{
|
||||||
|
$this->secure = $secure;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function getSecure()
|
||||||
|
{
|
||||||
|
return $this->secure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param SessionToken $sessionToken
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setSessionToken($sessionToken)
|
||||||
|
{
|
||||||
|
if ($this->httpClient->getClient() instanceof \Guzzle\Common\HasDispatcherInterface) {
|
||||||
|
$sessionTokenPlugin = new SessionTokenPlugin($sessionToken);
|
||||||
|
$this->httpClient->getClient()->addSubscriber($sessionTokenPlugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->sessionToken = $sessionToken;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return SessionToken
|
||||||
|
*/
|
||||||
|
public function getSessionToken()
|
||||||
|
{
|
||||||
|
return $this->sessionToken;
|
||||||
|
}
|
||||||
|
}
|
81
modules/Tmdb/Common/ObjectHydrator.php
Normal file
81
modules/Tmdb/Common/ObjectHydrator.php
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Common;
|
||||||
|
|
||||||
|
use Tmdb\Exception\RuntimeException;
|
||||||
|
use Tmdb\Model\AbstractModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilisation class to hydrate objects.
|
||||||
|
*
|
||||||
|
* Class ObjectHydrator
|
||||||
|
* @package Tmdb\Common
|
||||||
|
*/
|
||||||
|
class ObjectHydrator {
|
||||||
|
/**
|
||||||
|
* Hydrate the object with data
|
||||||
|
*
|
||||||
|
* @param AbstractModel $object
|
||||||
|
* @param array $data
|
||||||
|
* @return AbstractModel
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function hydrate(AbstractModel $object, $data = array())
|
||||||
|
{
|
||||||
|
if (!empty($data)) {
|
||||||
|
foreach ($data as $k => $v) {
|
||||||
|
|
||||||
|
if (in_array($k, $object::$_properties)) {
|
||||||
|
|
||||||
|
$method = $this->camelize(
|
||||||
|
sprintf('set_%s', $k)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!is_callable(array($object, $method))) {
|
||||||
|
throw new RuntimeException(sprintf(
|
||||||
|
'Trying to call method "%s" on "%s" but it does not exist or is private.',
|
||||||
|
$method,
|
||||||
|
get_class($object)
|
||||||
|
));
|
||||||
|
}else{
|
||||||
|
$object->$method($v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms an under_scored_string to a camelCasedOne
|
||||||
|
*
|
||||||
|
* @see https://gist.github.com/troelskn/751517
|
||||||
|
*
|
||||||
|
* @param string $candidate
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function camelize($candidate)
|
||||||
|
{
|
||||||
|
return lcfirst(
|
||||||
|
implode('',
|
||||||
|
array_map('ucfirst',
|
||||||
|
array_map('strtolower',
|
||||||
|
explode('_', $candidate
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
21
modules/Tmdb/Exception/InvalidArgumentException.php
Normal file
21
modules/Tmdb/Exception/InvalidArgumentException.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class InvalidArgumentException
|
||||||
|
* @package Tmdb\Exception
|
||||||
|
*/
|
||||||
|
class InvalidArgumentException extends \InvalidArgumentException {
|
||||||
|
|
||||||
|
}
|
21
modules/Tmdb/Exception/MissingArgumentException.php
Normal file
21
modules/Tmdb/Exception/MissingArgumentException.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MissingArgumentException
|
||||||
|
* @package Tmdb\Exception
|
||||||
|
*/
|
||||||
|
class MissingArgumentException extends \InvalidArgumentException {
|
||||||
|
|
||||||
|
}
|
21
modules/Tmdb/Exception/NotImplementedException.php
Normal file
21
modules/Tmdb/Exception/NotImplementedException.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class NotImplementedException
|
||||||
|
* @package Tmdb\Exception
|
||||||
|
*/
|
||||||
|
class NotImplementedException extends \Exception {
|
||||||
|
|
||||||
|
}
|
21
modules/Tmdb/Exception/RuntimeException.php
Normal file
21
modules/Tmdb/Exception/RuntimeException.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RuntimeException
|
||||||
|
* @package Tmdb\Exception
|
||||||
|
*/
|
||||||
|
class RuntimeException extends \RuntimeException {
|
||||||
|
|
||||||
|
}
|
21
modules/Tmdb/Exception/UnauthorizedRequestTokenException.php
Normal file
21
modules/Tmdb/Exception/UnauthorizedRequestTokenException.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UnauthorizedRequestTokenException
|
||||||
|
* @package Tmdb\Exception
|
||||||
|
*/
|
||||||
|
class UnauthorizedRequestTokenException extends \RuntimeException {
|
||||||
|
|
||||||
|
}
|
110
modules/Tmdb/Factory/AbstractFactory.php
Normal file
110
modules/Tmdb/Factory/AbstractFactory.php
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Common\ObjectHydrator;
|
||||||
|
use Tmdb\Model\AbstractModel;
|
||||||
|
use Tmdb\Model\Collection\ResultCollection;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AbstractFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
abstract class AbstractFactory {
|
||||||
|
/**
|
||||||
|
* Convert an array to an hydrated object
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return AbstractModel
|
||||||
|
*/
|
||||||
|
abstract public function create(array $data = array());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an array with an collection of items to an hydrated object collection
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
abstract public function createCollection(array $data = array());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a generic collection of data and map it on the class by it's static parameter $_properties
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param $class
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
protected function createGenericCollection(array $data = array(), $class)
|
||||||
|
{
|
||||||
|
if (is_object($class)) {
|
||||||
|
$class = get_class($class);
|
||||||
|
}
|
||||||
|
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->hydrate(new $class(), $item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a result collection
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param string $method
|
||||||
|
* @return ResultCollection
|
||||||
|
*/
|
||||||
|
public function createResultCollection(array $data = array(), $method = 'create')
|
||||||
|
{
|
||||||
|
$collection = new ResultCollection();
|
||||||
|
|
||||||
|
if (array_key_exists('page', $data)) {
|
||||||
|
$collection->setPage($data['page']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('total_pages', $data)) {
|
||||||
|
$collection->setTotalPages($data['total_pages']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('total_results', $data)) {
|
||||||
|
$collection->setTotalResults($data['total_results']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('results', $data)) {
|
||||||
|
$data = $data['results'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->$method($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hydrate the object with data
|
||||||
|
*
|
||||||
|
* @param AbstractModel $object
|
||||||
|
* @param array $data
|
||||||
|
* @return AbstractModel
|
||||||
|
*/
|
||||||
|
protected function hydrate(AbstractModel $object, $data = array())
|
||||||
|
{
|
||||||
|
$objectHydrator = new ObjectHydrator();
|
||||||
|
|
||||||
|
return $objectHydrator->hydrate($object, $data);
|
||||||
|
}
|
||||||
|
}
|
131
modules/Tmdb/Factory/AccountFactory.php
Normal file
131
modules/Tmdb/Factory/AccountFactory.php
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Exception\NotImplementedException;
|
||||||
|
use Tmdb\Model\Account;
|
||||||
|
use Tmdb\Model\Lists\Result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AccountFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class AccountFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var MovieFactory
|
||||||
|
*/
|
||||||
|
private $movieFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ImageFactory
|
||||||
|
*/
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->movieFactory = new MovieFactory();
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Account
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Account(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
public function createStatusResult(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Result(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create movie
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Tmdb\Model\Movie
|
||||||
|
*/
|
||||||
|
public function createMovie(array $data = array()) {
|
||||||
|
return $this->getMovieFactory()->create($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create list item
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Tmdb\Model\AbstractModel
|
||||||
|
*/
|
||||||
|
public function createListItem(array $data = array())
|
||||||
|
{
|
||||||
|
$listItem = new Account\ListItem();
|
||||||
|
|
||||||
|
if (array_key_exists('poster_path', $data)) {
|
||||||
|
$listItem->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($listItem, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
throw new NotImplementedException('Not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\MovieFactory $movieFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setMovieFactory($movieFactory)
|
||||||
|
{
|
||||||
|
$this->movieFactory = $movieFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\MovieFactory
|
||||||
|
*/
|
||||||
|
public function getMovieFactory()
|
||||||
|
{
|
||||||
|
return $this->movieFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
}
|
117
modules/Tmdb/Factory/AuthenticationFactory.php
Normal file
117
modules/Tmdb/Factory/AuthenticationFactory.php
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Exception\NotImplementedException;
|
||||||
|
use Tmdb\RequestToken;
|
||||||
|
use Tmdb\SessionToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AuthenticationFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class AuthenticationFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @throws NotImplementedException
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @throws NotImplementedException
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create request token
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return RequestToken
|
||||||
|
*/
|
||||||
|
public function createRequestToken(array $data = array())
|
||||||
|
{
|
||||||
|
$token = new RequestToken();
|
||||||
|
|
||||||
|
if (array_key_exists('expires_at', $data)) {
|
||||||
|
$token->setExpiresAt(new \DateTime($data['expires_at']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('request_token', $data)) {
|
||||||
|
$token->setToken($data['request_token']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('success', $data)) {
|
||||||
|
$token->setSuccess($data['success']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create session token for user
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return SessionToken
|
||||||
|
*/
|
||||||
|
public function createSessionToken(array $data = array())
|
||||||
|
{
|
||||||
|
$token = new SessionToken();
|
||||||
|
|
||||||
|
if (array_key_exists('session_id', $data)) {
|
||||||
|
$token->setToken($data['session_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('success', $data)) {
|
||||||
|
$token->setSuccess($data['success']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create session token for guest
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return SessionToken
|
||||||
|
*/
|
||||||
|
public function createGuestSessionToken(array $data = array())
|
||||||
|
{
|
||||||
|
$token = new SessionToken();
|
||||||
|
|
||||||
|
if (array_key_exists('expires_at', $data)) {
|
||||||
|
$token->setExpiresAt(new \DateTime($data['expires_at']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('guest_session_id', $data)) {
|
||||||
|
$token->setToken($data['guest_session_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('success', $data)) {
|
||||||
|
$token->setSuccess($data['success']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
}
|
60
modules/Tmdb/Factory/CertificationFactory.php
Normal file
60
modules/Tmdb/Factory/CertificationFactory.php
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Certification;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CertificationFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class CertificationFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Certification
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Certification\CountryCertification(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
if (array_key_exists('certifications', $data)) {
|
||||||
|
$data = $data['certifications'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
foreach($data as $country => $certifications) {
|
||||||
|
$certification = new Certification();
|
||||||
|
$certification->setCountry($country);
|
||||||
|
|
||||||
|
foreach($certifications as $countryCertification) {
|
||||||
|
$object = $this->create($countryCertification);
|
||||||
|
|
||||||
|
$certification->getCertifications()->add(null, $object);
|
||||||
|
}
|
||||||
|
|
||||||
|
$collection->add(null, $certification);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
62
modules/Tmdb/Factory/ChangesFactory.php
Normal file
62
modules/Tmdb/Factory/ChangesFactory.php
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Change;
|
||||||
|
use Tmdb\Model\Collection\Changes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ChangesFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class ChangesFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
* @return \Tmdb\Model\Change
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Change(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new Changes();
|
||||||
|
|
||||||
|
if (array_key_exists('page', $data)) {
|
||||||
|
$collection->setPage($data['page']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('total_pages', $data)) {
|
||||||
|
$collection->setTotalPages($data['total_pages']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('total_results', $data)) {
|
||||||
|
$collection->setTotalResults($data['total_results']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('results', $data)) {
|
||||||
|
$data = $data['results'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
121
modules/Tmdb/Factory/CollectionFactory.php
Normal file
121
modules/Tmdb/Factory/CollectionFactory.php
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CollectionFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class CollectionFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var MovieFactory
|
||||||
|
*/
|
||||||
|
private $movieFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ImageFactory
|
||||||
|
*/
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->movieFactory = new MovieFactory();
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
* @return \Tmdb\Model\Collection
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new Collection();
|
||||||
|
|
||||||
|
if (array_key_exists('parts', $data)) {
|
||||||
|
$collection->setParts(
|
||||||
|
$this->getMovieFactory()->createCollection($data['parts'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('backdrop_path', $data)) {
|
||||||
|
$collection->setBackdropImage($this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('images', $data)) {
|
||||||
|
$collection->setImages($this->getImageFactory()->createCollectionFromMovie($data['images']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('poster_path', $data)) {
|
||||||
|
$collection->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($collection, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\MovieFactory $movieFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setMovieFactory($movieFactory)
|
||||||
|
{
|
||||||
|
$this->movieFactory = $movieFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\MovieFactory
|
||||||
|
*/
|
||||||
|
public function getMovieFactory()
|
||||||
|
{
|
||||||
|
return $this->movieFactory;
|
||||||
|
}
|
||||||
|
}
|
75
modules/Tmdb/Factory/Common/ChangeFactory.php
Normal file
75
modules/Tmdb/Factory/Common/ChangeFactory.php
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory\Common;
|
||||||
|
|
||||||
|
use Tmdb\Factory\AbstractFactory;
|
||||||
|
use Tmdb\Model\Common\Change;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ChangeFactory
|
||||||
|
* @package Tmdb\Factory\Common
|
||||||
|
*/
|
||||||
|
class ChangeFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$change = new Change();
|
||||||
|
|
||||||
|
if (array_key_exists('items', $data)) {
|
||||||
|
$items = new GenericCollection();
|
||||||
|
|
||||||
|
foreach($data['items'] as $item) {
|
||||||
|
$item = $this->createChangeItem($item);
|
||||||
|
|
||||||
|
$items->add(null, $item);
|
||||||
|
}
|
||||||
|
|
||||||
|
$change->setItems($items);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($change, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create individual change items
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Tmdb\Model\AbstractModel
|
||||||
|
*/
|
||||||
|
private function createChangeItem(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Change\Item(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
if (array_key_exists('changes', $data)) {
|
||||||
|
$data = $data['changes'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
55
modules/Tmdb/Factory/Common/GenericCollectionFactory.php
Normal file
55
modules/Tmdb/Factory/Common/GenericCollectionFactory.php
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory\Common;
|
||||||
|
|
||||||
|
use Tmdb\Common\ObjectHydrator;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*
|
||||||
|
* Class GenericCollectionFactory
|
||||||
|
* @package Tmdb\Factory\Common
|
||||||
|
*/
|
||||||
|
class GenericCollectionFactory {
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @param $class
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function create(array $data = array(), $class)
|
||||||
|
{
|
||||||
|
return $this->createCollection($data, $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @param $class
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array(), $class)
|
||||||
|
{
|
||||||
|
if (is_object($class)) {
|
||||||
|
$class = get_class($class);
|
||||||
|
}
|
||||||
|
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
$objectHydrator = new ObjectHydrator();
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $objectHydrator->hydrate(new $class(), $item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
75
modules/Tmdb/Factory/CompanyFactory.php
Normal file
75
modules/Tmdb/Factory/CompanyFactory.php
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Company;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CompanyFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class CompanyFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var ImageFactory
|
||||||
|
*/
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$company = new Company();
|
||||||
|
|
||||||
|
if (array_key_exists('logo_path', $data)) {
|
||||||
|
$company->setLogoImage($this->getImageFactory()->createFromPath($data['logo_path'], 'logo_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($company, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
}
|
40
modules/Tmdb/Factory/ConfigurationFactory.php
Normal file
40
modules/Tmdb/Factory/ConfigurationFactory.php
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ConfigurationFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class ConfigurationFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$config = new Configuration();
|
||||||
|
|
||||||
|
return $this->hydrate($config, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
}
|
144
modules/Tmdb/Factory/CreditsFactory.php
Normal file
144
modules/Tmdb/Factory/CreditsFactory.php
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Exception\NotImplementedException;
|
||||||
|
use Tmdb\Model\Genre;
|
||||||
|
use Tmdb\Model\Movie;
|
||||||
|
use Tmdb\Model\Credits as Credits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CreditsFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class CreditsFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var TvSeasonFactory
|
||||||
|
*/
|
||||||
|
private $tvSeasonFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TvEpisodeFactory
|
||||||
|
*/
|
||||||
|
private $tvEpisodeFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PeopleFactory
|
||||||
|
*/
|
||||||
|
private $peopleFactory;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->tvSeasonFactory = new TvSeasonFactory();
|
||||||
|
$this->tvEpisodeFactory = new TvEpisodeFactory();
|
||||||
|
$this->peopleFactory = new PeopleFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Genre
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$credits = new Credits();
|
||||||
|
|
||||||
|
if (array_key_exists('media', $data)) {
|
||||||
|
|
||||||
|
$credits->setMedia(
|
||||||
|
$this->hydrate($credits->getMedia(), $data['media'])
|
||||||
|
);
|
||||||
|
|
||||||
|
if (array_key_exists('seasons', $data['media'])) {
|
||||||
|
$episodes = $this->getTvSeasonFactory()->createCollection($data['media']['seasons']);
|
||||||
|
$credits->getMedia()->setSeasons($episodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('episodes', $data['media'])) {
|
||||||
|
$episodes = $this->getTvEpisodeFactory()->createCollection($data['media']['episodes']);
|
||||||
|
$credits->getMedia()->setEpisodes($episodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('person', $data)) {
|
||||||
|
$credits->setPerson(
|
||||||
|
$this->getPeopleFactory()->create($data['person'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($credits, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws NotImplementedException
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
throw new NotImplementedException('Credits are usually obtained through the PeopleFactory, however we might add a shortcut for that here.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\TvEpisodeFactory $tvEpisodeFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTvEpisodeFactory($tvEpisodeFactory)
|
||||||
|
{
|
||||||
|
$this->tvEpisodeFactory = $tvEpisodeFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\TvEpisodeFactory
|
||||||
|
*/
|
||||||
|
public function getTvEpisodeFactory()
|
||||||
|
{
|
||||||
|
return $this->tvEpisodeFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\TvSeasonFactory $tvSeasonFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTvSeasonFactory($tvSeasonFactory)
|
||||||
|
{
|
||||||
|
$this->tvSeasonFactory = $tvSeasonFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\TvSeasonFactory
|
||||||
|
*/
|
||||||
|
public function getTvSeasonFactory()
|
||||||
|
{
|
||||||
|
return $this->tvSeasonFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\PeopleFactory $peopleFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPeopleFactory($peopleFactory)
|
||||||
|
{
|
||||||
|
$this->peopleFactory = $peopleFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\PeopleFactory
|
||||||
|
*/
|
||||||
|
public function getPeopleFactory()
|
||||||
|
{
|
||||||
|
return $this->peopleFactory;
|
||||||
|
}
|
||||||
|
}
|
134
modules/Tmdb/Factory/FindFactory.php
Normal file
134
modules/Tmdb/Factory/FindFactory.php
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Exception\NotImplementedException;
|
||||||
|
use Tmdb\Model\Find;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class FindFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class FindFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var MovieFactory
|
||||||
|
*/
|
||||||
|
private $movieFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PeopleFactory
|
||||||
|
*/
|
||||||
|
private $peopleFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TvFactory
|
||||||
|
*/
|
||||||
|
private $tvFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->movieFactory = new MovieFactory();
|
||||||
|
$this->peopleFactory = new PeopleFactory();
|
||||||
|
$this->tvFactory = new TvFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$find = new Find();
|
||||||
|
|
||||||
|
if (array_key_exists('movie_results', $data)) {
|
||||||
|
$find->setMovieResults($this->getMovieFactory()->createCollection($data['movie_results']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('person_results', $data)) {
|
||||||
|
$find->setPersonResults($this->getPeopleFactory()->createCollection($data['person_results']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('tv_results', $data)) {
|
||||||
|
$find->setTvResults($this->getTvFactory()->createCollection($data['tv_results']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $find;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
throw new NotImplementedException(sprintf('Method "%s" is not implemented.', __METHOD__));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\MovieFactory $movieFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setMovieFactory($movieFactory)
|
||||||
|
{
|
||||||
|
$this->movieFactory = $movieFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\MovieFactory
|
||||||
|
*/
|
||||||
|
public function getMovieFactory()
|
||||||
|
{
|
||||||
|
return $this->movieFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\PeopleFactory $peopleFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPeopleFactory($peopleFactory)
|
||||||
|
{
|
||||||
|
$this->peopleFactory = $peopleFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\PeopleFactory
|
||||||
|
*/
|
||||||
|
public function getPeopleFactory()
|
||||||
|
{
|
||||||
|
return $this->peopleFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\TvFactory $tvFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTvFactory($tvFactory)
|
||||||
|
{
|
||||||
|
$this->tvFactory = $tvFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\TvFactory
|
||||||
|
*/
|
||||||
|
public function getTvFactory()
|
||||||
|
{
|
||||||
|
return $this->tvFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
52
modules/Tmdb/Factory/GenreFactory.php
Normal file
52
modules/Tmdb/Factory/GenreFactory.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\Genres;
|
||||||
|
use Tmdb\Model\Genre;
|
||||||
|
use Tmdb\Model\Movie;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class GenreFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class GenreFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Genre
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Genre(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new Genres();
|
||||||
|
|
||||||
|
if (array_key_exists('genres', $data)) {
|
||||||
|
$data = $data['genres'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->addGenre($this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
202
modules/Tmdb/Factory/ImageFactory.php
Normal file
202
modules/Tmdb/Factory/ImageFactory.php
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\Images;
|
||||||
|
use Tmdb\Model\Image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ImageFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class ImageFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Convert an array to an hydrated object
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param string|null $key
|
||||||
|
* @return Image
|
||||||
|
*/
|
||||||
|
public function create(array $data = array(), $key = null)
|
||||||
|
{
|
||||||
|
$type = self::resolveImageType($key);
|
||||||
|
|
||||||
|
return $this->hydrate($type, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an image instance based on the path and type, e.g.
|
||||||
|
*
|
||||||
|
* '/xkQ5yWnMjpC2bGmu7GsD66AAoKO.jpg', 'backdrop_path'
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
* @param string $key
|
||||||
|
* @return Image|Image\BackdropImage|Image\LogoImage|Image\PosterImage|Image\ProfileImage|Image\StillImage
|
||||||
|
*/
|
||||||
|
public function createFromPath($path, $key)
|
||||||
|
{
|
||||||
|
return $this->hydrate(
|
||||||
|
self::resolveImageType($key),
|
||||||
|
array('file_path' => $path)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to obtain a new object for an image type
|
||||||
|
*
|
||||||
|
* @param string|null $key
|
||||||
|
* @return Image|Image\BackdropImage|Image\LogoImage|Image\PosterImage|Image\ProfileImage|Image\StillImage
|
||||||
|
*/
|
||||||
|
public function resolveImageType($key = null)
|
||||||
|
{
|
||||||
|
switch($key) {
|
||||||
|
case 'poster':
|
||||||
|
case 'posters':
|
||||||
|
case 'poster_path':
|
||||||
|
$object = new Image\PosterImage();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'backdrop':
|
||||||
|
case 'backdrops':
|
||||||
|
case 'backdrop_path':
|
||||||
|
$object = new Image\BackdropImage();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'profile':
|
||||||
|
case 'profiles':
|
||||||
|
case 'profile_path':
|
||||||
|
$object = new Image\ProfileImage();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'logo':
|
||||||
|
case 'logos':
|
||||||
|
case 'logo_path':
|
||||||
|
$object = new Image\LogoImage();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'still':
|
||||||
|
case 'stills':
|
||||||
|
case 'still_path':
|
||||||
|
$object = new Image\StillImage();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'file_path':
|
||||||
|
default:
|
||||||
|
$object = new Image();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create generic collection
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new Images();
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create full collection
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function createImageCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new Images();
|
||||||
|
|
||||||
|
foreach($data as $format => $formatCollection) {
|
||||||
|
|
||||||
|
if (!is_array($formatCollection)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($formatCollection as $item) {
|
||||||
|
if (array_key_exists($format, Image::$_formats)) {
|
||||||
|
$item = $this->create($item, $format);
|
||||||
|
|
||||||
|
$collection->addImage($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create full movie collection
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function createCollectionFromMovie(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->createImageCollection($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create full tv show collection
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function createCollectionFromTv(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->createImageCollection($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create full tv season collection
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function createCollectionFromTvSeason(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->createImageCollection($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create full tv episode collection
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function createCollectionFromTvEpisode(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->createImageCollection($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create full people collection
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function createCollectionFromPeople(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->createImageCollection($data);
|
||||||
|
}
|
||||||
|
}
|
49
modules/Tmdb/Factory/JobsFactory.php
Normal file
49
modules/Tmdb/Factory/JobsFactory.php
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\Jobs;
|
||||||
|
use Tmdb\Model\Job;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class JobsFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class JobsFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Job(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new Jobs();
|
||||||
|
|
||||||
|
if (array_key_exists('jobs', $data)) {
|
||||||
|
$data = $data['jobs'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
52
modules/Tmdb/Factory/KeywordFactory.php
Normal file
52
modules/Tmdb/Factory/KeywordFactory.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\Keywords;
|
||||||
|
use Tmdb\Model\Keyword;
|
||||||
|
use Tmdb\Model\Movie;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class KeywordFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class KeywordFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Keyword
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Keyword(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new Keywords();
|
||||||
|
|
||||||
|
if (array_key_exists('keywords', $data)) {
|
||||||
|
$data = $data['keywords'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->addKeyword($this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
145
modules/Tmdb/Factory/ListFactory.php
Normal file
145
modules/Tmdb/Factory/ListFactory.php
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Factory\Lists\ListItemFactory;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Genre;
|
||||||
|
use Tmdb\Model\Lists;
|
||||||
|
use Tmdb\Model\Movie;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ListFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class ListFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var ImageFactory
|
||||||
|
*/
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ListItemFactory
|
||||||
|
*/
|
||||||
|
private $listItemFactory;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
$this->listItemFactory = new ListItemFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Genre
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$lists = new Lists();
|
||||||
|
|
||||||
|
if (array_key_exists('items', $data)) {
|
||||||
|
$lists->setItems(
|
||||||
|
$this->getListItemFactory()->createCollection($data['items'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Images */
|
||||||
|
if (array_key_exists('poster_path', $data)) {
|
||||||
|
$lists->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($lists, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Lists\ItemStatus
|
||||||
|
*/
|
||||||
|
public function createItemStatus(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Lists\ItemStatus(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Lists\Result
|
||||||
|
*/
|
||||||
|
public function createResult(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Lists\Result(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Lists\ResultWithListId
|
||||||
|
*/
|
||||||
|
public function createResultWithListId(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Lists\ResultWithListId(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\Lists\ListItemFactory $listItemFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setListItemFactory($listItemFactory)
|
||||||
|
{
|
||||||
|
$this->listItemFactory = $listItemFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\Lists\ListItemFactory
|
||||||
|
*/
|
||||||
|
public function getListItemFactory()
|
||||||
|
{
|
||||||
|
return $this->listItemFactory;
|
||||||
|
}
|
||||||
|
}
|
92
modules/Tmdb/Factory/Lists/ListItemFactory.php
Normal file
92
modules/Tmdb/Factory/Lists/ListItemFactory.php
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory\Lists;
|
||||||
|
|
||||||
|
use Tmdb\Factory\AbstractFactory;
|
||||||
|
use Tmdb\Factory\ImageFactory;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Lists\ListItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ListItemFactory
|
||||||
|
* @package Tmdb\Factory\Lists
|
||||||
|
*/
|
||||||
|
class ListItemFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var ImageFactory
|
||||||
|
*/
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return ListItem
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$listItem = new ListItem();
|
||||||
|
|
||||||
|
/** Images */
|
||||||
|
if (array_key_exists('backdrop_path', $data)) {
|
||||||
|
$listItem->setBackdropImage($this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('poster_path', $data)) {
|
||||||
|
$listItem->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($listItem, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
if (array_key_exists('items', $data)) {
|
||||||
|
$data = $data['items'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
}
|
48
modules/Tmdb/Factory/Movie/AlternativeTitleFactory.php
Normal file
48
modules/Tmdb/Factory/Movie/AlternativeTitleFactory.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory\Movie;
|
||||||
|
|
||||||
|
use Tmdb\Factory\AbstractFactory;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Movie\AlternativeTitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AlternativeTitleFactory
|
||||||
|
* @package Tmdb\Factory\Movie
|
||||||
|
*/
|
||||||
|
class AlternativeTitleFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$title = new AlternativeTitle();
|
||||||
|
|
||||||
|
return $this->hydrate($title, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
71
modules/Tmdb/Factory/Movie/ListItemFactory.php
Normal file
71
modules/Tmdb/Factory/Movie/ListItemFactory.php
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory\Movie;
|
||||||
|
|
||||||
|
use Tmdb\Factory\AbstractFactory;
|
||||||
|
use Tmdb\Factory\ImageFactory;
|
||||||
|
use Tmdb\Model\Movie\ListItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ListItemFactory
|
||||||
|
* @package Tmdb\Factory\Movie
|
||||||
|
*/
|
||||||
|
class ListItemFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$listItem = new ListItem();
|
||||||
|
|
||||||
|
if (array_key_exists('poster_path', $data)) {
|
||||||
|
$listItem->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($listItem, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->createResultCollection($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
}
|
370
modules/Tmdb/Factory/MovieFactory.php
Normal file
370
modules/Tmdb/Factory/MovieFactory.php
Normal file
|
@ -0,0 +1,370 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Factory\Common\ChangeFactory;
|
||||||
|
use Tmdb\Factory\Movie\ListItemFactory;
|
||||||
|
use Tmdb\Factory\People\CastFactory;
|
||||||
|
use Tmdb\Factory\People\CrewFactory;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Common\Trailer\Youtube;
|
||||||
|
use Tmdb\Model\Common\Translation;
|
||||||
|
use Tmdb\Model\Lists\Result;
|
||||||
|
use Tmdb\Model\Movie;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MovieFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class MovieFactory extends AbstractFactory {
|
||||||
|
/**
|
||||||
|
* @var People\CastFactory
|
||||||
|
*/
|
||||||
|
private $castFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var People\CrewFactory
|
||||||
|
*/
|
||||||
|
private $crewFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var GenreFactory
|
||||||
|
*/
|
||||||
|
private $genreFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ImageFactory
|
||||||
|
*/
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ChangeFactory
|
||||||
|
*/
|
||||||
|
private $changeFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ReviewFactory
|
||||||
|
*/
|
||||||
|
private $reviewFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ListItemFactory
|
||||||
|
*/
|
||||||
|
private $listItemFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var KeywordFactory
|
||||||
|
*/
|
||||||
|
private $keywordFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->castFactory = new CastFactory();
|
||||||
|
$this->crewFactory = new CrewFactory();
|
||||||
|
$this->genreFactory = new GenreFactory();
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
$this->changeFactory = new ChangeFactory();
|
||||||
|
$this->reviewFactory = new ReviewFactory();
|
||||||
|
$this->listItemFactory = new ListItemFactory();
|
||||||
|
$this->keywordFactory = new KeywordFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @return Movie
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
if (!$data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$movie = new Movie();
|
||||||
|
|
||||||
|
if (array_key_exists('alternative_titles', $data) && array_key_exists('titles', $data['alternative_titles'])) {
|
||||||
|
$movie->setAlternativeTitles(
|
||||||
|
$this->createGenericCollection($data['alternative_titles']['titles'], new Movie\AlternativeTitle())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('credits', $data)) {
|
||||||
|
if (array_key_exists('cast', $data['credits'])) {
|
||||||
|
$movie->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('crew', $data['credits'])) {
|
||||||
|
$movie->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Genres */
|
||||||
|
if (array_key_exists('genres', $data)) {
|
||||||
|
$movie->setGenres($this->getGenreFactory()->createCollection($data['genres']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Images */
|
||||||
|
if (array_key_exists('backdrop_path', $data)) {
|
||||||
|
$movie->setBackdropImage($this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('images', $data)) {
|
||||||
|
$movie->setImages($this->getImageFactory()->createCollectionFromMovie($data['images']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('poster_path', $data)) {
|
||||||
|
$movie->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Keywords */
|
||||||
|
if (array_key_exists('keywords', $data)) {
|
||||||
|
$movie->setKeywords($this->getKeywordFactory()->createCollection($data['keywords']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('releases', $data) && array_key_exists('countries', $data['releases'])) {
|
||||||
|
$movie->setReleases($this->createGenericCollection($data['releases']['countries'], new Movie\Release()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @TODO actually implement more providers? ( Can't seem to find any quicktime related trailers anyways? ). For now KISS
|
||||||
|
*/
|
||||||
|
if (array_key_exists('trailers', $data) && array_key_exists('youtube', $data['trailers'])) {
|
||||||
|
$movie->setTrailers($this->createGenericCollection($data['trailers']['youtube'], new Youtube()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('translations', $data) && array_key_exists('translations', $data['translations'])) {
|
||||||
|
$movie->setTranslations($this->createGenericCollection($data['translations']['translations'], new Translation()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('similar_movies', $data)) {
|
||||||
|
$movie->setSimilarMovies($this->createResultCollection($data['similar_movies']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('reviews', $data)) {
|
||||||
|
$movie->setReviews($this->getReviewFactory()->createResultCollection($data['reviews']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('lists', $data)) {
|
||||||
|
$movie->setLists($this->getListItemFactory()->createResultCollection($data['lists']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('changes', $data)) {
|
||||||
|
$movie->setChanges($this->getChangeFactory()->createCollection($data['changes']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($movie, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
if (array_key_exists('results', $data)) {
|
||||||
|
$data = $data['results'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create result
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Tmdb\Model\AbstractModel
|
||||||
|
*/
|
||||||
|
public function createResult(array $data = array()) {
|
||||||
|
return $this->hydrate(new Result(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create rating
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Tmdb\Model\AbstractModel
|
||||||
|
*/
|
||||||
|
public function createRating(array $data = array()) {
|
||||||
|
return $this->hydrate(new Movie\Rating(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the account states
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Tmdb\Model\AbstractModel
|
||||||
|
*/
|
||||||
|
public function createAccountStates(array $data = array())
|
||||||
|
{
|
||||||
|
$accountStates = new Movie\AccountStates();
|
||||||
|
|
||||||
|
if (array_key_exists('rated', $data)) {
|
||||||
|
$rating = new Movie\Rating();
|
||||||
|
|
||||||
|
$accountStates->setRated($this->hydrate($rating, $data['rated']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($accountStates, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCastFactory($castFactory)
|
||||||
|
{
|
||||||
|
$this->castFactory = $castFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\People\CastFactory
|
||||||
|
*/
|
||||||
|
public function getCastFactory()
|
||||||
|
{
|
||||||
|
return $this->castFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCrewFactory($crewFactory)
|
||||||
|
{
|
||||||
|
$this->crewFactory = $crewFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\People\CrewFactory
|
||||||
|
*/
|
||||||
|
public function getCrewFactory()
|
||||||
|
{
|
||||||
|
return $this->crewFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\GenreFactory $genreFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setGenreFactory($genreFactory)
|
||||||
|
{
|
||||||
|
$this->genreFactory = $genreFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\GenreFactory
|
||||||
|
*/
|
||||||
|
public function getGenreFactory()
|
||||||
|
{
|
||||||
|
return $this->genreFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\Common\ChangeFactory $changeFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setChangeFactory($changeFactory)
|
||||||
|
{
|
||||||
|
$this->changeFactory = $changeFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\Common\ChangeFactory
|
||||||
|
*/
|
||||||
|
public function getChangeFactory()
|
||||||
|
{
|
||||||
|
return $this->changeFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ReviewFactory $reviewFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setReviewFactory($reviewFactory)
|
||||||
|
{
|
||||||
|
$this->reviewFactory = $reviewFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ReviewFactory
|
||||||
|
*/
|
||||||
|
public function getReviewFactory()
|
||||||
|
{
|
||||||
|
return $this->reviewFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\Movie\ListItemFactory $listItemFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setListItemFactory($listItemFactory)
|
||||||
|
{
|
||||||
|
$this->listItemFactory = $listItemFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\Movie\ListItemFactory
|
||||||
|
*/
|
||||||
|
public function getListItemFactory()
|
||||||
|
{
|
||||||
|
return $this->listItemFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\KeywordFactory $keywordFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setKeywordFactory($keywordFactory)
|
||||||
|
{
|
||||||
|
$this->keywordFactory = $keywordFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\KeywordFactory
|
||||||
|
*/
|
||||||
|
public function getKeywordFactory()
|
||||||
|
{
|
||||||
|
return $this->keywordFactory;
|
||||||
|
}
|
||||||
|
}
|
52
modules/Tmdb/Factory/NetworkFactory.php
Normal file
52
modules/Tmdb/Factory/NetworkFactory.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Network;
|
||||||
|
use Tmdb\Model\Movie;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class NetworkFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class NetworkFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Network
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->hydrate(new Network(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
if (array_key_exists('networks', $data)) {
|
||||||
|
$data = $data['networks'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
53
modules/Tmdb/Factory/People/CastFactory.php
Normal file
53
modules/Tmdb/Factory/People/CastFactory.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory\People;
|
||||||
|
|
||||||
|
use Tmdb\Factory\PeopleFactory;
|
||||||
|
use Tmdb\Model\Collection\People\Cast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CastFactory
|
||||||
|
* @package Tmdb\Factory\People
|
||||||
|
*/
|
||||||
|
class CastFactory extends PeopleFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array(), $person = null)
|
||||||
|
{
|
||||||
|
return parent::create($data, $person);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
* @param \Tmdb\Model\Person\CastMember $person
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array(), $person = null)
|
||||||
|
{
|
||||||
|
$collection = new Cast();
|
||||||
|
|
||||||
|
if (is_object($person)) {
|
||||||
|
$class = get_class($person);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$class = '\Tmdb\Model\Person\CastMember';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item, new $class()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
53
modules/Tmdb/Factory/People/CrewFactory.php
Normal file
53
modules/Tmdb/Factory/People/CrewFactory.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory\People;
|
||||||
|
|
||||||
|
use Tmdb\Factory\PeopleFactory;
|
||||||
|
use Tmdb\Model\Collection\People\Crew;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CrewFactory
|
||||||
|
* @package Tmdb\Factory\People
|
||||||
|
*/
|
||||||
|
class CrewFactory extends PeopleFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array(), $person = null)
|
||||||
|
{
|
||||||
|
return parent::create($data, $person);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
* @param \Tmdb\Model\Person\CrewMember $person
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array(), $person = null)
|
||||||
|
{
|
||||||
|
$collection = new Crew();
|
||||||
|
|
||||||
|
if (is_object($person)) {
|
||||||
|
$class = get_class($person);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$class = '\Tmdb\Model\Person\CrewMember';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item, new $class()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
206
modules/Tmdb/Factory/PeopleFactory.php
Normal file
206
modules/Tmdb/Factory/PeopleFactory.php
Normal file
|
@ -0,0 +1,206 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Common\ObjectHydrator;
|
||||||
|
use Tmdb\Factory\Common\ChangeFactory;
|
||||||
|
use Tmdb\Model\Collection\People;
|
||||||
|
use Tmdb\Model\Common\ExternalIds;
|
||||||
|
use Tmdb\Model\Person\CastMember;
|
||||||
|
use Tmdb\Model\Person\CrewMember;
|
||||||
|
use Tmdb\Model\Person;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PeopleFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class PeopleFactory extends AbstractFactory {
|
||||||
|
/**
|
||||||
|
* @var ImageFactory
|
||||||
|
*/
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ChangeFactory
|
||||||
|
*/
|
||||||
|
private $changeFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
$this->changeFactory = new ChangeFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @param Person\AbstractMember|null $person
|
||||||
|
*
|
||||||
|
* @return Person|CrewMember|CastMember
|
||||||
|
*/
|
||||||
|
public function create(array $data = array(), $person = null)
|
||||||
|
{
|
||||||
|
if (!is_object($person)) {
|
||||||
|
if (array_key_exists('character', $data)) {
|
||||||
|
$person = new CastMember();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('job', $data)) {
|
||||||
|
$person = new CrewMember();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $person) {
|
||||||
|
$person = new Person();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('profile_path', $data)) {
|
||||||
|
$person->setProfileImage($this->getImageFactory()->createFromPath($data['profile_path'], 'profile_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($person instanceof Person) {
|
||||||
|
/** Images */
|
||||||
|
if (array_key_exists('images', $data)) {
|
||||||
|
$person->setImages($this->getImageFactory()->createCollectionFromPeople($data['images']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Credits */
|
||||||
|
$this->applyCredits($data, $person);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('changes', $data)) {
|
||||||
|
$person->setChanges($this->getChangeFactory()->createCollection($data['changes']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** External ids */
|
||||||
|
if (array_key_exists('external_ids', $data)) {
|
||||||
|
$person->setExternalIds(
|
||||||
|
$this->hydrate(new ExternalIds(), $data['external_ids'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($person, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply credits
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param Person $person
|
||||||
|
*/
|
||||||
|
protected function applyCredits(array $data = array(), Person $person) {
|
||||||
|
$hydrator = new ObjectHydrator();
|
||||||
|
$types = array('movie_credits', 'tv_credits', 'combined_credits');
|
||||||
|
|
||||||
|
foreach($types as $type) {
|
||||||
|
if (array_key_exists($type, $data)) {
|
||||||
|
$method = $hydrator->camelize(sprintf('get_%s', $type));
|
||||||
|
|
||||||
|
if (array_key_exists('cast', $data[$type])) {
|
||||||
|
$cast = $this->createGenericCollection(
|
||||||
|
$data[$type]['cast'],
|
||||||
|
new Person\MovieCredit()
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach($cast as $member) {
|
||||||
|
$member->setPosterImage($member->getPosterPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
$person->$method()->setCast($cast);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('crew', $data[$type])) {
|
||||||
|
$crew = $this->createGenericCollection(
|
||||||
|
$data[$type]['crew'],
|
||||||
|
new Person\MovieCredit()
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach($crew as $member) {
|
||||||
|
$member->setPosterImage($member->getPosterPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
$person->$method()->setCrew($crew);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPosterImageForCredit($posterPath)
|
||||||
|
{
|
||||||
|
return $this->getImageFactory()->createFromPath($posterPath, 'poster_path');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array(), $person = null, $collection = null)
|
||||||
|
{
|
||||||
|
if (!$collection) {
|
||||||
|
$collection = new People();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('results', $data)) {
|
||||||
|
$data = $data['results'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_object($person)) {
|
||||||
|
$class = get_class($person);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$class = '\Tmdb\Model\Person';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item, new $class()));
|
||||||
|
}
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\Common\ChangeFactory $changeFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setChangeFactory($changeFactory)
|
||||||
|
{
|
||||||
|
$this->changeFactory = $changeFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\Common\ChangeFactory
|
||||||
|
*/
|
||||||
|
public function getChangeFactory()
|
||||||
|
{
|
||||||
|
return $this->changeFactory;
|
||||||
|
}
|
||||||
|
}
|
40
modules/Tmdb/Factory/ReviewFactory.php
Normal file
40
modules/Tmdb/Factory/ReviewFactory.php
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Model\Review;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ReviewFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class ReviewFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
$review = new Review();
|
||||||
|
|
||||||
|
return $this->hydrate($review, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
return $this->createResultCollection($data);
|
||||||
|
}
|
||||||
|
}
|
166
modules/Tmdb/Factory/TvEpisodeFactory.php
Normal file
166
modules/Tmdb/Factory/TvEpisodeFactory.php
Normal file
|
@ -0,0 +1,166 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Factory\People\CastFactory;
|
||||||
|
use Tmdb\Factory\People\CrewFactory;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Person\CastMember;
|
||||||
|
use Tmdb\Model\Person\CrewMember;
|
||||||
|
use Tmdb\Model\Common\ExternalIds;
|
||||||
|
use Tmdb\Model\Tv\Episode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TvEpisodeFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class TvEpisodeFactory extends AbstractFactory {
|
||||||
|
/**
|
||||||
|
* @var People\CastFactory
|
||||||
|
*/
|
||||||
|
private $castFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var People\CrewFactory
|
||||||
|
*/
|
||||||
|
private $crewFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ImageFactory
|
||||||
|
*/
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->castFactory = new CastFactory();
|
||||||
|
$this->crewFactory = new CrewFactory();
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
if (!$data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tvEpisode = new Episode();
|
||||||
|
|
||||||
|
if (array_key_exists('credits', $data)) {
|
||||||
|
if (array_key_exists('cast', $data['credits'])) {
|
||||||
|
$tvEpisode->getCredits()->setCast(
|
||||||
|
$this->getCastFactory()->createCollection($data['credits']['cast'],
|
||||||
|
new CastMember())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('crew', $data['credits'])) {
|
||||||
|
$tvEpisode->getCredits()->setCrew(
|
||||||
|
$this->getCrewFactory()->createCollection($data['credits']['crew'],
|
||||||
|
new CrewMember())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** External ids */
|
||||||
|
if (array_key_exists('external_ids', $data)) {
|
||||||
|
$tvEpisode->setExternalIds(
|
||||||
|
$this->hydrate(new ExternalIds(), $data['external_ids'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Images */
|
||||||
|
if (array_key_exists('images', $data)) {
|
||||||
|
$tvEpisode->setImages($this->getImageFactory()->createCollectionFromTvEpisode($data['images']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('still_path', $data)) {
|
||||||
|
$tvEpisode->setStillImage($this->getImageFactory()->createFromPath($data['still_path'], 'still_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($tvEpisode, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCastFactory($castFactory)
|
||||||
|
{
|
||||||
|
$this->castFactory = $castFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\People\CastFactory
|
||||||
|
*/
|
||||||
|
public function getCastFactory()
|
||||||
|
{
|
||||||
|
return $this->castFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCrewFactory($crewFactory)
|
||||||
|
{
|
||||||
|
$this->crewFactory = $crewFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\People\CrewFactory
|
||||||
|
*/
|
||||||
|
public function getCrewFactory()
|
||||||
|
{
|
||||||
|
return $this->crewFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
}
|
263
modules/Tmdb/Factory/TvFactory.php
Normal file
263
modules/Tmdb/Factory/TvFactory.php
Normal file
|
@ -0,0 +1,263 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Factory\People\CastFactory;
|
||||||
|
use Tmdb\Factory\People\CrewFactory;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Common\Translation;
|
||||||
|
use Tmdb\Model\Person\CastMember;
|
||||||
|
use Tmdb\Model\Person\CrewMember;
|
||||||
|
use Tmdb\Model\Common\ExternalIds;
|
||||||
|
use Tmdb\Model\Tv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TvFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class TvFactory extends AbstractFactory {
|
||||||
|
/**
|
||||||
|
* @var People\CastFactory
|
||||||
|
*/
|
||||||
|
private $castFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var People\CrewFactory
|
||||||
|
*/
|
||||||
|
private $crewFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var GenreFactory
|
||||||
|
*/
|
||||||
|
private $genreFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ImageFactory
|
||||||
|
*/
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TvSeasonFactory
|
||||||
|
*/
|
||||||
|
private $tvSeasonFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var NetworkFactory
|
||||||
|
*/
|
||||||
|
private $networkFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->castFactory = new CastFactory();
|
||||||
|
$this->crewFactory = new CrewFactory();
|
||||||
|
$this->genreFactory = new GenreFactory();
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
$this->tvSeasonFactory = new TvSeasonFactory();
|
||||||
|
$this->networkFactory = new NetworkFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Tv
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
if (!$data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tvShow = new Tv();
|
||||||
|
|
||||||
|
if (array_key_exists('credits', $data)) {
|
||||||
|
if (array_key_exists('cast', $data['credits'])) {
|
||||||
|
$tvShow->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new CastMember()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('crew', $data['credits'])) {
|
||||||
|
$tvShow->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new CrewMember()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** External ids */
|
||||||
|
if (array_key_exists('external_ids', $data)) {
|
||||||
|
$tvShow->setExternalIds(
|
||||||
|
$this->hydrate(new ExternalIds(), $data['external_ids'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Genres */
|
||||||
|
if (array_key_exists('genres', $data)) {
|
||||||
|
$tvShow->setGenres($this->getGenreFactory()->createCollection($data['genres']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Images */
|
||||||
|
if (array_key_exists('images', $data)) {
|
||||||
|
$tvShow->setImages($this->getImageFactory()->createCollectionFromTv($data['images']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('backdrop_path', $data)) {
|
||||||
|
$tvShow->setBackdropImage($this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('poster_path', $data)) {
|
||||||
|
$tvShow->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Translations */
|
||||||
|
if (array_key_exists('translations', $data) && null !== $data['translations']) {
|
||||||
|
$tvShow->setTranslations($this->createGenericCollection($data['translations']['translations'], new Translation()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Seasons */
|
||||||
|
if (array_key_exists('seasons', $data)) {
|
||||||
|
$tvShow->setSeasons($this->getTvSeasonFactory()->createCollection($data['seasons']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Networks */
|
||||||
|
if (array_key_exists('networks', $data)) {
|
||||||
|
$tvShow->setNetworks($this->getNetworkFactory()->createCollection($data['networks']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($tvShow, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
if (array_key_exists('results', $data)) {
|
||||||
|
$data = $data['results'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCastFactory($castFactory)
|
||||||
|
{
|
||||||
|
$this->castFactory = $castFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\People\CastFactory
|
||||||
|
*/
|
||||||
|
public function getCastFactory()
|
||||||
|
{
|
||||||
|
return $this->castFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCrewFactory($crewFactory)
|
||||||
|
{
|
||||||
|
$this->crewFactory = $crewFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\People\CrewFactory
|
||||||
|
*/
|
||||||
|
public function getCrewFactory()
|
||||||
|
{
|
||||||
|
return $this->crewFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\GenreFactory $genreFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setGenreFactory($genreFactory)
|
||||||
|
{
|
||||||
|
$this->genreFactory = $genreFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\GenreFactory
|
||||||
|
*/
|
||||||
|
public function getGenreFactory()
|
||||||
|
{
|
||||||
|
return $this->genreFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\TvSeasonFactory $tvSeasonFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTvSeasonFactory($tvSeasonFactory)
|
||||||
|
{
|
||||||
|
$this->tvSeasonFactory = $tvSeasonFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\TvSeasonFactory
|
||||||
|
*/
|
||||||
|
public function getTvSeasonFactory()
|
||||||
|
{
|
||||||
|
return $this->tvSeasonFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\NetworkFactory $networkFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setNetworkFactory($networkFactory)
|
||||||
|
{
|
||||||
|
$this->networkFactory = $networkFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\NetworkFactory
|
||||||
|
*/
|
||||||
|
public function getNetworkFactory()
|
||||||
|
{
|
||||||
|
return $this->networkFactory;
|
||||||
|
}
|
||||||
|
}
|
189
modules/Tmdb/Factory/TvSeasonFactory.php
Normal file
189
modules/Tmdb/Factory/TvSeasonFactory.php
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Factory;
|
||||||
|
|
||||||
|
use Tmdb\Factory\People\CastFactory;
|
||||||
|
use Tmdb\Factory\People\CrewFactory;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Person\CastMember;
|
||||||
|
use Tmdb\Model\Person\CrewMember;
|
||||||
|
use Tmdb\Model\Common\ExternalIds;
|
||||||
|
use Tmdb\Model\Tv\Season;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TvSeasonFactory
|
||||||
|
* @package Tmdb\Factory
|
||||||
|
*/
|
||||||
|
class TvSeasonFactory extends AbstractFactory {
|
||||||
|
/**
|
||||||
|
* @var People\CastFactory
|
||||||
|
*/
|
||||||
|
private $castFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var People\CrewFactory
|
||||||
|
*/
|
||||||
|
private $crewFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ImageFactory
|
||||||
|
*/
|
||||||
|
private $imageFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TvEpisodeFactory
|
||||||
|
*/
|
||||||
|
private $tvEpisodeFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->castFactory = new CastFactory();
|
||||||
|
$this->crewFactory = new CrewFactory();
|
||||||
|
$this->imageFactory = new ImageFactory();
|
||||||
|
$this->tvEpisodeFactory = new TvEpisodeFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function create(array $data = array())
|
||||||
|
{
|
||||||
|
if (!$data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tvSeason = new Season();
|
||||||
|
|
||||||
|
if (array_key_exists('credits', $data)) {
|
||||||
|
if (array_key_exists('cast', $data['credits'])) {
|
||||||
|
$tvSeason->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new CastMember()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('crew', $data['credits'])) {
|
||||||
|
$tvSeason->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new CrewMember()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** External ids */
|
||||||
|
if (array_key_exists('external_ids', $data)) {
|
||||||
|
$tvSeason->setExternalIds(
|
||||||
|
$this->hydrate(new ExternalIds(), $data['external_ids'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Images */
|
||||||
|
if (array_key_exists('images', $data)) {
|
||||||
|
$tvSeason->setImages($this->getImageFactory()->createCollectionFromTvSeason($data['images']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('poster_path', $data)) {
|
||||||
|
$tvSeason->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Episodes */
|
||||||
|
if (array_key_exists('episodes', $data)) {
|
||||||
|
$tvSeason->setEpisodes($this->getTvEpisodeFactory()->createCollection($data['episodes']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hydrate($tvSeason, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCollection(array $data = array())
|
||||||
|
{
|
||||||
|
$collection = new GenericCollection();
|
||||||
|
|
||||||
|
foreach($data as $item) {
|
||||||
|
$collection->add(null, $this->create($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\People\CastFactory $castFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCastFactory($castFactory)
|
||||||
|
{
|
||||||
|
$this->castFactory = $castFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\People\CastFactory
|
||||||
|
*/
|
||||||
|
public function getCastFactory()
|
||||||
|
{
|
||||||
|
return $this->castFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\People\CrewFactory $crewFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCrewFactory($crewFactory)
|
||||||
|
{
|
||||||
|
$this->crewFactory = $crewFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\People\CrewFactory
|
||||||
|
*/
|
||||||
|
public function getCrewFactory()
|
||||||
|
{
|
||||||
|
return $this->crewFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\ImageFactory $imageFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageFactory($imageFactory)
|
||||||
|
{
|
||||||
|
$this->imageFactory = $imageFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\ImageFactory
|
||||||
|
*/
|
||||||
|
public function getImageFactory()
|
||||||
|
{
|
||||||
|
return $this->imageFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Factory\TvEpisodeFactory $tvEpisodeFactory
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTvEpisodeFactory($tvEpisodeFactory)
|
||||||
|
{
|
||||||
|
$this->tvEpisodeFactory = $tvEpisodeFactory;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Factory\TvEpisodeFactory
|
||||||
|
*/
|
||||||
|
public function getTvEpisodeFactory()
|
||||||
|
{
|
||||||
|
return $this->tvEpisodeFactory;
|
||||||
|
}
|
||||||
|
}
|
93
modules/Tmdb/Helper/ImageHelper.php
Normal file
93
modules/Tmdb/Helper/ImageHelper.php
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Helper;
|
||||||
|
|
||||||
|
use Tmdb\Model\Configuration;
|
||||||
|
use Tmdb\Model\Image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ImageHelper
|
||||||
|
* @package Tmdb\Helper
|
||||||
|
*/
|
||||||
|
class ImageHelper {
|
||||||
|
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
public function __construct(Configuration $config)
|
||||||
|
{
|
||||||
|
$this->config = $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the image configuration collection
|
||||||
|
*
|
||||||
|
* @return \Tmdb\Model\Common\GenericCollection
|
||||||
|
*/
|
||||||
|
public function getImageConfiguration()
|
||||||
|
{
|
||||||
|
return $this->config->getImages();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the url for the image resource
|
||||||
|
*
|
||||||
|
* @param Image $image
|
||||||
|
* @param string $size
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUrl(Image $image, $size = 'original') {
|
||||||
|
$config = $this->getImageConfiguration();
|
||||||
|
|
||||||
|
return $config['base_url'] . $size . $image->getFilePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an img html tag for the image in the specified size
|
||||||
|
*
|
||||||
|
* @param Image $image
|
||||||
|
* @param string $size
|
||||||
|
* @param int|null $width
|
||||||
|
* @param int|null $height
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getHtml(Image $image, $size = 'original', $width = null, $height = null) {
|
||||||
|
if (null == $image->getFilePath()) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$aspectRatio = $image->getAspectRatio();
|
||||||
|
|
||||||
|
if (null !== $width && null == $height && $aspectRatio !== null) {
|
||||||
|
$height = round($width / $aspectRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $height && null == $width && $aspectRatio !== null) {
|
||||||
|
$width = round($height * $aspectRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == $width) {
|
||||||
|
$width = $image->getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == $height) {
|
||||||
|
$height = $image->getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'<img src="%s" width="%s" height="%s" />',
|
||||||
|
$this->getUrl($image, $size),
|
||||||
|
$width,
|
||||||
|
$height
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
204
modules/Tmdb/HttpClient/HttpClient.php
Normal file
204
modules/Tmdb/HttpClient/HttpClient.php
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\HttpClient;
|
||||||
|
|
||||||
|
use Guzzle\Http\ClientInterface;
|
||||||
|
use Guzzle\Http\Message\Request;
|
||||||
|
use Guzzle\Http\Message\RequestInterface;
|
||||||
|
use Guzzle\Http\Message\Response;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class HttpClient
|
||||||
|
* @package Tmdb\HttpClient
|
||||||
|
*/
|
||||||
|
class HttpClient
|
||||||
|
implements HttpClientInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Guzzle\Http\ClientInterface
|
||||||
|
*/
|
||||||
|
private $client;
|
||||||
|
|
||||||
|
protected $options = array();
|
||||||
|
protected $base_url = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Response
|
||||||
|
*/
|
||||||
|
private $lastResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Request
|
||||||
|
*/
|
||||||
|
private $lastRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string $baseUrl
|
||||||
|
* @param array $options
|
||||||
|
* @param ClientInterface $client
|
||||||
|
*/
|
||||||
|
public function __construct($baseUrl, array $options, ClientInterface $client)
|
||||||
|
{
|
||||||
|
$this->base_url = $baseUrl;
|
||||||
|
$this->options = $options;
|
||||||
|
$this->client = $client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a subscriber
|
||||||
|
*
|
||||||
|
* @param EventSubscriberInterface $subscriber
|
||||||
|
*/
|
||||||
|
public function addSubscriber(EventSubscriberInterface $subscriber)
|
||||||
|
{
|
||||||
|
$this->client->addSubscriber($subscriber);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the query parameters
|
||||||
|
*
|
||||||
|
* @param $queryParameters
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function buildQueryParameters($queryParameters)
|
||||||
|
{
|
||||||
|
return array_merge($this->options, array('query' => $queryParameters));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get($path, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
$parameters = $this->buildQueryParameters($parameters);
|
||||||
|
|
||||||
|
return $this->request(
|
||||||
|
$this->client->get($path, $headers, $parameters)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function head($path, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
$parameters = $this->buildQueryParameters($parameters);
|
||||||
|
|
||||||
|
return $this->request(
|
||||||
|
$this->client->head($path, $headers, $parameters)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function post($path, $postBody, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
$parameters = $this->buildQueryParameters($parameters);
|
||||||
|
|
||||||
|
return $this->request(
|
||||||
|
$this->client->post($path, $headers, $postBody, $parameters)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function postJson($path, $postBody, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
$parameters = $this->buildQueryParameters($parameters);
|
||||||
|
$request = $this->client->post($path, $headers, null, $parameters);
|
||||||
|
$request->setBody($postBody, 'application/json');
|
||||||
|
|
||||||
|
return $this->request($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function patch($path, $body = null, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
$parameters = $this->buildQueryParameters($parameters);
|
||||||
|
|
||||||
|
return $this->request(
|
||||||
|
$this->client->patch($path, $headers, $body, $parameters)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function delete($path, $body = null, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
$parameters = $this->buildQueryParameters($parameters);
|
||||||
|
|
||||||
|
return $this->request(
|
||||||
|
$this->client->delete($path, $headers, $body, $parameters)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function put($path, $body = null, array $parameters = array(), array $headers = array())
|
||||||
|
{
|
||||||
|
$parameters = $this->buildQueryParameters($parameters);
|
||||||
|
|
||||||
|
return $this->request(
|
||||||
|
$this->client->put($path, $headers, $body, $parameters)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @{inheritDoc}
|
||||||
|
*/
|
||||||
|
public function request(RequestInterface $request)
|
||||||
|
{
|
||||||
|
$response = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $request->send();
|
||||||
|
}
|
||||||
|
catch(\Exception $e)
|
||||||
|
{
|
||||||
|
// @TODO catch any API errors / timeouts / other specific information from Guzzle?
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->lastRequest = $request;
|
||||||
|
$this->lastResponse = $response;
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Guzzle\Http\ClientInterface $client
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setClient($client)
|
||||||
|
{
|
||||||
|
$this->client = $client;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Guzzle\Http\ClientInterface
|
||||||
|
*/
|
||||||
|
public function getClient()
|
||||||
|
{
|
||||||
|
return $this->client;
|
||||||
|
}
|
||||||
|
}
|
103
modules/Tmdb/HttpClient/HttpClientInterface.php
Normal file
103
modules/Tmdb/HttpClient/HttpClientInterface.php
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\HttpClient;
|
||||||
|
|
||||||
|
use Guzzle\Http\Message\RequestInterface;
|
||||||
|
use Guzzle\Http\Message\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface HttpClientInterface
|
||||||
|
* @package Tmdb\HttpClient
|
||||||
|
*/
|
||||||
|
interface HttpClientInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Compose a GET request
|
||||||
|
*
|
||||||
|
* @param string $path Request path
|
||||||
|
* @param array $parameters GET Parameters
|
||||||
|
* @param array $headers Reconfigure the request headers for this call only
|
||||||
|
*
|
||||||
|
* @return Response Data
|
||||||
|
*/
|
||||||
|
public function get($path, array $parameters = array(), array $headers = array());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compose a POST request
|
||||||
|
*
|
||||||
|
* @param string $path Request path
|
||||||
|
* @param string $postBody The post BODY
|
||||||
|
* @param array $parameters POST Parameters
|
||||||
|
* @param array $headers Reconfigure the request headers for this call only
|
||||||
|
*
|
||||||
|
* @return Response Data
|
||||||
|
*/
|
||||||
|
public function post($path, $postBody, array $parameters = array(), array $headers = array());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compose a POST request but json_encode the body
|
||||||
|
*
|
||||||
|
* @param string $path Request path
|
||||||
|
* @param array $postBody The post BODY
|
||||||
|
* @param array $parameters POST Parameters
|
||||||
|
* @param array $headers Reconfigure the request headers for this call only
|
||||||
|
*
|
||||||
|
* @return Response Data
|
||||||
|
*/
|
||||||
|
public function postJson($path, $postBody, array $parameters = array(), array $headers = array());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compose a PATCH request
|
||||||
|
*
|
||||||
|
* @param string $path Request path
|
||||||
|
* @param string $body The body
|
||||||
|
* @param array $parameters PATCH Parameters
|
||||||
|
* @param array $headers Reconfigure the request headers for this call only
|
||||||
|
*
|
||||||
|
* @return Response Data
|
||||||
|
*/
|
||||||
|
public function patch($path, $body = null, array $parameters = array(), array $headers = array());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compose a PUT request
|
||||||
|
*
|
||||||
|
* @param string $path Request path
|
||||||
|
* @param string $body The body
|
||||||
|
* @param array $parameters PUT Parameters
|
||||||
|
* @param array $headers Reconfigure the request headers for this call only
|
||||||
|
*
|
||||||
|
* @return Response Data
|
||||||
|
*/
|
||||||
|
public function put($path, $body = null, array $parameters = array(), array $headers = array());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compose a DELETE request
|
||||||
|
*
|
||||||
|
* @param string $path Request path
|
||||||
|
* @param string $body The body
|
||||||
|
* @param array $parameters DELETE Parameters
|
||||||
|
* @param array $headers Reconfigure the request headers for this call only
|
||||||
|
*
|
||||||
|
* @return Response Data
|
||||||
|
*/
|
||||||
|
public function delete($path, $body = null, array $parameters = array(), array $headers = array());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a request to the server, receive a response,
|
||||||
|
* decode the response and returns an associative array
|
||||||
|
* @param $request RequestInterface
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function request(RequestInterface $request);
|
||||||
|
|
||||||
|
}
|
33
modules/Tmdb/HttpClient/Plugin/AcceptJsonHeaderPlugin.php
Normal file
33
modules/Tmdb/HttpClient/Plugin/AcceptJsonHeaderPlugin.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\HttpClient\Plugin;
|
||||||
|
|
||||||
|
use Guzzle\Common\Event;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AcceptJsonHeaderPlugin
|
||||||
|
* @package Tmdb\HttpClient\Plugin
|
||||||
|
*/
|
||||||
|
class AcceptJsonHeaderPlugin implements EventSubscriberInterface
|
||||||
|
{
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return array('request.before_send' => 'onBeforeSend');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBeforeSend(Event $event)
|
||||||
|
{
|
||||||
|
$event['request']->setHeader('accept', 'application/json');
|
||||||
|
}
|
||||||
|
}
|
44
modules/Tmdb/HttpClient/Plugin/AdultFilterPlugin.php
Normal file
44
modules/Tmdb/HttpClient/Plugin/AdultFilterPlugin.php
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\HttpClient\Plugin;
|
||||||
|
|
||||||
|
use Guzzle\Common\Event;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AdultFilterPlugin
|
||||||
|
* @package Tmdb\HttpClient\Plugin
|
||||||
|
*/
|
||||||
|
class AdultFilterPlugin implements EventSubscriberInterface
|
||||||
|
{
|
||||||
|
private $includeAdult;
|
||||||
|
|
||||||
|
public function __construct($includeAdult = false)
|
||||||
|
{
|
||||||
|
$this->includeAdult = $includeAdult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return array('request.before_send' => 'onBeforeSend');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBeforeSend(Event $event)
|
||||||
|
{
|
||||||
|
$url = $event['request']->getUrl(true);
|
||||||
|
|
||||||
|
$url->getQuery()->set('include_adult', $this->includeAdult === true ? 'true' : 'false');
|
||||||
|
|
||||||
|
$event['request']->setUrl($url);
|
||||||
|
}
|
||||||
|
}
|
48
modules/Tmdb/HttpClient/Plugin/ApiTokenPlugin.php
Normal file
48
modules/Tmdb/HttpClient/Plugin/ApiTokenPlugin.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\HttpClient\Plugin;
|
||||||
|
|
||||||
|
use Guzzle\Common\Event;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
use Tmdb\ApiToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ApiTokenPlugin
|
||||||
|
* @package Tmdb\HttpClient\Plugin
|
||||||
|
*/
|
||||||
|
class ApiTokenPlugin implements EventSubscriberInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Tmdb\ApiToken
|
||||||
|
*/
|
||||||
|
private $token;
|
||||||
|
|
||||||
|
public function __construct(ApiToken $token)
|
||||||
|
{
|
||||||
|
$this->token = $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return array('request.before_send' => 'onBeforeSend');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBeforeSend(Event $event)
|
||||||
|
{
|
||||||
|
$url = $event['request']->getUrl(true);
|
||||||
|
|
||||||
|
$url->getQuery()->set('api_key', $this->token->getToken());
|
||||||
|
|
||||||
|
$event['request']->setUrl($url);
|
||||||
|
}
|
||||||
|
}
|
44
modules/Tmdb/HttpClient/Plugin/LanguageFilterPlugin.php
Normal file
44
modules/Tmdb/HttpClient/Plugin/LanguageFilterPlugin.php
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\HttpClient\Plugin;
|
||||||
|
|
||||||
|
use Guzzle\Common\Event;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class LanguageFilterPlugin
|
||||||
|
* @package Tmdb\HttpClient\Plugin
|
||||||
|
*/
|
||||||
|
class LanguageFilterPlugin implements EventSubscriberInterface
|
||||||
|
{
|
||||||
|
private $language;
|
||||||
|
|
||||||
|
public function __construct($language = 'en')
|
||||||
|
{
|
||||||
|
$this->language = $language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return array('request.before_send' => 'onBeforeSend');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBeforeSend(Event $event)
|
||||||
|
{
|
||||||
|
$url = $event['request']->getUrl(true);
|
||||||
|
|
||||||
|
$url->getQuery()->set('language', $this->language);
|
||||||
|
|
||||||
|
$event['request']->setUrl($url);
|
||||||
|
}
|
||||||
|
}
|
48
modules/Tmdb/HttpClient/Plugin/SessionTokenPlugin.php
Normal file
48
modules/Tmdb/HttpClient/Plugin/SessionTokenPlugin.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\HttpClient\Plugin;
|
||||||
|
|
||||||
|
use Guzzle\Common\Event;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
use Tmdb\SessionToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class SessionTokenPlugin
|
||||||
|
* @package Tmdb\HttpClient\Plugin
|
||||||
|
*/
|
||||||
|
class SessionTokenPlugin implements EventSubscriberInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Tmdb\ApiToken
|
||||||
|
*/
|
||||||
|
private $token;
|
||||||
|
|
||||||
|
public function __construct(SessionToken $token)
|
||||||
|
{
|
||||||
|
$this->token = $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return array('request.before_send' => 'onBeforeSend');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBeforeSend(Event $event)
|
||||||
|
{
|
||||||
|
$url = $event['request']->getUrl(true);
|
||||||
|
|
||||||
|
$url->getQuery()->set('session_id', $this->token->getToken());
|
||||||
|
|
||||||
|
$event['request']->setUrl($url);
|
||||||
|
}
|
||||||
|
}
|
27
modules/Tmdb/Model/AbstractModel.php
Normal file
27
modules/Tmdb/Model/AbstractModel.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AbstractModel
|
||||||
|
* @package Tmdb\Model
|
||||||
|
*/
|
||||||
|
class AbstractModel {
|
||||||
|
/**
|
||||||
|
* List of properties to populate by the ObjectHydrator
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $_properties = array();
|
||||||
|
|
||||||
|
}
|
171
modules/Tmdb/Model/Account.php
Normal file
171
modules/Tmdb/Model/Account.php
Normal file
|
@ -0,0 +1,171 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Account
|
||||||
|
* @package Tmdb\Model
|
||||||
|
*/
|
||||||
|
class Account extends AbstractModel {
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $includeAdult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $iso31661;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $iso6391;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $_properties = array(
|
||||||
|
'id',
|
||||||
|
'include_adult',
|
||||||
|
'iso_3166_1',
|
||||||
|
'iso_639_1',
|
||||||
|
'name',
|
||||||
|
'username'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param boolean $includeAdult
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setIncludeAdult($includeAdult)
|
||||||
|
{
|
||||||
|
$this->includeAdult = $includeAdult;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function getIncludeAdult()
|
||||||
|
{
|
||||||
|
return $this->includeAdult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $iso31661
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setIso31661($iso31661)
|
||||||
|
{
|
||||||
|
$this->iso31661 = $iso31661;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getIso31661()
|
||||||
|
{
|
||||||
|
return $this->iso31661;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $iso6391
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setIso6391($iso6391)
|
||||||
|
{
|
||||||
|
$this->iso6391 = $iso6391;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getIso6391()
|
||||||
|
{
|
||||||
|
return $this->iso6391;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $username
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setUsername($username)
|
||||||
|
{
|
||||||
|
$this->username = $username;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUsername()
|
||||||
|
{
|
||||||
|
return $this->username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
243
modules/Tmdb/Model/Account/ListItem.php
Normal file
243
modules/Tmdb/Model/Account/ListItem.php
Normal file
|
@ -0,0 +1,243 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Account;
|
||||||
|
|
||||||
|
use Tmdb\Model\AbstractModel;
|
||||||
|
use Tmdb\Model\Image\PosterImage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ListItem
|
||||||
|
* @package Tmdb\Model\Account
|
||||||
|
*/
|
||||||
|
class ListItem extends AbstractModel {
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $favoriteCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $itemCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $iso6391;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $listType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $posterPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PosterImage
|
||||||
|
*/
|
||||||
|
private $posterImage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $_properties = array(
|
||||||
|
'description',
|
||||||
|
'favorite_count',
|
||||||
|
'id',
|
||||||
|
'item_count',
|
||||||
|
'iso_639_1',
|
||||||
|
'list_type',
|
||||||
|
'name',
|
||||||
|
'poster_path'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $description
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setDescription($description)
|
||||||
|
{
|
||||||
|
$this->description = $description;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $favoriteCount
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setFavoriteCount($favoriteCount)
|
||||||
|
{
|
||||||
|
$this->favoriteCount = $favoriteCount;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getFavoriteCount()
|
||||||
|
{
|
||||||
|
return $this->favoriteCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $id
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $iso6391
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setIso6391($iso6391)
|
||||||
|
{
|
||||||
|
$this->iso6391 = $iso6391;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getIso6391()
|
||||||
|
{
|
||||||
|
return $this->iso6391;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $itemCount
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setItemCount($itemCount)
|
||||||
|
{
|
||||||
|
$this->itemCount = $itemCount;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getItemCount()
|
||||||
|
{
|
||||||
|
return $this->itemCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $listType
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setListType($listType)
|
||||||
|
{
|
||||||
|
$this->listType = $listType;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getListType()
|
||||||
|
{
|
||||||
|
return $this->listType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Model\Image\PosterImage $posterImage
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPosterImage($posterImage)
|
||||||
|
{
|
||||||
|
$this->posterImage = $posterImage;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Model\Image\PosterImage
|
||||||
|
*/
|
||||||
|
public function getPosterImage()
|
||||||
|
{
|
||||||
|
return $this->posterImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $posterPath
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPosterPath($posterPath)
|
||||||
|
{
|
||||||
|
$this->posterPath = $posterPath;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPosterPath()
|
||||||
|
{
|
||||||
|
return $this->posterPath;
|
||||||
|
}
|
||||||
|
}
|
77
modules/Tmdb/Model/Certification.php
Normal file
77
modules/Tmdb/Model/Certification.php
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model;
|
||||||
|
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Certification
|
||||||
|
* @package Tmdb\Model
|
||||||
|
*/
|
||||||
|
class Certification extends AbstractModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $country;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var GenericCollection
|
||||||
|
*/
|
||||||
|
private $certifications;
|
||||||
|
|
||||||
|
public static $_properties = array(
|
||||||
|
'country',
|
||||||
|
);
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->certifications = new GenericCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Model\Common\GenericCollection $certifications
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCertifications($certifications)
|
||||||
|
{
|
||||||
|
$this->certifications = $certifications;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Model\Common\GenericCollection
|
||||||
|
*/
|
||||||
|
public function getCertifications()
|
||||||
|
{
|
||||||
|
return $this->certifications;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $country
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCountry($country)
|
||||||
|
{
|
||||||
|
$this->country = $country;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCountry()
|
||||||
|
{
|
||||||
|
return $this->country;
|
||||||
|
}
|
||||||
|
}
|
99
modules/Tmdb/Model/Certification/CountryCertification.php
Normal file
99
modules/Tmdb/Model/Certification/CountryCertification.php
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Certification;
|
||||||
|
|
||||||
|
use Tmdb\Model\AbstractModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CountryCertification
|
||||||
|
* @package Tmdb\Model\Certification
|
||||||
|
*/
|
||||||
|
class CountryCertification extends AbstractModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $certification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $meaning;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
private $order;
|
||||||
|
|
||||||
|
public static $_properties = array(
|
||||||
|
'certification',
|
||||||
|
'meaning',
|
||||||
|
'order',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $certification
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCertification($certification)
|
||||||
|
{
|
||||||
|
$this->certification = $certification;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCertification()
|
||||||
|
{
|
||||||
|
return $this->certification;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $meaning
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setMeaning($meaning)
|
||||||
|
{
|
||||||
|
$this->meaning = $meaning;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMeaning()
|
||||||
|
{
|
||||||
|
return $this->meaning;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $order
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setOrder($order)
|
||||||
|
{
|
||||||
|
$this->order = $order;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getOrder()
|
||||||
|
{
|
||||||
|
return $this->order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
73
modules/Tmdb/Model/Change.php
Normal file
73
modules/Tmdb/Model/Change.php
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Change
|
||||||
|
* @package Tmdb\Model
|
||||||
|
*/
|
||||||
|
class Change extends AbstractModel {
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $adult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $_properties = array(
|
||||||
|
'id',
|
||||||
|
'adult'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param boolean $adult
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setAdult($adult)
|
||||||
|
{
|
||||||
|
$this->adult = (bool) $adult;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function getAdult()
|
||||||
|
{
|
||||||
|
return $this->adult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = (int) $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
}
|
246
modules/Tmdb/Model/Collection.php
Normal file
246
modules/Tmdb/Model/Collection.php
Normal file
|
@ -0,0 +1,246 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\Images;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Image\BackdropImage;
|
||||||
|
use Tmdb\Model\Image\PosterImage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Collection
|
||||||
|
* @package Tmdb\Model
|
||||||
|
*/
|
||||||
|
class Collection extends AbstractModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $backdropPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var BackdropImage
|
||||||
|
*/
|
||||||
|
private $backdrop;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Images
|
||||||
|
*/
|
||||||
|
private $images;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $overview;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Common\GenericCollection
|
||||||
|
*/
|
||||||
|
private $parts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $posterPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PosterImage
|
||||||
|
*/
|
||||||
|
private $poster;
|
||||||
|
|
||||||
|
public static $_properties = array(
|
||||||
|
'backdrop_path',
|
||||||
|
'id',
|
||||||
|
'name',
|
||||||
|
'overview',
|
||||||
|
'poster_path',
|
||||||
|
);
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->parts = new GenericCollection();
|
||||||
|
$this->images = new Images();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Model\Image\BackdropImage $backdrop
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setBackdropImage(BackdropImage $backdrop)
|
||||||
|
{
|
||||||
|
$this->backdrop = $backdrop;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Model\Image\BackdropImage
|
||||||
|
*/
|
||||||
|
public function getBackdropImage()
|
||||||
|
{
|
||||||
|
return $this->backdrop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $backdropPath
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setBackdropPath($backdropPath)
|
||||||
|
{
|
||||||
|
$this->backdropPath = $backdropPath;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBackdropPath()
|
||||||
|
{
|
||||||
|
return $this->backdropPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = (int) $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Model\Collection\Images $images
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImages(Images $images)
|
||||||
|
{
|
||||||
|
$this->images = $images;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Model\Collection\Images
|
||||||
|
*/
|
||||||
|
public function getImages()
|
||||||
|
{
|
||||||
|
return $this->images;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $overview
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setOverview($overview)
|
||||||
|
{
|
||||||
|
$this->overview = $overview;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getOverview()
|
||||||
|
{
|
||||||
|
return $this->overview;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param GenericCollection $parts
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setParts($parts)
|
||||||
|
{
|
||||||
|
$this->parts = $parts;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function getParts()
|
||||||
|
{
|
||||||
|
return $this->parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Model\Image\PosterImage $poster
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPosterImage(PosterImage $poster)
|
||||||
|
{
|
||||||
|
$this->poster = $poster;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Model\Image\PosterImage
|
||||||
|
*/
|
||||||
|
public function getPosterImage()
|
||||||
|
{
|
||||||
|
return $this->poster;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $posterPath
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPosterPath($posterPath)
|
||||||
|
{
|
||||||
|
$this->posterPath = $posterPath;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPosterPath()
|
||||||
|
{
|
||||||
|
return $this->posterPath;
|
||||||
|
}
|
||||||
|
}
|
19
modules/Tmdb/Model/Collection/Changes.php
Normal file
19
modules/Tmdb/Model/Collection/Changes.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Changes
|
||||||
|
* @package Tmdb\Model\Collection
|
||||||
|
*/
|
||||||
|
class Changes extends ResultCollection {}
|
78
modules/Tmdb/Model/Collection/CreditsCollection.php
Normal file
78
modules/Tmdb/Model/Collection/CreditsCollection.php
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\People\Cast;
|
||||||
|
use Tmdb\Model\Collection\People\Crew;
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CreditsCollection
|
||||||
|
* @package Tmdb\Model\Collection
|
||||||
|
*/
|
||||||
|
class CreditsCollection {
|
||||||
|
/**
|
||||||
|
* @var Cast
|
||||||
|
*/
|
||||||
|
public $cast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Crew
|
||||||
|
*/
|
||||||
|
private $crew;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->cast = new Cast();
|
||||||
|
$this->crew = new Crew();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Cast|GenericCollection $cast
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCast(GenericCollection $cast)
|
||||||
|
{
|
||||||
|
$this->cast = $cast;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Cast
|
||||||
|
*/
|
||||||
|
public function getCast()
|
||||||
|
{
|
||||||
|
return $this->cast;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Crew|GenericCollection $crew
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCrew(GenericCollection $crew)
|
||||||
|
{
|
||||||
|
$this->crew = $crew;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Crew
|
||||||
|
*/
|
||||||
|
public function getCrew()
|
||||||
|
{
|
||||||
|
return $this->crew;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection\CreditsCollection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\CreditsCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CombinedCredits
|
||||||
|
* @package Tmdb\Model\Collection\CreditsCollection
|
||||||
|
*/
|
||||||
|
class CombinedCredits extends CreditsCollection {}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection\CreditsCollection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\CreditsCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MovieCredits
|
||||||
|
* @package Tmdb\Model\Collection\CreditsCollection
|
||||||
|
*/
|
||||||
|
class MovieCredits extends CreditsCollection {}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection\CreditsCollection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\CreditsCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TvCredits
|
||||||
|
* @package Tmdb\Model\Collection\CreditsCollection
|
||||||
|
*/
|
||||||
|
class TvCredits extends CreditsCollection {}
|
59
modules/Tmdb/Model/Collection/Genres.php
Normal file
59
modules/Tmdb/Model/Collection/Genres.php
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Genre;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Genres
|
||||||
|
* @package Tmdb\Model\Collection
|
||||||
|
*/
|
||||||
|
class Genres extends GenericCollection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all genres
|
||||||
|
*
|
||||||
|
* @return Genre[]
|
||||||
|
*/
|
||||||
|
public function getGenres()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a genre from the collection
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
* @return Genre|null
|
||||||
|
*/
|
||||||
|
public function getGenre($id) {
|
||||||
|
foreach($this->data as $genre) {
|
||||||
|
if ($id === $genre->getId()) {
|
||||||
|
return $genre;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a genre to the collection
|
||||||
|
*
|
||||||
|
* @param Genre $genre
|
||||||
|
*/
|
||||||
|
public function addGenre(Genre $genre)
|
||||||
|
{
|
||||||
|
$this->data[] = $genre;
|
||||||
|
}
|
||||||
|
}
|
193
modules/Tmdb/Model/Collection/Images.php
Normal file
193
modules/Tmdb/Model/Collection/Images.php
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Filter\ImageFilter;
|
||||||
|
use Tmdb\Model\Image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Images
|
||||||
|
* @package Tmdb\Model\Collection
|
||||||
|
*/
|
||||||
|
class Images extends GenericCollection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all images
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getImages()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a image from the collection
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function getImage($id) {
|
||||||
|
return $this->filterId($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a image to the collection
|
||||||
|
*
|
||||||
|
* @param Image $image
|
||||||
|
*/
|
||||||
|
public function addImage(Image $image)
|
||||||
|
{
|
||||||
|
$this->add(null, $image);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter poster images
|
||||||
|
*
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function filterPosters()
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) {
|
||||||
|
if ($value instanceof ImageFilter && $value instanceof Image\PosterImage) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter backdrop images
|
||||||
|
*
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function filterBackdrops()
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) {
|
||||||
|
if ($value instanceof ImageFilter && $value instanceof Image\BackdropImage) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter profile images
|
||||||
|
*
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function filterProfile()
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) {
|
||||||
|
if ($value instanceof ImageFilter && $value instanceof Image\ProfileImage) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter still images
|
||||||
|
*
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function filterStills()
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) {
|
||||||
|
if ($value instanceof ImageFilter && $value instanceof Image\StillImage) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by image size
|
||||||
|
*
|
||||||
|
* @param $width
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function filterMaxWidth($width)
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) use ($width) {
|
||||||
|
if ($value instanceof ImageFilter && $value->getWidth() <= $width && $value->getWidth() !== null) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by image size
|
||||||
|
*
|
||||||
|
* @param $width
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function filterMinWidth($width)
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) use ($width) {
|
||||||
|
if ($value instanceof ImageFilter && $value->getWidth() >= $width && $value->getWidth() !== null) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by image size
|
||||||
|
*
|
||||||
|
* @param $height
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function filterMaxHeight($height)
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) use ($height) {
|
||||||
|
if ($value instanceof ImageFilter && $value->getHeight() <= $height && $value->getHeight() !== null) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by image size
|
||||||
|
*
|
||||||
|
* @param $height
|
||||||
|
* @return Images
|
||||||
|
*/
|
||||||
|
public function filterMinHeight($height)
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) use ($height) {
|
||||||
|
if ($value instanceof ImageFilter && $value->getHeight() >= $height && $value->getHeight() !== null) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a single image that is rated highest
|
||||||
|
*
|
||||||
|
* @return ImageFilter|null
|
||||||
|
*/
|
||||||
|
public function filterBestVotedImage()
|
||||||
|
{
|
||||||
|
$currentImage = null;
|
||||||
|
$voteAverage = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var $image Image
|
||||||
|
*/
|
||||||
|
foreach($this->data as $image) {
|
||||||
|
if ($image->getVoteAverage() > $voteAverage) {
|
||||||
|
$voteAverage = $image->getVoteAverage();
|
||||||
|
$currentImage = $image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $currentImage;
|
||||||
|
}
|
||||||
|
}
|
94
modules/Tmdb/Model/Collection/Jobs.php
Normal file
94
modules/Tmdb/Model/Collection/Jobs.php
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Jobs
|
||||||
|
* @package Tmdb\Model\Collection
|
||||||
|
*/
|
||||||
|
class Jobs extends GenericCollection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by department
|
||||||
|
*
|
||||||
|
* @param string $department
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function filterByDepartment($department)
|
||||||
|
{
|
||||||
|
$result = $this->filter(
|
||||||
|
function($key, $value) use ($department) {
|
||||||
|
if ($value->getDepartment() == $department) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result && 1 === count($result)) {
|
||||||
|
$results = $result->toArray();
|
||||||
|
return array_shift($results);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by department and return the jobs collection
|
||||||
|
*
|
||||||
|
* @param string $department
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function filterByDepartmentAndReturnJobsList($department)
|
||||||
|
{
|
||||||
|
$result = $this->filter(
|
||||||
|
function($key, $value) use ($department) {
|
||||||
|
if ($value->getDepartment() == $department) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result && 1 === count($result)) {
|
||||||
|
$results = $result->toArray();
|
||||||
|
$data = array_shift($results);
|
||||||
|
|
||||||
|
return $data->getJobList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by job
|
||||||
|
*
|
||||||
|
* @param string $filterByJob
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function filterByJob($filterByJob)
|
||||||
|
{
|
||||||
|
$result = $this->filter(
|
||||||
|
function($key, $value) use ($filterByJob) {
|
||||||
|
$jobList = $value->getJobList();
|
||||||
|
|
||||||
|
foreach($jobList as $job) {
|
||||||
|
if ($filterByJob == $job) { return true; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result && 1 === count($result)) {
|
||||||
|
$results = $result->toArray();
|
||||||
|
return array_shift($results);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
53
modules/Tmdb/Model/Collection/Keywords.php
Normal file
53
modules/Tmdb/Model/Collection/Keywords.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Keyword;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Keywords
|
||||||
|
* @package Tmdb\Model\Collection
|
||||||
|
*/
|
||||||
|
class Keywords extends GenericCollection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all keywords
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getKeywords()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a keyword from the collection
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
* @return Keyword
|
||||||
|
*/
|
||||||
|
public function getKeyword($id) {
|
||||||
|
return $this->filterId($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a keyword to the collection
|
||||||
|
*
|
||||||
|
* @param Keyword $keyword
|
||||||
|
*/
|
||||||
|
public function addKeyword(Keyword $keyword)
|
||||||
|
{
|
||||||
|
$this->data[] = $keyword;
|
||||||
|
}
|
||||||
|
}
|
54
modules/Tmdb/Model/Collection/People.php
Normal file
54
modules/Tmdb/Model/Collection/People.php
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
use Tmdb\Model\Collection\People\PersonInterface;
|
||||||
|
use Tmdb\Model\Person;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class People
|
||||||
|
* @package Tmdb\Model\Collection
|
||||||
|
*/
|
||||||
|
class People extends GenericCollection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all people
|
||||||
|
*
|
||||||
|
* @return Person[]
|
||||||
|
*/
|
||||||
|
public function getPeople()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a person from the collection
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
* @return Person
|
||||||
|
*/
|
||||||
|
public function getPerson($id) {
|
||||||
|
return $this->filterId($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a person to the collection
|
||||||
|
*
|
||||||
|
* @param PersonInterface $person
|
||||||
|
*/
|
||||||
|
public function addPerson(PersonInterface $person)
|
||||||
|
{
|
||||||
|
$this->data[] = $person;
|
||||||
|
}
|
||||||
|
}
|
42
modules/Tmdb/Model/Collection/People/Cast.php
Normal file
42
modules/Tmdb/Model/Collection/People/Cast.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection\People;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\People;
|
||||||
|
use Tmdb\Model\Person;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Cast
|
||||||
|
* @package Tmdb\Model\Collection\People
|
||||||
|
*/
|
||||||
|
class Cast extends People {
|
||||||
|
/**
|
||||||
|
* Returns all people
|
||||||
|
*
|
||||||
|
* @return Person[]
|
||||||
|
*/
|
||||||
|
public function getCast()
|
||||||
|
{
|
||||||
|
return parent::getPeople();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a cast member from the collection
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
* @return Person
|
||||||
|
*/
|
||||||
|
public function getCastMember($id) {
|
||||||
|
return parent::getPerson($id);
|
||||||
|
}
|
||||||
|
}
|
42
modules/Tmdb/Model/Collection/People/Crew.php
Normal file
42
modules/Tmdb/Model/Collection/People/Crew.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection\People;
|
||||||
|
|
||||||
|
use Tmdb\Model\Collection\People;
|
||||||
|
use Tmdb\Model\Person;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Crew
|
||||||
|
* @package Tmdb\Model\Collection\People
|
||||||
|
*/
|
||||||
|
class Crew extends People {
|
||||||
|
/**
|
||||||
|
* Returns all people
|
||||||
|
*
|
||||||
|
* @return Person[]
|
||||||
|
*/
|
||||||
|
public function getCrew()
|
||||||
|
{
|
||||||
|
return parent::getPeople();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a crew member from the collection
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
* @return Person
|
||||||
|
*/
|
||||||
|
public function getCrewMember($id) {
|
||||||
|
return parent::getPerson($id);
|
||||||
|
}
|
||||||
|
}
|
26
modules/Tmdb/Model/Collection/People/PersonInterface.php
Normal file
26
modules/Tmdb/Model/Collection/People/PersonInterface.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection\People;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface PersonInterface
|
||||||
|
* @package Tmdb\Model\Collection\People
|
||||||
|
*/
|
||||||
|
interface PersonInterface {
|
||||||
|
function getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function getId();
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection\QueryParameter;
|
||||||
|
|
||||||
|
use Tmdb\Model\Common\QueryParameter\AppendToResponse as BaseAppendToResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AppendToResponse
|
||||||
|
* @package Tmdb\Model\Collection\QueryParameter
|
||||||
|
*/
|
||||||
|
final class AppendToResponse extends BaseAppendToResponse {
|
||||||
|
const IMAGES = 'images';
|
||||||
|
}
|
21
modules/Tmdb/Model/Collection/QueryParametersCollection.php
Normal file
21
modules/Tmdb/Model/Collection/QueryParametersCollection.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class QueryParametersCollection
|
||||||
|
* @package Tmdb\Model\Collection
|
||||||
|
*/
|
||||||
|
class QueryParametersCollection extends GenericCollection {}
|
99
modules/Tmdb/Model/Collection/ResultCollection.php
Normal file
99
modules/Tmdb/Model/Collection/ResultCollection.php
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Collection;
|
||||||
|
|
||||||
|
use Tmdb\Model\Common\GenericCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ResultCollection
|
||||||
|
* @package Tmdb\Model\Collection
|
||||||
|
*/
|
||||||
|
class ResultCollection extends GenericCollection {
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $page = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $totalPages = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $totalResults = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $_properties = array(
|
||||||
|
'page',
|
||||||
|
'total_pages',
|
||||||
|
'total_results'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $page
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPage($page)
|
||||||
|
{
|
||||||
|
$this->page = (int) $page;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPage()
|
||||||
|
{
|
||||||
|
return $this->page;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $totalPages
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTotalPages($totalPages)
|
||||||
|
{
|
||||||
|
$this->totalPages = (int) $totalPages;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getTotalPages()
|
||||||
|
{
|
||||||
|
return $this->totalPages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $totalResults
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTotalResults($totalResults)
|
||||||
|
{
|
||||||
|
$this->totalResults = (int) $totalResults;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getTotalResults()
|
||||||
|
{
|
||||||
|
return $this->totalResults;
|
||||||
|
}
|
||||||
|
}
|
28
modules/Tmdb/Model/Common/AbstractTrailer.php
Normal file
28
modules/Tmdb/Model/Common/AbstractTrailer.php
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Common;
|
||||||
|
|
||||||
|
use Tmdb\Model\AbstractModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AbstractTrailer
|
||||||
|
* @package Tmdb\Model\Common
|
||||||
|
*/
|
||||||
|
abstract class AbstractTrailer extends AbstractModel {
|
||||||
|
/**
|
||||||
|
* Returns the http url to the trailer
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function getUrl();
|
||||||
|
}
|
79
modules/Tmdb/Model/Common/Change.php
Normal file
79
modules/Tmdb/Model/Common/Change.php
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Common;
|
||||||
|
|
||||||
|
use Tmdb\Model\AbstractModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Change
|
||||||
|
* @package Tmdb\Model\Common
|
||||||
|
*/
|
||||||
|
class Change extends AbstractModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var GenericCollection
|
||||||
|
*/
|
||||||
|
private $items;
|
||||||
|
|
||||||
|
public static $_properties = array(
|
||||||
|
'key',
|
||||||
|
);
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->items = new GenericCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Tmdb\Model\Common\GenericCollection $items
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setItems($items)
|
||||||
|
{
|
||||||
|
$this->items = $items;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Tmdb\Model\Common\GenericCollection
|
||||||
|
*/
|
||||||
|
public function getItems()
|
||||||
|
{
|
||||||
|
return $this->items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $key
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setKey($key)
|
||||||
|
{
|
||||||
|
$this->key = $key;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getKey()
|
||||||
|
{
|
||||||
|
return $this->key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
128
modules/Tmdb/Model/Common/Change/Item.php
Normal file
128
modules/Tmdb/Model/Common/Change/Item.php
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Common\Change;
|
||||||
|
|
||||||
|
use Tmdb\Model\AbstractModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Item
|
||||||
|
* @package Tmdb\Model\Common\Change
|
||||||
|
*/
|
||||||
|
class Item extends AbstractModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \DateTime
|
||||||
|
*/
|
||||||
|
private $time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $value;
|
||||||
|
|
||||||
|
public static $_properties = array(
|
||||||
|
'id',
|
||||||
|
'action',
|
||||||
|
'time',
|
||||||
|
'value'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $action
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setAction($action)
|
||||||
|
{
|
||||||
|
$this->action = $action;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAction()
|
||||||
|
{
|
||||||
|
return $this->action;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $id
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|\DateTime $time
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTime($time)
|
||||||
|
{
|
||||||
|
if (!$time instanceof \DateTime) {
|
||||||
|
$time = new \DateTime($time);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->time = $time;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \DateTime
|
||||||
|
*/
|
||||||
|
public function getTime()
|
||||||
|
{
|
||||||
|
return $this->time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $value
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setValue($value)
|
||||||
|
{
|
||||||
|
$this->value = $value;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getValue()
|
||||||
|
{
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
67
modules/Tmdb/Model/Common/Country.php
Normal file
67
modules/Tmdb/Model/Common/Country.php
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Common;
|
||||||
|
|
||||||
|
use Tmdb\Model\AbstractModel;
|
||||||
|
use Tmdb\Model\Filter\CountryFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Country
|
||||||
|
* @package Tmdb\Model\Common
|
||||||
|
*/
|
||||||
|
class Country extends AbstractModel implements CountryFilter {
|
||||||
|
|
||||||
|
private $iso31661;
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
public static $_properties = array(
|
||||||
|
'iso_3166_1',
|
||||||
|
'name',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $iso31661
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setIso31661($iso31661)
|
||||||
|
{
|
||||||
|
$this->iso31661 = $iso31661;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getIso31661()
|
||||||
|
{
|
||||||
|
return $this->iso31661;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
}
|
146
modules/Tmdb/Model/Common/ExternalIds.php
Normal file
146
modules/Tmdb/Model/Common/ExternalIds.php
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Common;
|
||||||
|
|
||||||
|
use Tmdb\Model\AbstractModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ExternalIds
|
||||||
|
* @package Tmdb\Model\Common
|
||||||
|
*/
|
||||||
|
class ExternalIds extends AbstractModel {
|
||||||
|
|
||||||
|
private $imdbId;
|
||||||
|
private $freebaseId;
|
||||||
|
private $freebaseMid;
|
||||||
|
private $id;
|
||||||
|
private $tvdbId;
|
||||||
|
private $tvrageId;
|
||||||
|
|
||||||
|
public static $_properties = array(
|
||||||
|
'imdb_id',
|
||||||
|
'freebase_id',
|
||||||
|
'freebase_mid',
|
||||||
|
'id',
|
||||||
|
'tvdb_id',
|
||||||
|
'tvrage_id',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $freebaseId
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setFreebaseId($freebaseId)
|
||||||
|
{
|
||||||
|
$this->freebaseId = $freebaseId;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getFreebaseId()
|
||||||
|
{
|
||||||
|
return $this->freebaseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $freebaseMid
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setFreebaseMid($freebaseMid)
|
||||||
|
{
|
||||||
|
$this->freebaseMid = $freebaseMid;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getFreebaseMid()
|
||||||
|
{
|
||||||
|
return $this->freebaseMid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $id
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = (int) $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $imdbId
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImdbId($imdbId)
|
||||||
|
{
|
||||||
|
$this->imdbId = $imdbId;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getImdbId()
|
||||||
|
{
|
||||||
|
return $this->imdbId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $tvdbId
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTvdbId($tvdbId)
|
||||||
|
{
|
||||||
|
$this->tvdbId = $tvdbId;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTvdbId()
|
||||||
|
{
|
||||||
|
return $this->tvdbId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $tvrageId
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTvrageId($tvrageId)
|
||||||
|
{
|
||||||
|
$this->tvrageId = $tvrageId;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTvrageId()
|
||||||
|
{
|
||||||
|
return $this->tvrageId;
|
||||||
|
}
|
||||||
|
}
|
374
modules/Tmdb/Model/Common/GenericCollection.php
Normal file
374
modules/Tmdb/Model/Common/GenericCollection.php
Normal file
|
@ -0,0 +1,374 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* Some code is borrowed from Guzzle, and thus I've credited the author, however most of it is in a modified form.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Common;
|
||||||
|
|
||||||
|
use Tmdb\Model\Filter\AdultFilter;
|
||||||
|
use Tmdb\Model\Filter\CountryFilter;
|
||||||
|
use Tmdb\Model\Filter\LanguageFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class GenericCollection
|
||||||
|
* @package Tmdb\Model\Common
|
||||||
|
*/
|
||||||
|
class GenericCollection implements \ArrayAccess, \IteratorAggregate, \Countable {
|
||||||
|
/** @var array Data associated with the object. */
|
||||||
|
protected $data = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data Associative array of data to set
|
||||||
|
*/
|
||||||
|
public function __construct(array $data = array())
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function count()
|
||||||
|
{
|
||||||
|
return count($this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \ArrayIterator|\Traversable
|
||||||
|
*/
|
||||||
|
public function getIterator()
|
||||||
|
{
|
||||||
|
return new \ArrayIterator($this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all key value pairs
|
||||||
|
*
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
$this->data = array();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all or a subset of matching key value pairs
|
||||||
|
*
|
||||||
|
* @param array $keys Pass an array of keys to retrieve only a subset of key value pairs
|
||||||
|
*
|
||||||
|
* @return array Returns an array of all matching key value pairs
|
||||||
|
*/
|
||||||
|
public function getAll(array $keys = null)
|
||||||
|
{
|
||||||
|
return $keys ? array_intersect_key($this->data, array_flip($keys)) : $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific key value.
|
||||||
|
*
|
||||||
|
* @param string $key Key to retrieve.
|
||||||
|
*
|
||||||
|
* @return mixed|null Value of the key or NULL
|
||||||
|
*/
|
||||||
|
public function get($key)
|
||||||
|
{
|
||||||
|
if (is_object($key)) {
|
||||||
|
$key = spl_object_hash($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($this->data[$key]) ? $this->data[$key] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a key value pair
|
||||||
|
*
|
||||||
|
* @param string $key Key to set
|
||||||
|
* @param mixed $value Value to set
|
||||||
|
*
|
||||||
|
* @return GenericCollection Returns a reference to the object
|
||||||
|
*/
|
||||||
|
public function set($key, $value)
|
||||||
|
{
|
||||||
|
if ($key === null && is_object($value)) {
|
||||||
|
$key = spl_object_hash($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->data[$key] = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a value to a key.
|
||||||
|
*
|
||||||
|
* @param string $key Key to add
|
||||||
|
* @param mixed $value Value to add to the key
|
||||||
|
*
|
||||||
|
* @return GenericCollection Returns a reference to the object.
|
||||||
|
*/
|
||||||
|
public function add($key, $value)
|
||||||
|
{
|
||||||
|
if ($key === null && is_object($value)) {
|
||||||
|
$key = spl_object_hash($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!array_key_exists($key, $this->data)) {
|
||||||
|
$this->data[$key] = $value;
|
||||||
|
} elseif (is_array($this->data[$key])) {
|
||||||
|
$this->data[$key][] = $value;
|
||||||
|
} else {
|
||||||
|
$this->data[$key] = array($this->data[$key], $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a specific key value pair
|
||||||
|
*
|
||||||
|
* @param string $key A key to remove or an object in the same state
|
||||||
|
*
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function remove($key)
|
||||||
|
{
|
||||||
|
if (is_object($key)) {
|
||||||
|
$key = spl_object_hash($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($this->data[$key]);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all keys in the collection
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getKeys()
|
||||||
|
{
|
||||||
|
return array_keys($this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the specified key is present.
|
||||||
|
*
|
||||||
|
* @param string $key The key for which to check the existence.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasKey($key)
|
||||||
|
{
|
||||||
|
return array_key_exists($key, $this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Case insensitive search the keys in the collection
|
||||||
|
*
|
||||||
|
* @param string $key Key to search for
|
||||||
|
*
|
||||||
|
* @return bool|string Returns false if not found, otherwise returns the key
|
||||||
|
*/
|
||||||
|
public function keySearch($key)
|
||||||
|
{
|
||||||
|
foreach (array_keys($this->data) as $k) {
|
||||||
|
if (!strcasecmp($k, $key)) {
|
||||||
|
return $k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if any keys contains a certain value
|
||||||
|
*
|
||||||
|
* @param string $value Value to search for
|
||||||
|
*
|
||||||
|
* @return mixed Returns the key if the value was found FALSE if the value was not found.
|
||||||
|
*/
|
||||||
|
public function hasValue($value)
|
||||||
|
{
|
||||||
|
return array_search($value, $this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace the data of the object with the value of an array
|
||||||
|
*
|
||||||
|
* @param array $data Associative array of data
|
||||||
|
*
|
||||||
|
* @return GenericCollection Returns a reference to the object
|
||||||
|
*/
|
||||||
|
public function replace(array $data)
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add and merge in a Collection or array of key value pair data.
|
||||||
|
*
|
||||||
|
* @param GenericCollection|array $data Associative array of key value pair data
|
||||||
|
*
|
||||||
|
* @return GenericCollection Returns a reference to the object.
|
||||||
|
*/
|
||||||
|
public function merge($data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
$this->add($key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a Collection containing all the elements of the collection after applying the callback function to each
|
||||||
|
* one. The Closure should accept three parameters: (string) $key, (string) $value, (array) $context and return a
|
||||||
|
* modified value
|
||||||
|
*
|
||||||
|
* @param \Closure $closure Closure to apply
|
||||||
|
* @param array $context Context to pass to the closure
|
||||||
|
* @param bool $static Set to TRUE to use the same class as the return rather than returning a Collection
|
||||||
|
*
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function map(\Closure $closure, array $context = array(), $static = true)
|
||||||
|
{
|
||||||
|
$collection = $static ? new static() : new self();
|
||||||
|
foreach ($this as $key => $value) {
|
||||||
|
$collection->add($key, $closure($key, $value, $context));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterates over each key value pair in the collection passing them to the Closure. If the Closure function returns
|
||||||
|
* true, the current value from input is returned into the result Collection. The Closure must accept three
|
||||||
|
* parameters: (string) $key, (string) $value and return Boolean TRUE or FALSE for each value.
|
||||||
|
*
|
||||||
|
* @param \Closure $closure Closure evaluation function
|
||||||
|
* @param bool $static Set to TRUE to use the same class as the return rather than returning a Collection
|
||||||
|
*
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function filter(\Closure $closure, $static = true)
|
||||||
|
{
|
||||||
|
$collection = ($static) ? new static() : new self();
|
||||||
|
foreach ($this->data as $key => $value) {
|
||||||
|
if ($closure($key, $value)) {
|
||||||
|
$collection->add($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function offsetExists($offset)
|
||||||
|
{
|
||||||
|
return isset($this->data[$offset]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function offsetGet($offset)
|
||||||
|
{
|
||||||
|
return isset($this->data[$offset]) ? $this->data[$offset] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function offsetSet($offset, $value)
|
||||||
|
{
|
||||||
|
$this->data[$offset] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function offsetUnset($offset)
|
||||||
|
{
|
||||||
|
unset($this->data[$offset]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by id
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function filterId($id)
|
||||||
|
{
|
||||||
|
$result = $this->filter(
|
||||||
|
function($key, $value) use ($id) {
|
||||||
|
if ($value->getId() == $id) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result && 1 === count($result)) {
|
||||||
|
return array_shift($this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by language ISO 639-1 code.
|
||||||
|
*
|
||||||
|
* @param string $language
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function filterLanguage($language = 'en')
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) use ($language) {
|
||||||
|
if ($value instanceof LanguageFilter && $value->getIso6391() == $language) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by country ISO 3166-1 code.
|
||||||
|
*
|
||||||
|
* @param string $country
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function filterCountry($country = 'US')
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) use ($country) {
|
||||||
|
if ($value instanceof CountryFilter && $value->getIso31661() == $country) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by adult content
|
||||||
|
*
|
||||||
|
* @param boolean $adult
|
||||||
|
* @return GenericCollection
|
||||||
|
*/
|
||||||
|
public function filterAdult($adult = false)
|
||||||
|
{
|
||||||
|
return $this->filter(
|
||||||
|
function($key, $value) use ($adult) {
|
||||||
|
if ($value instanceof AdultFilter && $value->getAdult() == $adult) { return true; }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
43
modules/Tmdb/Model/Common/QueryParameter/Adult.php
Normal file
43
modules/Tmdb/Model/Common/QueryParameter/Adult.php
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Tmdb PHP API created by Michael Roterman.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @package Tmdb
|
||||||
|
* @author Michael Roterman <michael@wtfz.net>
|
||||||
|
* @copyright (c) 2013, Michael Roterman
|
||||||
|
* @version 0.0.1
|
||||||
|
*/
|
||||||
|
namespace Tmdb\Model\Common\QueryParameter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Adult
|
||||||
|
* @package Tmdb\Model\Common\QueryParameter
|
||||||
|
*/
|
||||||
|
class Adult implements QueryParameterInterface {
|
||||||
|
|
||||||
|
private $adult;
|
||||||
|
|
||||||
|
public function __construct($adult)
|
||||||
|
{
|
||||||
|
$this->adult = $adult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getKey()
|
||||||
|
{
|
||||||
|
return 'adult';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getValue()
|
||||||
|
{
|
||||||
|
return $this->adult;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue