Skip to content

Commit

Permalink
refactor plugin first step
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinSecondred committed Dec 19, 2023
1 parent 1392759 commit 02f6ea1
Show file tree
Hide file tree
Showing 41 changed files with 1,165 additions and 1,000 deletions.
24 changes: 5 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "studioespresso/craft-seeder",
"name": "anubarak/craft-seeder",
"description": "Easy entries seeder for Craft CMS",
"type": "craft-plugin",
"keywords": [
Expand All @@ -9,33 +9,19 @@
"craft-plugin",
"seeder"
],
"support": {
"docs": "https://github.com/studioespresso/craft3-seeder/blob/master/README.md",
"issues": "https://github.com/studioespresso/craft3-seeder/issues"
},
"license": "MIT",
"authors": [
{
"name": "Studio Espresso",
"homepage": "https://www.studioepsresso.co"
}
],
"require": {
"craftcms/cms": "^4.0.0",
"fakerphp/faker": "^1.23.0"
},
"require-dev": {
"codeception/codeception": "2.4.2"
},
"autoload": {
"psr-4": {
"studioespresso\\seeder\\": "src/"
"anubarak\\seeder\\": "src/"
}
},
"extra": {
"name": "Seeder",
"handle": "seeder",
"changelogUrl": "https://raw.githubusercontent.com/studioespresso/craft3-seeder/master/CHANGELOG.md",
"class": "studioespresso\\seeder\\Seeder"
"name": "Element Seeder",
"handle": "element-seeder",
"class": "anubarak\\seeder\\Seeder"
}
}
84 changes: 32 additions & 52 deletions src/Seeder.php
Original file line number Diff line number Diff line change
@@ -1,54 +1,36 @@
<?php
/**
* Seeder plugin for Craft CMS 3.x
*
* Entries seeder for Craft CMS
*
* @link https://studioespresso.co
* @copyright Copyright (c) 2018 Studio Espresso
*/

namespace studioespresso\seeder;

use studioespresso\seeder\models\Settings;
use studioespresso\seeder\services\Categories;
use studioespresso\seeder\services\Entries;
use studioespresso\seeder\services\fields\CkEditor;
use studioespresso\seeder\services\fields\CTA;
use studioespresso\seeder\services\fields\Fields;
use studioespresso\seeder\services\fields\Redactor;
use studioespresso\seeder\services\fields\Supertable;
use studioespresso\seeder\services\SeederService;
use studioespresso\seeder\services\Entries as EntriesService;
use studioespresso\seeder\services\Categories as CategoriesService;
use studioespresso\seeder\services\Users;
use studioespresso\seeder\services\Weeder as WeederService;
use studioespresso\seeder\services\Users as UsersService;
use studioespresso\seeder\services\fields\Fields as FieldsService;
use studioespresso\seeder\services\fields\Redactor as RedactorService;
use studioespresso\seeder\services\fields\CkEditor as CkEditorService;
use studioespresso\seeder\services\fields\Supertable as SupertableService;
use studioespresso\seeder\services\fields\CTA as CTAService;
use studioespresso\seeder\services\fields\Positionfieldtype as PositionService;
use Craft;

namespace anubarak\seeder;

use anubarak\seeder\models\Settings;
use anubarak\seeder\services\Categories;
use anubarak\seeder\services\Entries;
use anubarak\seeder\services\fields\CkEditor;
use anubarak\seeder\services\fields\CTA;
use anubarak\seeder\services\fields\Fields;
use anubarak\seeder\services\fields\Redactor;
use anubarak\seeder\services\fields\Supertable;
use anubarak\seeder\services\SeederService;
use anubarak\seeder\services\Entries as EntriesService;
use anubarak\seeder\services\Categories as CategoriesService;
use anubarak\seeder\services\Users;
use anubarak\seeder\services\Weeder as WeederService;
use anubarak\seeder\services\Users as UsersService;
use anubarak\seeder\services\fields\Fields as FieldsService;
use anubarak\seeder\services\fields\Redactor as RedactorService;
use anubarak\seeder\services\fields\CkEditor as CkEditorService;
use anubarak\seeder\services\fields\Supertable as SupertableService;
use anubarak\seeder\services\fields\CTA as CTAService;
use anubarak\seeder\services\fields\Positionfieldtype as PositionService;
use craft\base\Plugin;
use craft\console\Application as ConsoleApplication;
use craft\web\UrlManager;
use craft\events\RegisterUrlRulesEvent;

use yii\base\Event;

/**
* Craft plugins are very much like little applications in and of themselves. We’ve made
* it as simple as we can, but the training wheels are off. A little prior knowledge is
* going to be required to write a plugin.
*
* For the purposes of the plugin docs, we’re going to assume that you know PHP and SQL,
* as well as some semi-advanced concepts like object-oriented programming and PHP namespaces.
*
* https://craftcms.com/docs/plugins/introduction
*
* @author Studio Espresso
* @package Seeder
* @since 1.0.0
* @property SeederService seeder
Expand Down Expand Up @@ -76,7 +58,7 @@ class Seeder extends Plugin
*
* @var Seeder
*/
public static $plugin;
public static Seeder $plugin;

// Public Properties
// =========================================================================
Expand All @@ -87,9 +69,14 @@ class Seeder extends Plugin
* @var string
*/
public string $schemaVersion = '1.0.0';

/**
* @inheritdoc
*/
public bool $hasCpSettings = false;

/**
* @inheritdoc
*/
public bool $hasCpSection = true;

// Public Methods
Expand All @@ -105,28 +92,21 @@ public function init()
'seeder' => SeederService::class,
'weeder' => WeederService::class,
'entries' => Entries::class,
'categories' => Categories::class,
'users' => Users::class,
'fields' => Fields::class,
'redactor' => Redactor::class,
'ckeditor' => CkEditor::class,
'supertable' => Supertable::class,
'cta' => CTA::class,
'positionfieldtype' => PositionService::class,
];

Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_CP_URL_RULES,
static function (RegisterUrlRulesEvent $event) {
$event->rules['seeder'] = 'seeder/seeder/index';
$event->rules['seeder'] = 'element-seeder/seeder/index';
}
);

// Add in our console commands
if (Craft::$app instanceof ConsoleApplication) {
$this->controllerNamespace = 'studioespresso\seeder\console\controllers';
}
}

// Protected Methods
Expand All @@ -135,7 +115,7 @@ static function (RegisterUrlRulesEvent $event) {
/**
* Creates and returns the model used to store the plugin’s settings.
*
* @return \studioespresso\seeder\models\Settings
* @return Settings
*/
protected function createSettingsModel(): Settings
{
Expand Down
12 changes: 6 additions & 6 deletions src/console/controllers/CleanUpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
* @copyright Copyright (c) 2018 Studio Espresso
*/

namespace studioespresso\seeder\console\controllers;
namespace anubarak\seeder\console\controllers;

use studioespresso\seeder\records\SeederAssetRecord;
use studioespresso\seeder\records\SeederEntryRecord;
use studioespresso\seeder\records\SeederUserRecord;
use studioespresso\seeder\Seeder;
use anubarak\seeder\records\SeederAssetRecord;
use anubarak\seeder\records\SeederEntryRecord;
use anubarak\seeder\records\SeederUserRecord;
use anubarak\seeder\Seeder;

use Craft;
use studioespresso\seeder\services\Seeder_EntriesService;
use anubarak\seeder\services\Seeder_EntriesService;
use yii\console\Controller;
use yii\helpers\Console;

Expand Down
Loading

0 comments on commit 02f6ea1

Please sign in to comment.