-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move element Settings to a specific model
- Loading branch information
1 parent
f6016e4
commit 5549578
Showing
8 changed files
with
164 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace studioespresso\exporter\models; | ||
|
||
use craft\base\Element; | ||
use craft\base\ElementInterface; | ||
use craft\base\Model; | ||
use craft\elements\Category; | ||
use craft\elements\Entry; | ||
use craft\services\Sections; | ||
|
||
class ExportableCategoryModel extends ExportableElementTypeModel | ||
{ | ||
public $elementType = Category::class; | ||
|
||
public string $elementLabel = "Categories"; | ||
|
||
public function getGroup(): array | ||
{ | ||
return [ | ||
"parameter" => "groupId", | ||
"label" => "Group", | ||
"instructions" => "Choose a group from which you want to start your export", | ||
"items" => \Craft::$app->getCategories()->getEditableGroups(), | ||
]; | ||
} | ||
|
||
public function getSubGroup(): bool|array | ||
{ | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace studioespresso\exporter\models; | ||
|
||
use craft\base\Element; | ||
use craft\base\ElementInterface; | ||
use craft\base\Model; | ||
|
||
abstract class ExportableElementTypeModel extends Model | ||
{ | ||
public $elementType; | ||
|
||
public string $elementLabel = ""; | ||
|
||
abstract public function getGroup(): bool|array; | ||
|
||
abstract public function getSubGroup(): bool|array; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace studioespresso\exporter\models; | ||
|
||
use craft\base\Element; | ||
use craft\base\ElementInterface; | ||
use craft\base\Model; | ||
use craft\elements\Entry; | ||
use craft\services\Sections; | ||
|
||
class ExportableEntryModel extends ExportableElementTypeModel | ||
{ | ||
public $elementType = Entry::class; | ||
|
||
public string $elementLabel = "Entries"; | ||
|
||
public function getGroup(): array | ||
{ | ||
return [ | ||
"parameter" => "sectionId", | ||
"label" => "Section", | ||
"instructions" => "Choose a group from which you want to start your export", | ||
"items" => \Craft::$app->getSections()->getEditableSections(), | ||
]; | ||
} | ||
|
||
public function getSubGroup(): array | ||
{ | ||
return [ | ||
'label' => "Entry type", | ||
"instructions" => "Choose which entry-type you want to export", | ||
'parameter' => 'id', | ||
'class' => Sections::class, | ||
'function' => 'getEntryTypesBySectionId', | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace studioespresso\exporter\models; | ||
|
||
use craft\base\Element; | ||
use craft\base\ElementInterface; | ||
use craft\base\Model; | ||
use craft\elements\Category; | ||
use craft\elements\Entry; | ||
use craft\services\Sections; | ||
use verbb\formie\elements\Submission; | ||
use verbb\formie\Formie; | ||
|
||
class ExportableFormieSubmissionModel extends ExportableElementTypeModel | ||
{ | ||
public $elementType = Submission::class; | ||
|
||
public string $elementLabel = "Formie Submissions"; | ||
|
||
public function getGroup(): array | ||
{ | ||
return [ | ||
"label" => "Form", | ||
"parameter" => "formId", | ||
"items" => Formie::getInstance()->getForms()->getAllForms(), // @phpstan-ignore-line | ||
"nameProperty" => "title", | ||
]; | ||
} | ||
|
||
public function getSubGroup(): bool|array | ||
{ | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters