Skip to content

Commit

Permalink
Plugin mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenckens committed Mar 23, 2018
1 parent c061938 commit 9198d9a
Show file tree
Hide file tree
Showing 20 changed files with 785 additions and 0 deletions.
1 change: 1 addition & 0 deletions .craftplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pluginName":"Seeder","pluginDescription":"Easy entries seeder for Craft CMS","pluginVersion":"1.0.0","pluginAuthorName":"Studio Espresso","pluginVendorName":"","pluginAuthorUrl":"https://www.studioepsresso.co","pluginAuthorGithub":"studioespresso","codeComments":"yes","pluginComponents":"","consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Seeder Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.0 - 2018-03-21
### Added
- Initial release
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2018 Studio Espresso

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Seeder plugin for Craft CMS 3.x

Easy entries seeder for Craft CMS
45 changes: 45 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "studioespresso/craft-seeder",
"description": "Easy entries seeder for Craft CMS",
"type": "craft-plugin",
"version": "1.0.0",
"keywords": [
"craft",
"cms",
"craftcms",
"craft-plugin",
"seeder"
],
"support": {
"docs": "https://github.com/studioespresso/seeder/blob/master/README.md",
"issues": "https://github.com/studioespresso/seeder/issues"
},
"license": "MIT",
"authors": [
{
"name": "Studio Espresso",
"homepage": "https://www.studioepsresso.co"
}
],
"require": {
"craftcms/cms": "^3.0.0-RC1",
"fzaninotto/faker": "^1.7.0"
},
"autoload": {
"psr-4": {
"studioespresso\\seeder\\": "src/"
}
},
"extra": {
"name": "Seeder",
"handle": "seeder",
"hasCpSettings": false,
"hasCpSection": false,
"components": {
"entries": "studioespresso\\seeder\\services\\Entries",
"fields": "studioespresso\\seeder\\services\\Fields"
},
"changelogUrl": "https://raw.githubusercontent.com/studioespresso/seeder/master/CHANGELOG.md",
"class": "studioespresso\\seeder\\Seeder"
}
}
109 changes: 109 additions & 0 deletions src/Seeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?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\Entries as EntriesService;
use studioespresso\seeder\services\Fields as FieldsService;

use Craft;
use craft\base\Plugin;
use craft\services\Plugins;
use craft\events\PluginEvent;
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 EntriesService entries
* @property FieldsService fields
* @property Settings $settings
* @method Settings getSettings()
*/
class Seeder extends Plugin
{
// Static Properties
// =========================================================================

/**
* Static property that is an instance of this plugin class so that it can be accessed via
* Seeder::$plugin
*
* @var Seeder
*/
public static $plugin;

// Public Properties
// =========================================================================

/**
* To execute your plugin’s migrations, you’ll need to increase its schema version.
*
* @var string
*/
public $schemaVersion = '1.0.0';

// Public Methods
// =========================================================================

public function init() {
parent::init();
self::$plugin = $this;

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

// Protected Methods
// =========================================================================

/**
* Creates and returns the model used to store the plugin’s settings.
*
* @return \craft\base\Model|null
*/
protected function createSettingsModel()
{
return new Settings();
}

/**
* Returns the rendered settings HTML, which will be inserted into the content
* block on the settings page.
*
* @return string The rendered settings HTML
*/
protected function settingsHtml(): string
{
return Craft::$app->view->renderTemplate(
'seeder/settings',
[
'settings' => $this->getSettings()
]
);
}
}
65 changes: 65 additions & 0 deletions src/assetbundles/seeder/SeederAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?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\assetbundles\Seeder;

use Craft;
use craft\web\AssetBundle;
use craft\web\assets\cp\CpAsset;

/**
* SeederAsset AssetBundle
*
* AssetBundle represents a collection of asset files, such as CSS, JS, images.
*
* Each asset bundle has a unique name that globally identifies it among all asset bundles used in an application.
* The name is the [fully qualified class name](http://php.net/manual/en/language.namespaces.rules.php)
* of the class representing it.
*
* An asset bundle can depend on other asset bundles. When registering an asset bundle
* with a view, all its dependent asset bundles will be automatically registered.
*
* http://www.yiiframework.com/doc-2.0/guide-structure-assets.html
*
* @author Studio Espresso
* @package Seeder
* @since 1.0.0
*/
class SeederAsset extends AssetBundle
{
// Public Methods
// =========================================================================

/**
* Initializes the bundle.
*/
public function init()
{
// define the path that your publishable resources live
$this->sourcePath = "@studioespresso/seeder/assetbundles/seeder/dist";

// define the dependencies
$this->depends = [
CpAsset::class,
];

// define the relative path to CSS/JS files that should be registered with the page
// when this asset bundle is registered
$this->js = [
'js/Seeder.js',
];

$this->css = [
'css/Seeder.css',
];

parent::init();
}
}
11 changes: 11 additions & 0 deletions src/assetbundles/seeder/dist/css/Seeder.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Seeder plugin for Craft CMS
*
* Seeder CSS
*
* @author Studio Espresso
* @copyright Copyright (c) 2018 Studio Espresso
* @link https://studioespresso.co
* @package Seeder
* @since 1.0.0
*/
52 changes: 52 additions & 0 deletions src/assetbundles/seeder/dist/img/Seeder-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/assetbundles/seeder/dist/js/Seeder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Seeder plugin for Craft CMS
*
* Seeder JS
*
* @author Studio Espresso
* @copyright Copyright (c) 2018 Studio Espresso
* @link https://studioespresso.co
* @package Seeder
* @since 1.0.0
*/
30 changes: 30 additions & 0 deletions src/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Seeder plugin for Craft CMS 3.x
*
* Entries seeder for Craft CMS
*
* @link https://studioespresso.co
* @copyright Copyright (c) 2018 Studio Espresso
*/

/**
* Seeder config.php
*
* This file exists only as a template for the Seeder settings.
* It does nothing on its own.
*
* Don't edit this file, instead copy it to 'craft/config' as 'seeder.php'
* and make your changes there to override default settings.
*
* Once copied to 'craft/config', this file will be multi-environment aware as
* well, so you can have different settings groups for each environment, just as
* you do for 'general.php'
*/

return [

// This controls blah blah blah
"someAttribute" => true,

];
Loading

0 comments on commit 9198d9a

Please sign in to comment.