| 1 |
<?php |
| 2 |
namespace Elementor\App\Modules\KitLibrary\Data; |
| 3 |
|
| 4 |
use Elementor\Plugin; |
| 5 |
use Elementor\Data\V2\Base\Controller; |
| 6 |
use Elementor\Core\Utils\Collection; |
| 7 |
use Elementor\Modules\Library\User_Favorites; |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; // Exit if accessed directly. |
| 11 |
} |
| 12 |
|
| 13 |
abstract class Base_Controller extends Controller { |
| 14 |
/** |
| 15 |
* @var Repository |
| 16 |
*/ |
| 17 |
private $repository; |
| 18 |
|
| 19 |
/** |
| 20 |
* @return Repository |
| 21 |
*/ |
| 22 |
public function get_repository() { |
| 23 |
if ( ! $this->repository ) { |
| 24 |
/** @var \Elementor\Core\Common\Modules\Connect\Module $connect */ |
| 25 |
$connect = Plugin::$instance->common->get_component( 'connect' ); |
| 26 |
|
| 27 |
$subscription_plans = ( new Collection( $connect->get_subscription_plans() ) ) |
| 28 |
->map( function ( $value ) { |
| 29 |
return $value['label']; |
| 30 |
} ); |
| 31 |
|
| 32 |
$this->repository = new Repository( |
| 33 |
$connect->get_app( 'kit-library' ), |
| 34 |
new User_Favorites( get_current_user_id() ), |
| 35 |
$subscription_plans |
| 36 |
); |
| 37 |
} |
| 38 |
|
| 39 |
return $this->repository; |
| 40 |
} |
| 41 |
} |
| 42 |
|