Skip to content
Snippets Groups Projects
Commit ecd62bdf authored by Nick Vanpraet's avatar Nick Vanpraet
Browse files

wip requirements

parent 563a0b7d
No related tags found
No related merge requests found
......@@ -13,4 +13,18 @@ function rocketship_core_install() {
$blazySettings->set('responsive_image', TRUE);
$blazySettings->save();
}
}
\ No newline at end of file
}
/**
* Implements hook_requirements().
*/
function rocketship_core_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
}
return $requirements;
}
......@@ -9,3 +9,6 @@ services:
arguments: ['@entity_type.manager', '@config.factory', '@redirect.repository']
tags:
- { name: event_subscriber }
rocketship_core.requirements:
class: Drupal\rocketship_core\RocketshipCoreRequirements
arguments: ['@module_handler']
<?php
namespace Drupal\rocketship_core;
/**
* Class RocketshipCoreRequirementResult
*
* @package Drupal\rocketship_core
*/
class RocketshipCoreRequirementResult {
/**
* @var int
*/
public $flag;
/**
* @var string
*/
public $title;
/**
* @var string
*/
public $message;
/**
* @var string|null
*/
public $description;
/**
* RocketshipCoreRequirementResult constructor.
*
* @param int $flag
* @param string $title
* @param string $message
* @param string $description
*/
public function __construct(int $flag, string $title, string $message, ?string $description = NULL) {
$this->flag = $flag;
$this->message = $message;
$this->description = $description;
$this->title = $title;
}
}
<?php
namespace Drupal\rocketship_core;
use Drupal\Core\Access\AccessResult;
use \Drupal\Core\Extension\ModuleHandlerInterface;
class RocketshipCoreRequirements {
/**
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* RocketshipCoreRequirements constructor.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
*/
public function __construct(ModuleHandlerInterface $moduleHandler) {
$this->moduleHandler = $moduleHandler;
}
/**
* @return \Drupal\rocketship_core\RocketshipCoreRequirementResult
*/
public function validateProjectEnvironmentNameConstantRequirements() {
if (!ROCKETSHIP_PROJECT_ENVIRONMENT) {
return new RocketshipCoreRequirementResult(
REQUIREMENT_ERROR,
'Rocketship: ROCKETSHIP_PROJECT_ENVIRONMENT constant',
'Constant has not been set up'
);
}
else {
return new RocketshipCoreRequirementResult(
REQUIREMENT_OK,
'Rocketship: ROCKETSHIP_PROJECT_ENVIRONMENT constant',
'Constant has been set up: ' . ROCKETSHIP_PROJECT_ENVIRONMENT
);
}
}
/**
* @return \Drupal\rocketship_core\RocketshipCoreRequirementResult
*/
public function validateProjectNameConstantRequirements() {
if (!ROCKETSHIP_PROJECT_NAME) {
return new RocketshipCoreRequirementResult(
REQUIREMENT_ERROR,
'Rocketship: ROCKETSHIP_PROJECT_NAME constant',
'Constant has not been set up'
);
}
else {
return new RocketshipCoreRequirementResult(
REQUIREMENT_OK,
'Rocketship: ROCKETSHIP_PROJECT_NAME constant',
'Constant has been set up: ' . ROCKETSHIP_PROJECT_NAME
);
}
}
/**
* @return \Drupal\rocketship_core\RocketshipCoreRequirementResult
*/
public function validateMemcacheRequirements() {
$title = 'Rocketship: Memcache';
if ($this->moduleHandler->moduleExists('redis')) {
// If redis is running, we don't care about Memcache
return new RocketshipCoreRequirementResult(
REQUIREMENT_OK,
$title,
'Redis detected. Ignoring Memcache requirements.'
);
}
$memcache_exists = extension_loaded('memcache');
$memcached_exists = extension_loaded('memcached');
if (!$memcache_exists && !$memcached_exists) {
return new RocketshipCoreRequirementResult(
REQUIREMENT_WARNING,
$title,
'The Memcache(d) PHP extension isn\'t installed.'
);
}
if (!$this->moduleHandler->moduleExists('memcache')) {
return new RocketshipCoreRequirementResult(
REQUIREMENT_ERROR,
$title,
'Memcache has not been correctly set up.',
'The Memcache Drupal module has not been installed.'
);
}
if (!ROCKETSHIP_PROJECT_NAME || !ROCKETSHIP_MEMCACHE_READY_FOR_USE || !ROCKETSHIP_PROJECT_ENVIRONMENT) {
return new RocketshipCoreRequirementResult(
REQUIREMENT_ERROR,
$title,
'Memcache has not been correctly set up.',
'The constants in the settings files are not correctly configured.'
);
}
return new RocketshipCoreRequirementResult(
REQUIREMENT_OK,
$title,
'Memcache has been correctly set up.'
);
}
public function validatePurgeRequirements() {
if (!$this->moduleHandler->moduleExists('purge')) {
// If purge isn't enabled... warning?
}
}
// Ensure all content has human readable URL
// join node and alias table, report nulls?
// Google Analytics enabled and set up
// check google_tag is installed, check if A non-default container exists
// frontpage has meta description and title
// load and check
// check image toolkit setting is set to 75%
// xml sitemap (Simple Sitemap) check already exists
// check reroute_email is disabled on env live
// ? if recaptcha installed, check config has a key?
// need to look into what captcha stuff is needed
// check page cache is installed and set up
// check website title and email are filled in
// purge check (on all non-local envs?)
// memcache check (unless redis is installed)
//
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment