Update lots of docblocks
This commit is contained in:
parent
34acf00b5e
commit
7f2000f180
@ -3,7 +3,7 @@
|
||||
namespace Aviat\AnimeClient\Auth;
|
||||
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\AnimeClient\Model\Anime as AnimeModel;
|
||||
use Aviat\AnimeClient\Model\API;
|
||||
|
||||
/**
|
||||
* Hummingbird API Authentication
|
||||
@ -24,7 +24,7 @@ class HummingbirdAuth {
|
||||
*
|
||||
* @var Aura\Session\Segment
|
||||
*/
|
||||
protected $session;
|
||||
protected $segment;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -34,32 +34,60 @@ class HummingbirdAuth {
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->setContainer($container);
|
||||
$this->session = $container->get('session')
|
||||
$this->segment = $container->get('session')
|
||||
->getSegment(__NAMESPACE__);
|
||||
$this->model = new AnimeModel($container);
|
||||
$this->model = new API($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the appropriate authentication call,
|
||||
* and save the resulting auth token if successful
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return boolean
|
||||
*/
|
||||
public function authenticate($username, $password)
|
||||
public function authenticate($password)
|
||||
{
|
||||
return $this->model->authenticate();
|
||||
$username = $this->config->get('hummingbird_username');
|
||||
$auth_token = $this->model->authenticate($username, $password);
|
||||
|
||||
if (FALSE !== $auth_token)
|
||||
{
|
||||
$this->segment->set('auth_token', $auth_token);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the current user is authenticated
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_authenticated()
|
||||
{
|
||||
return ($this->get_auth_token() !== FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear authentication values
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function log_out()
|
||||
{
|
||||
$this->segment->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the authentication token from the session
|
||||
*
|
||||
* @return string
|
||||
* @return string|false
|
||||
*/
|
||||
public function get_auth_token()
|
||||
{
|
||||
return $this->session->get('auth_token');
|
||||
return $this->segment->get('auth_token', FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,10 +4,19 @@ namespace Aviat\AnimeClient\Helper;
|
||||
|
||||
use Aviat\AnimeClient\MenuGenerator;
|
||||
|
||||
/**
|
||||
* MenuGenerator helper wrapper
|
||||
*/
|
||||
class Menu {
|
||||
|
||||
use \Aviat\Ion\Di\ContainerAware;
|
||||
|
||||
/**
|
||||
* Create the html for the selected menu
|
||||
*
|
||||
* @param string $menu_name
|
||||
* @return string
|
||||
*/
|
||||
public function __invoke($menu_name)
|
||||
{
|
||||
$generator = new MenuGenerator($this->container);
|
||||
|
@ -64,7 +64,7 @@ class API extends BaseModel {
|
||||
* @codeCoverageIgnore
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
* @return string|false
|
||||
*/
|
||||
public function authenticate($username, $password)
|
||||
{
|
||||
@ -77,8 +77,7 @@ class API extends BaseModel {
|
||||
|
||||
if ($result->getStatusCode() === 201)
|
||||
{
|
||||
$_SESSION['hummingbird_anime_token'] = $result->json();
|
||||
return TRUE;
|
||||
return json_decode($result->getBody(), TRUE);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -88,6 +88,12 @@ class Manga extends API {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the list from the hummingbird api
|
||||
*
|
||||
* @param string $status
|
||||
* @return array
|
||||
*/
|
||||
private function _get_list_from_api($status = "All")
|
||||
{
|
||||
|
||||
|
@ -4,6 +4,9 @@ namespace Aviat\Ion;
|
||||
|
||||
use Aviat\Ion\Type\ArrayType;
|
||||
|
||||
/**
|
||||
* Wrapper to shortcut creating ArrayType objects
|
||||
*/
|
||||
trait ArrayWrapper {
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
namespace Aviat\Ion\Di;
|
||||
|
||||
/**
|
||||
* Trait implementation of ContainerAwareInterface
|
||||
*/
|
||||
trait ContainerAware {
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
namespace Aviat\Ion\Di;
|
||||
|
||||
/**
|
||||
* Interface for a class that is aware of the Di Container
|
||||
*/
|
||||
interface ContainerAwareInterface {
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
namespace Aviat\Ion\Di\Exception;
|
||||
|
||||
/**
|
||||
* Generic exception for Di Container
|
||||
*/
|
||||
class ContainerException
|
||||
extends \Exception
|
||||
implements \Interop\Container\Exception\ContainerException {
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
namespace Aviat\Ion\Di\Exception;
|
||||
|
||||
/**
|
||||
* Exception for Di Container when trying to access a
|
||||
* key that doesn't exist in the container
|
||||
*/
|
||||
class NotFoundException
|
||||
extends ContainerException
|
||||
implements \Interop\Container\Exception\NotFoundException {
|
||||
|
@ -4,6 +4,9 @@ namespace Aviat\Ion\Type;
|
||||
|
||||
use Stringy\Stringy;
|
||||
|
||||
/**
|
||||
* Wrapper around Stringy
|
||||
*/
|
||||
class StringType extends Stringy {
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user