Skip to content

Commit f6fed79

Browse files
committed
activity profile API implementation
1 parent dbfed05 commit f6fed79

8 files changed

+256
-0
lines changed

Model/ActivityProfile.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Model;
13+
14+
/**
15+
* A {@link ProfileInterface Profile} related to an {@link ActivityInterface Activity}.
16+
*
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
class ActivityProfile extends Profile implements ActivityProfileInterface
20+
{
21+
/**
22+
* @var ActivityInterface The activity
23+
*/
24+
private $activity;
25+
26+
/**
27+
* {@inheritDoc}
28+
*/
29+
public function setActivity(ActivityInterface $activity)
30+
{
31+
$this->activity = $activity;
32+
}
33+
34+
/**
35+
* {@inheritDoc}
36+
*/
37+
public function getActivity()
38+
{
39+
return $this->activity;
40+
}
41+
}

Model/ActivityProfileDocument.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Model;
13+
14+
/**
15+
* A {@link DocumentInterface Document} that is related to an {@link ActivityInterface Activity}.
16+
*
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
class ActivityProfileDocument extends Document implements ActivityProfileDocumentInterface
20+
{
21+
/**
22+
* @var ActivityProfileInterface The activity profile
23+
*/
24+
private $profile;
25+
26+
/**
27+
* {@inheritDoc}
28+
*/
29+
public function setActivityProfile(ActivityProfileInterface $profile)
30+
{
31+
$this->profile = $profile;
32+
}
33+
34+
/**
35+
* {@inheritDoc}
36+
*/
37+
public function getActivityProfile()
38+
{
39+
return $this->profile;
40+
}
41+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Model;
13+
14+
/**
15+
* A {@link DocumentInterface Document} that is related to an {@link ActivityInterface Activity}.
16+
*
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
interface ActivityProfileDocumentInterface extends DocumentInterface
20+
{
21+
/**
22+
* Sets the activity profile.
23+
*
24+
* @param ActivityProfileInterface $profile The activity profile
25+
*/
26+
public function setActivityProfile(ActivityProfileInterface $profile);
27+
28+
/**
29+
* Returns the activity profile.
30+
*
31+
* @return ActivityProfileInterface The activity profile
32+
*/
33+
public function getActivityProfile();
34+
}

Model/ActivityProfileInterface.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Model;
13+
14+
/**
15+
* A {@link ProfileInterface Profile} related to an {@link ActivityInterface Activity}.
16+
*
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
interface ActivityProfileInterface extends ProfileInterface
20+
{
21+
/**
22+
* Sets the activity.
23+
*
24+
* @param ActivityInterface $activity The activity
25+
*/
26+
public function setActivity(ActivityInterface $activity);
27+
28+
/**
29+
* Returns the activity.
30+
*
31+
* @return ActivityInterface The activity
32+
*/
33+
public function getActivity();
34+
}

Model/Profile.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Model;
13+
14+
/**
15+
* A profile.
16+
*
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
abstract class Profile implements ProfileInterface
20+
{
21+
/**
22+
* @var string The profile id
23+
*/
24+
protected $profileId;
25+
26+
/**
27+
* {@inheritDoc}
28+
*/
29+
public function setProfileId($profileId)
30+
{
31+
$this->profileId = $profileId;
32+
}
33+
34+
/**
35+
* {@inheritDoc}
36+
*/
37+
public function getProfileId()
38+
{
39+
return $this->profileId;
40+
}
41+
}

Model/ProfileInterface.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Model;
13+
14+
/**
15+
* A {@link DocumentInterface Document} related to a profile.
16+
*
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
interface ProfileInterface
20+
{
21+
/**
22+
* Sets the profile id.
23+
*
24+
* @param string $profileId The id
25+
*/
26+
public function setProfileId($profileId);
27+
28+
/**
29+
* Returns the profile id.
30+
*
31+
* @return string The id
32+
*/
33+
public function getProfileId();
34+
}

Serializer/Handler/DocumentDataUnwrapper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public static function getSubscribingMethods()
3636
'type' => 'Xabbuh\XApi\Common\Model\Document',
3737
'method' => 'unwrapData',
3838
),
39+
array(
40+
'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
41+
'format' => 'json',
42+
'type' => 'Xabbuh\XApi\Common\Model\ActivityProfileDocument',
43+
'method' => 'unwrapData',
44+
),
3945
array(
4046
'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
4147
'format' => 'json',
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Tests\Model;
13+
14+
use Xabbuh\XApi\Common\Model\ActivityProfileDocument;
15+
16+
/**
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
class ActivityProfileDocumentTest extends DocumentTest
20+
{
21+
protected function createDocument()
22+
{
23+
return new ActivityProfileDocument();
24+
}
25+
}

0 commit comments

Comments
 (0)