Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Update module template
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Dec 15, 2014
1 parent 5781774 commit a025567
Show file tree
Hide file tree
Showing 21 changed files with 181 additions and 37 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
},
"require": {
"php": ">=5.3.23",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-json": "*",
"francodacosta/phmagick": "0.4.*@dev",
Expand All @@ -25,22 +24,23 @@
"reprovinci/solr-php-client": "~1.0.3",
"rhumsaa/uuid": "~2.8.0",
"sendgrid/sendgrid": "~2.1.1",
"symfony/console": "~2.5.7",
"zendframework/zendframework1": "~1.12.9"
},
"require-dev": {
"ext-curl": "*",
"fabpot/php-cs-fixer": "~1.1",
"fabpot/php-cs-fixer": "~1.3",
"jokkedk/zfdebug": "~1.6.2",
"phpcheckstyle/phpcheckstyle": "V0.14.1",
"phpunit/dbunit": "1.3.*@dev",
"phpunit/php-code-coverage": "~2.0.11",
"phpunit/php-code-coverage": "~2.0.13",
"phpunit/phpcov": "~2.0.1",
"phpunit/phpunit": "~4.3.5",
"satooshi/php-coveralls": "~0.6.1",
"sensiolabs/security-checker": "~2.0.0"
"sensiolabs/security-checker": "~2.0.0",
"symfony/console": "~2.5.8"
},
"suggest": {
"ext-fileinfo": "*",
"ext-imagick": "*",
"ext-ldap": "*",
"ext-memcached": "*",
Expand Down
23 changes: 19 additions & 4 deletions utils/NewModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,29 @@
# limitations under the License.
#=============================================================================

# This CMake script should be used to create a new Midas module.
# This script should be used to create a new module in modules directory.
# Call as
# cmake -P NewModule.cmake modulename
# Where modulename is the name of your module. It should have no spaces in it.
# cmake -P NewModule.cmake modulename
# Where modulename is the name of your module. The name should contain no spaces.
#
cmake_minimum_required(VERSION 2.8.7)
if(NOT DEFINED CMAKE_ARGV3)
message(FATAL_ERROR "Must pass in module name as an argument: cmake -P NewModule.cmake mymodule")
message(FATAL_ERROR "Must pass in module name as an argument: cmake -P NewModule.cmake mymodule")
endif()

find_file(COMPOSER_LOCK "composer.lock" PATHS ${CMAKE_CURRENT_LIST_DIR}/../ NO_DEFAULT_PATH DOC "Path to the composer lock file")
if(NOT COMPOSER_LOCK)
message(FATAL_ERROR "Must run composer install before creating a module")
endif()

set(MUUID "00000000-0000-4000-a000-000000000000")
find_program(PHP "php" DOC "Path to php")
if(PHP)
find_program(UUID "uuid" PATHS ${CMAKE_CURRENT_LIST_DIR}/../vendor/bin NO_DEFAULT_PATH DOC "Path to uuid")
if(UUID)
execute_process(COMMAND ${PHP} ${UUID} generate 4 OUTPUT_VARIABLE MUUID_OUTPUT)
string(STRIP ${MUUID_OUTPUT} MUUID)
endif()
endif()

set(moduleName "${CMAKE_ARGV3}")
Expand Down
7 changes: 6 additions & 1 deletion utils/moduleTemplate/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
limitations under the License.
=========================================================================*/

/** App controller for the @MN@ module */
/**
* Generic controller class for the @MN@ module.
*
* @package Modules\@MN_CAP@\Controller
*/
class @MN_CAP@_AppController extends MIDAS_GlobalModule
{
/** @var string */
public $moduleName = '@MN@';
}
7 changes: 6 additions & 1 deletion utils/moduleTemplate/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
limitations under the License.
=========================================================================*/

/** Bootstrap for the @MN@ module. */
/**
* Bootstrap for the @MN@ module.
*
* @package Modules\@MN_CAP@\Bootstrap
*/
class @MN_CAP@_Bootstrap extends Zend_Application_Module_Bootstrap
{
/** @var string */
public $moduleName = '@MN@';
}
12 changes: 9 additions & 3 deletions utils/moduleTemplate/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
limitations under the License.
=========================================================================*/

/** Notification manager for the @MN@ module */
/**
* Notification manager for the @MN@ module.
*
* @package Modules\@MN_CAP@\Notification
*/
class @MN_CAP@_Notification extends MIDAS_Notification
{
/** @var string */
public $moduleName = '@MN@';

/** Init notification process */
/** @TODO Initialize the notification process. */
public function init()
{
$fc = Zend_Controller_Front::getInstance();
Expand All @@ -34,13 +39,14 @@ public function init()
}

/**
* STUB: Example of receiving a callback when an item is deleted
* @TODO Handle the callback when an item is deleted.
*
* @param array $params parameters
*/
public function handleItemDeleted($params)
{
$itemDao = $params['item'];

// TODO: Do something with this item DAO
}
}
2 changes: 1 addition & 1 deletion utils/moduleTemplate/configs/module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ category = "Contributed"
; comma separated list of module dependencies, if any
dependencies =
; generated unique identifier
uuid =
uuid = "@MUUID@"
; semantic version number (>= "1.0.0")
version = "1.0.0"
41 changes: 27 additions & 14 deletions utils/moduleTemplate/controllers/ThingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,27 @@
limitations under the License.
=========================================================================*/

/** Controller template for the @MN@ module */
/**
* Thing controller for the @MN@ module.
*
* @package Modules\@MN_CAP@\Controller
*/
class @MN_CAP@_ThingController extends @MN_CAP@_AppController
{
/** @var array */
public $_components = array();

/** @var array */
public $_models = array();
public $_moduleModels = array();

/** STUB: Example get action */
public function getAction()
{
$id = $this->_getParam('id');
$this->view->id = $id;
}
/** @var array */
public $_moduleComponents = array();

/** @var array */
public $_moduleModels = array();

/** STUB: Example create action */
public function createAction()
/** @TODO Delete action. */
public function deleteAction()
{
$this->disableLayout();
$this->disableView();
Expand All @@ -41,8 +47,15 @@ public function createAction()
);
}

/** STUB: Example update action */
public function updateAction()
/** @TODO Get action. */
public function getAction()
{
$id = $this->_getParam('id');
$this->view->id = $id;
}

/** @TODO Patch action. */
public function patchAction()
{
$this->disableLayout();
$this->disableView();
Expand All @@ -51,8 +64,8 @@ public function updateAction()
);
}

/** STUB: Example delete action */
public function deleteAction()
/** @TODO Post action. */
public function postAction()
{
$this->disableLayout();
$this->disableView();
Expand Down
7 changes: 6 additions & 1 deletion utils/moduleTemplate/models/AppDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
limitations under the License.
=========================================================================*/

/** App DAO for the @MN@ module */
/**
* Generic DAO class for the @MN@ module.
*
* @package Modules\@MN_CAP@\DAO
*/
class @MN_CAP@_AppDao extends MIDAS_GlobalDao
{
/** @var string */
public $_module = '@MN@';
}
7 changes: 6 additions & 1 deletion utils/moduleTemplate/models/AppModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
limitations under the License.
=========================================================================*/

/** Base model class for the @MN@ module */
/**
* Generic model class for the @MN@ module.
*
* @package Modules\@MN_CAP@\Model
*/
class @MN_CAP@_AppModel extends MIDASModel
{
/** @var string */
public $moduleName = '@MN@';
}
9 changes: 7 additions & 2 deletions utils/moduleTemplate/models/base/ThingModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
limitations under the License.
=========================================================================*/

/** Base model class template for the @MN@ module */
/**
* Thing model base class for the @MN@ module.
*
* @package Modules\@MN_CAP@\Model
*/
abstract class @MN_CAP@_ThingModelBase extends @MN_CAP@_AppModel
{
/** Constructor */
/** Constructor. */
public function __construct()
{
parent::__construct();
Expand All @@ -32,6 +36,7 @@ public function __construct()
'thing_id' => array('type' => MIDAS_DATA),
'creation_date' => array('type' => MIDAS_DATA)
);

$this->initialize();
}
}
12 changes: 10 additions & 2 deletions utils/moduleTemplate/models/dao/ThingDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@
limitations under the License.
=========================================================================*/

/** DAO template for the @MN@ module */
/**
* Thing DAO for the @MN@ module.
*
* @method int getThingId()
* @method void setThingId(int $thingId)
* @method string getCreationDate()
* @method void setCreationDate(string $creationDate)
* @package Modules\@MN_CAP@\DAO
*/
class @MN_CAP@_ThingDao extends @MN_CAP@_AppDao
{
/** @var string */
public $_model = 'Thing';
public $_module = '@MN@';
}
6 changes: 5 additions & 1 deletion utils/moduleTemplate/models/pdo/ThingModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

require_once BASE_PATH.'/modules/@MN@/models/base/ThingModelBase.php';

/** PDO model template for the @MN@ module */
/**
* Thing model for the @MN@ module.
*
* @package Modules\@MN_CAP@\Model
*/
class @MN_CAP@_ThingModel extends @MN_CAP@_ThingModelBase
{
}
Empty file.
1 change: 1 addition & 0 deletions utils/moduleTemplate/public/css/thing/thing.get.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
1 change: 1 addition & 0 deletions utils/moduleTemplate/public/js/thing/thing.get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.
1 change: 1 addition & 0 deletions utils/moduleTemplate/public/scss/thing/thing.get.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0. */
Empty file.
20 changes: 20 additions & 0 deletions utils/moduleTemplate/tests/controllers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#=============================================================================
# MIDAS Server
# Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
# All rights reserved.
# More information http://www.kitware.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

add_midas_test(${module_name_titlecase}ThingController ThingControllerTest.php)
46 changes: 46 additions & 0 deletions utils/moduleTemplate/tests/controllers/ThingControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
All rights reserved.
More information http://www.kitware.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

/** Thing controller test for the @MN@ module. */
class @MN_CAP@_ThingControllerTest extends ControllerTestCase
{
/** @TODO Setup the tests. */
public function setUp()
{
$this->enabledModules = array('@MN@');

parent::setUp();
}

/** @TODO Test the get action. */
public function testGetAction()
{
$params = array('action' => 'get', 'controller' => 'Thing', 'module' => '@MN@');
$urlParams = $this->urlizeOptions($params);
$id = 1;
$url = $this->url($urlParams, '@MN@-1').'?id='.$id;
$this->dispatch($url);

$this->assertModule($urlParams['module']);
$this->assertController($urlParams['controller']);
$this->assertAction($urlParams['action']);
$this->assertQueryContentContains('div.viewMain p', 'The id parameter passed in is: '.$id.'.');
}
}
6 changes: 5 additions & 1 deletion utils/moduleTemplate/views/thing/get.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

$this->declareVars('id');
$this->headLink()->appendStylesheet($this->baseUrl('modules/@MN@/public/css/thing/thing.get.css'));
$this->headScript()->appendFile($this->baseUrl('modules/@MN@/public/js/thing/thing.get.js'));
?>

<div class="viewMain">
The id parameter passed in is: <?php echo $this->escape($this->id); ?>
<p>The id parameter passed in is: <?php echo $this->escape($this->id); ?>.</p>
</div>

0 comments on commit a025567

Please sign in to comment.