| 1 |
<?php |
| 2 |
|
| 3 |
namespace Buddypress\CLI\Command; |
| 4 |
|
| 5 |
use WP_CLI\Fetchers\Base; |
| 6 |
|
| 7 |
/** |
| 8 |
* Fetch a BuddyPress activity based on one of its attributes. |
| 9 |
* |
| 10 |
* @since 2.0.0 |
| 11 |
*/ |
| 12 |
class Activity_Fetcher extends Base { |
| 13 |
|
| 14 |
/** |
| 15 |
* @var string $msg Error message to use when invalid data is provided. |
| 16 |
*/ |
| 17 |
protected $msg = 'Could not find the activity with ID %d.'; |
| 18 |
|
| 19 |
/** |
| 20 |
* Get an activity ID. |
| 21 |
* |
| 22 |
* @param int $activity_id Activity ID. |
| 23 |
* @return BP_Activity_Activity|bool |
| 24 |
*/ |
| 25 |
public function get( $activity_id ) { |
| 26 |
$activity = new \BP_Activity_Activity( $activity_id ); |
| 27 |
|
| 28 |
if ( empty( $activity->id ) ) { |
| 29 |
return false; |
| 30 |
} |
| 31 |
|
| 32 |
return $activity; |
| 33 |
} |
| 34 |
} |
| 35 |
|