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

Commit a025567

Browse files
author
Jamie Snape
committed
Update module template
1 parent 5781774 commit a025567

File tree

21 files changed

+181
-37
lines changed

21 files changed

+181
-37
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
},
1313
"require": {
1414
"php": ">=5.3.23",
15-
"ext-fileinfo": "*",
1615
"ext-gd": "*",
1716
"ext-json": "*",
1817
"francodacosta/phmagick": "0.4.*@dev",
@@ -25,22 +24,23 @@
2524
"reprovinci/solr-php-client": "~1.0.3",
2625
"rhumsaa/uuid": "~2.8.0",
2726
"sendgrid/sendgrid": "~2.1.1",
28-
"symfony/console": "~2.5.7",
2927
"zendframework/zendframework1": "~1.12.9"
3028
},
3129
"require-dev": {
3230
"ext-curl": "*",
33-
"fabpot/php-cs-fixer": "~1.1",
31+
"fabpot/php-cs-fixer": "~1.3",
3432
"jokkedk/zfdebug": "~1.6.2",
3533
"phpcheckstyle/phpcheckstyle": "V0.14.1",
3634
"phpunit/dbunit": "1.3.*@dev",
37-
"phpunit/php-code-coverage": "~2.0.11",
35+
"phpunit/php-code-coverage": "~2.0.13",
3836
"phpunit/phpcov": "~2.0.1",
3937
"phpunit/phpunit": "~4.3.5",
4038
"satooshi/php-coveralls": "~0.6.1",
41-
"sensiolabs/security-checker": "~2.0.0"
39+
"sensiolabs/security-checker": "~2.0.0",
40+
"symfony/console": "~2.5.8"
4241
},
4342
"suggest": {
43+
"ext-fileinfo": "*",
4444
"ext-imagick": "*",
4545
"ext-ldap": "*",
4646
"ext-memcached": "*",

utils/NewModule.cmake

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,29 @@
1717
# limitations under the License.
1818
#=============================================================================
1919

20-
# This CMake script should be used to create a new Midas module.
20+
# This script should be used to create a new module in modules directory.
2121
# Call as
22-
# cmake -P NewModule.cmake modulename
23-
# Where modulename is the name of your module. It should have no spaces in it.
22+
# cmake -P NewModule.cmake modulename
23+
# Where modulename is the name of your module. The name should contain no spaces.
2424
#
2525
cmake_minimum_required(VERSION 2.8.7)
2626
if(NOT DEFINED CMAKE_ARGV3)
27-
message(FATAL_ERROR "Must pass in module name as an argument: cmake -P NewModule.cmake mymodule")
27+
message(FATAL_ERROR "Must pass in module name as an argument: cmake -P NewModule.cmake mymodule")
28+
endif()
29+
30+
find_file(COMPOSER_LOCK "composer.lock" PATHS ${CMAKE_CURRENT_LIST_DIR}/../ NO_DEFAULT_PATH DOC "Path to the composer lock file")
31+
if(NOT COMPOSER_LOCK)
32+
message(FATAL_ERROR "Must run composer install before creating a module")
33+
endif()
34+
35+
set(MUUID "00000000-0000-4000-a000-000000000000")
36+
find_program(PHP "php" DOC "Path to php")
37+
if(PHP)
38+
find_program(UUID "uuid" PATHS ${CMAKE_CURRENT_LIST_DIR}/../vendor/bin NO_DEFAULT_PATH DOC "Path to uuid")
39+
if(UUID)
40+
execute_process(COMMAND ${PHP} ${UUID} generate 4 OUTPUT_VARIABLE MUUID_OUTPUT)
41+
string(STRIP ${MUUID_OUTPUT} MUUID)
42+
endif()
2843
endif()
2944

3045
set(moduleName "${CMAKE_ARGV3}")

utils/moduleTemplate/AppController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** App controller for the @MN@ module */
21+
/**
22+
* Generic controller class for the @MN@ module.
23+
*
24+
* @package Modules\@MN_CAP@\Controller
25+
*/
2226
class @MN_CAP@_AppController extends MIDAS_GlobalModule
2327
{
28+
/** @var string */
2429
public $moduleName = '@MN@';
2530
}

utils/moduleTemplate/Bootstrap.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** Bootstrap for the @MN@ module. */
21+
/**
22+
* Bootstrap for the @MN@ module.
23+
*
24+
* @package Modules\@MN_CAP@\Bootstrap
25+
*/
2226
class @MN_CAP@_Bootstrap extends Zend_Application_Module_Bootstrap
2327
{
28+
/** @var string */
2429
public $moduleName = '@MN@';
2530
}

utils/moduleTemplate/Notification.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** Notification manager for the @MN@ module */
21+
/**
22+
* Notification manager for the @MN@ module.
23+
*
24+
* @package Modules\@MN_CAP@\Notification
25+
*/
2226
class @MN_CAP@_Notification extends MIDAS_Notification
2327
{
28+
/** @var string */
2429
public $moduleName = '@MN@';
2530

26-
/** Init notification process */
31+
/** @TODO Initialize the notification process. */
2732
public function init()
2833
{
2934
$fc = Zend_Controller_Front::getInstance();
@@ -34,13 +39,14 @@ public function init()
3439
}
3540

3641
/**
37-
* STUB: Example of receiving a callback when an item is deleted
42+
* @TODO Handle the callback when an item is deleted.
3843
*
3944
* @param array $params parameters
4045
*/
4146
public function handleItemDeleted($params)
4247
{
4348
$itemDao = $params['item'];
49+
4450
// TODO: Do something with this item DAO
4551
}
4652
}

utils/moduleTemplate/configs/module.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ category = "Contributed"
1010
; comma separated list of module dependencies, if any
1111
dependencies =
1212
; generated unique identifier
13-
uuid =
13+
uuid = "@MUUID@"
1414
; semantic version number (>= "1.0.0")
1515
version = "1.0.0"

utils/moduleTemplate/controllers/ThingController.php

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,27 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** Controller template for the @MN@ module */
21+
/**
22+
* Thing controller for the @MN@ module.
23+
*
24+
* @package Modules\@MN_CAP@\Controller
25+
*/
2226
class @MN_CAP@_ThingController extends @MN_CAP@_AppController
2327
{
28+
/** @var array */
29+
public $_components = array();
30+
31+
/** @var array */
2432
public $_models = array();
25-
public $_moduleModels = array();
2633

27-
/** STUB: Example get action */
28-
public function getAction()
29-
{
30-
$id = $this->_getParam('id');
31-
$this->view->id = $id;
32-
}
34+
/** @var array */
35+
public $_moduleComponents = array();
36+
37+
/** @var array */
38+
public $_moduleModels = array();
3339

34-
/** STUB: Example create action */
35-
public function createAction()
40+
/** @TODO Delete action. */
41+
public function deleteAction()
3642
{
3743
$this->disableLayout();
3844
$this->disableView();
@@ -41,8 +47,15 @@ public function createAction()
4147
);
4248
}
4349

44-
/** STUB: Example update action */
45-
public function updateAction()
50+
/** @TODO Get action. */
51+
public function getAction()
52+
{
53+
$id = $this->_getParam('id');
54+
$this->view->id = $id;
55+
}
56+
57+
/** @TODO Patch action. */
58+
public function patchAction()
4659
{
4760
$this->disableLayout();
4861
$this->disableView();
@@ -51,8 +64,8 @@ public function updateAction()
5164
);
5265
}
5366

54-
/** STUB: Example delete action */
55-
public function deleteAction()
67+
/** @TODO Post action. */
68+
public function postAction()
5669
{
5770
$this->disableLayout();
5871
$this->disableView();

utils/moduleTemplate/models/AppDao.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** App DAO for the @MN@ module */
21+
/**
22+
* Generic DAO class for the @MN@ module.
23+
*
24+
* @package Modules\@MN_CAP@\DAO
25+
*/
2226
class @MN_CAP@_AppDao extends MIDAS_GlobalDao
2327
{
28+
/** @var string */
2429
public $_module = '@MN@';
2530
}

utils/moduleTemplate/models/AppModel.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** Base model class for the @MN@ module */
21+
/**
22+
* Generic model class for the @MN@ module.
23+
*
24+
* @package Modules\@MN_CAP@\Model
25+
*/
2226
class @MN_CAP@_AppModel extends MIDASModel
2327
{
28+
/** @var string */
2429
public $moduleName = '@MN@';
2530
}

utils/moduleTemplate/models/base/ThingModelBase.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** Base model class template for the @MN@ module */
21+
/**
22+
* Thing model base class for the @MN@ module.
23+
*
24+
* @package Modules\@MN_CAP@\Model
25+
*/
2226
abstract class @MN_CAP@_ThingModelBase extends @MN_CAP@_AppModel
2327
{
24-
/** Constructor */
28+
/** Constructor. */
2529
public function __construct()
2630
{
2731
parent::__construct();
@@ -32,6 +36,7 @@ public function __construct()
3236
'thing_id' => array('type' => MIDAS_DATA),
3337
'creation_date' => array('type' => MIDAS_DATA)
3438
);
39+
3540
$this->initialize();
3641
}
3742
}

0 commit comments

Comments
 (0)