<?php  // vim:set et ts=4 sw=4 sts=4:
# Copyright (C) 2003-2014 hipplay Inc.
#
# This is UNPUBLISHED PROPRIETARY SOURCE CODE OF hipplay Inc.
# The copyright notice above does not evidence any actual or intended
# publication of such source code. The contents of this file may not
# be disclosed to third parties, copied or duplicated in any form, in
# whole or in part, without the prior written permission of
# hipplay Inc.
#
namespace HipPlayConnect\REST\services\sessions;


use HipPlayConnect\REST\AxAbstractRESTService;
use HipPlayConnect\REST\AxRESTServiceInterface;

class AxSessionsRESTService extends AxAbstractRESTService implements AxRESTServiceInterface
{
	protected $requiresAuthenticatedHipServUser = false;
    protected $serviceName = 'sessions';
		
	public function getResource( array $URIArray )
	{
		if ( count( $URIArray ) > 1 )
			return null;
			
	    // all sessions (to log in)
	    if ( count( $URIArray ) == 0 || $URIArray[ 0 ] == '' ) // || $URIArray[ 0 ] == '' for backward compatibility, can be removed
	    {
            $resourceClassName = $this->getResourceClassName( 'sessions' );
            return new $resourceClassName();	        
	    }

		// a specific session 
		// !!! Works only for the current user !!!
		$resourceClassName = $this->getResourceClassName( 'session' );
		return new $resourceClassName( $URIArray[ 0 ] );
	}
}