Created
January 28, 2017 10:09
-
-
Save woutersf/d54ebd8b56850b6f4a809650ee5fd00e to your computer and use it in GitHub Desktop.
custom drupal bootstrap (for performance)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(empty($_GET['submithandler']) && empty($_POST['submithandler'])) { | |
http_response_code(400); | |
die('Invalid data'); | |
} | |
define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']); | |
require_once DRUPAL_ROOT. '/includes/bootstrap.inc'; | |
require_once DRUPAL_ROOT. '/includes/common.inc'; | |
require_once DRUPAL_ROOT. '/includes/file.inc'; | |
require_once DRUPAL_ROOT. '/includes/theme.inc'; | |
if(isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) { | |
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}"); | |
} | |
/**** angular ***/ | |
header('Access-Control-Allow-Origin: *'); | |
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); | |
header('Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS'); | |
/**** ***/ | |
/****************************** sROUTING **************************************/ | |
// Handle POST requests | |
switch($_GET['submithandler']) { | |
case "my_custom_thingie": | |
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); | |
/** | |
DRUPAL_BOOTSTRAP_CONFIGURATION, | |
DRUPAL_BOOTSTRAP_PAGE_CACHE, | |
DRUPAL_BOOTSTRAP_DATABASE, | |
DRUPAL_BOOTSTRAP_VARIABLES, | |
DRUPAL_BOOTSTRAP_SESSION, | |
DRUPAL_BOOTSTRAP_PAGE_HEADER, | |
DRUPAL_BOOTSTRAP_LANGUAGE, | |
DRUPAL_BOOTSTRAP_FULL, | |
*/ | |
//If this is neede (not always) | |
// module_load_all(); | |
//Do custom thing that only bootstraps db (for example) | |
dako_search_ajax(); | |
break; | |
default: | |
http_response_code(400); | |
die('Invalid data'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment