Shift code into app/src

Add autoloading bootstrapping
This commit is contained in:
Damian Mooyman 2018-04-05 15:27:04 +12:00
parent fe388639d9
commit 14da371ced
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
5 changed files with 54 additions and 41 deletions

13
app/src/Page.php Executable file
View File

@ -0,0 +1,13 @@
<?php
namespace {
use SilverStripe\CMS\Model\SiteTree;
class Page extends SiteTree
{
private static $db = [];
private static $has_one = [];
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace {
use SilverStripe\CMS\Controllers\ContentController;
class PageController extends ContentController
{
/**
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
* permissions or conditions required to allow the user to access it.
*
* <code>
* [
* '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
* ];
* </code>
*
* @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/
}
}
}

View File

@ -20,9 +20,16 @@
"require-dev": { "require-dev": {
"phpunit/PHPUnit": "^5.7" "phpunit/PHPUnit": "^5.7"
}, },
"autoload": {
"psr-4": {},
"classmap": [
"app/src/Page.php",
"app/src/PageController.php"
]
},
"extra": { "extra": {
"project-files": [ "project-files": [
"mysite/code/*" "app/src/*"
], ],
"branch-alias": { "branch-alias": {
"1.x-dev": "1.2.x-dev" "1.x-dev": "1.2.x-dev"

View File

@ -1,10 +0,0 @@
<?php
use SilverStripe\CMS\Model\SiteTree;
class Page extends SiteTree
{
private static $db = [];
private static $has_one = [];
}

View File

@ -1,30 +0,0 @@
<?php
use SilverStripe\CMS\Controllers\ContentController;
class PageController extends ContentController
{
/**
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
* permissions or conditions required to allow the user to access it.
*
* <code>
* [
* '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
* ];
* </code>
*
* @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/
}
}