mirror of
https://github.com/proelements/proelements.git
synced 2026-04-19 02:22:18 +00:00
v3.33.1
This commit is contained in:
44
modules/forms/submissions/data/forms-controller.php
Normal file
44
modules/forms/submissions/data/forms-controller.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\Forms\Submissions\Data;
|
||||
|
||||
use Elementor\Data\Base\Controller as Controller_Base;
|
||||
use ElementorPro\Modules\Forms\Submissions\Database\Entities\Form_Snapshot;
|
||||
use ElementorPro\Modules\Forms\Submissions\Database\Repositories\Form_Snapshot_Repository;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Forms_Controller extends Controller_Base {
|
||||
public function get_name() {
|
||||
return 'forms';
|
||||
}
|
||||
|
||||
public function get_items( $request ) {
|
||||
$forms = Form_Snapshot_Repository::instance()->all();
|
||||
|
||||
// For now return only as "options"
|
||||
return [
|
||||
'data' => $forms->map(function ( Form_Snapshot $form ) {
|
||||
return [
|
||||
'label' => $form->get_label(),
|
||||
'value' => $form->get_key(),
|
||||
];
|
||||
})->values(),
|
||||
'meta' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public function register_endpoints() {
|
||||
//
|
||||
}
|
||||
|
||||
protected function register_internal_endpoints() {
|
||||
// Register as internal to remove the default endpoint generated by the base controller.
|
||||
$this->register_endpoint( Endpoints\Forms_Index::class );
|
||||
}
|
||||
|
||||
public function get_permission_callback( $request ) {
|
||||
return current_user_can( 'manage_options' );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user