From 14da371cedd708a0e20c9fa65106a53ca83f3064 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 5 Apr 2018 15:27:04 +1200 Subject: [PATCH] Shift code into app/src Add autoloading bootstrapping --- app/src/Page.php | 13 +++++++++++++ app/src/PageController.php | 33 +++++++++++++++++++++++++++++++++ composer.json | 9 ++++++++- mysite/code/Page.php | 10 ---------- mysite/code/PageController.php | 30 ------------------------------ 5 files changed, 54 insertions(+), 41 deletions(-) create mode 100755 app/src/Page.php create mode 100644 app/src/PageController.php delete mode 100755 mysite/code/Page.php delete mode 100644 mysite/code/PageController.php diff --git a/app/src/Page.php b/app/src/Page.php new file mode 100755 index 0000000..d5d11e7 --- /dev/null +++ b/app/src/Page.php @@ -0,0 +1,13 @@ + + * [ + * 'action', // anyone can access this action + * 'action' => true, // same as above + * 'action' => 'ADMIN', // you must have ADMIN permissions to access this action + * 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true + * ]; + * + * + * @var array + */ + private static $allowed_actions = []; + + protected function init() + { + parent::init(); + // You can include any CSS or JS required by your project here. + // See: https://docs.silverstripe.org/en/developer_guides/templates/requirements/ + } + } +} diff --git a/composer.json b/composer.json index b3f398b..61e4a93 100644 --- a/composer.json +++ b/composer.json @@ -20,9 +20,16 @@ "require-dev": { "phpunit/PHPUnit": "^5.7" }, + "autoload": { + "psr-4": {}, + "classmap": [ + "app/src/Page.php", + "app/src/PageController.php" + ] + }, "extra": { "project-files": [ - "mysite/code/*" + "app/src/*" ], "branch-alias": { "1.x-dev": "1.2.x-dev" diff --git a/mysite/code/Page.php b/mysite/code/Page.php deleted file mode 100755 index 6300926..0000000 --- a/mysite/code/Page.php +++ /dev/null @@ -1,10 +0,0 @@ - - * [ - * 'action', // anyone can access this action - * 'action' => true, // same as above - * 'action' => 'ADMIN', // you must have ADMIN permissions to access this action - * 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true - * ]; - * - * - * @var array - */ - private static $allowed_actions = []; - - protected function init() - { - parent::init(); - // You can include any CSS or JS required by your project here. - // See: https://docs.silverstripe.org/en/developer_guides/templates/requirements/ - } -}