Skip to content

Commit

Permalink
Merge pull request #1078 from humanmade/630-documentation-linting-issues
Browse files Browse the repository at this point in the history
Reformat docs files after linting
  • Loading branch information
mikelittle authored Jul 15, 2024
2 parents 2563599 + bd2d399 commit 1001179
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Import Travis configuration from dev-tools repo
version: ~> 1.0
import:
- source: humanmade/altis-dev-tools:travis/module.yml@4accc74
- source: humanmade/altis-dev-tools:travis/module.yml@0bfa112a
mode: deep_merge_append

# Add your custom config below, which will merge with the default module config from the section above.
95 changes: 56 additions & 39 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Core

![](./assets/banner-core.png)
![Core banner](./assets/banner-core.png)

The core module provides the entry point for platform code. It includes functionality for retrieving information about the current environment, the module registry, plus parsing and reading the project configuration.
The core module provides the entry point for platform code. It includes functionality for retrieving information about the current
environment, the module registry, plus parsing and reading the project configuration.

**Note:** all functions documented below are under the `Altis` namespace.

Expand All @@ -16,72 +17,81 @@ Returns the current hosting stack name based on the `HM_ENV` constant. On local

**`get_environment_type() : string`**

Returns one of `local`, `development`, `staging` or `production`. This is read from the `HM_ENV_TYPE` constant except on local setups.
Returns one of `local`, `development`, `staging` or `production`. This is read from the `HM_ENV_TYPE` constant except on local
setups.

**`get_environment_region() : ?string`**

Returns the current AWS application's region based on the `HM_ENV_REGION` constant. On local setups or if the region is not set this will return `null`. The region can be `us-east-1`, `ap-northeast-1`, `eu-central-1` etc.
Returns the current AWS application's region based on the `HM_ENV_REGION` constant. On local setups or if the region is not set this
will return `null`. The region can be `us-east-1`, `ap-northeast-1`, `eu-central-1` etc.

**`get_environment_architecture() : string`**

Returns the current server architecture, currently this is one of `ecs` or `ec2`. `ec2` is the legacy architecture while `ecs` is the new container based system.
Returns the current server architecture, currently this is one of `ecs` or `ec2`. `ec2` is the legacy architecture while `ecs` is
the new container based system.

**`get_environment_codebase_revision() : string`**

Returns the current revision of the codebase deployed to the current environment. This will be the GIT commit hash of the latest commit that was deployed in the most recent deploy.
Returns the current revision of the codebase deployed to the current environment. This will be the GIT commit hash of the latest
commit that was deployed in the most recent deploy.

## AWS SDK

The AWS SDK is always available and preconfigured with the necessary credentials on all non local servers. Access to additional APIs can be requested if needed.
The AWS SDK is always available and preconfigured with the necessary credentials on all non local servers. Access to additional APIs
can be requested if needed.

**`get_aws_sdk() : Aws\Sdk`**

Returns an instance of the base AWS SDK with preconfigured credentials.

The credentials can be supplied by providing the `modules.core.aws` setting in the configuration. It's recommended that this be done only for the local environment:
The credentials can be supplied by providing the `modules.core.aws` setting in the configuration. It's recommended that this be done
only for the local environment:

```
```json
{
"extra": {
"altis": {
"environments":{
"local": {
"modules": {
"core" : {
"aws":{
"region": "us-east-1",
"key": "xxxxxxxxxxxxxxxxxxxx",
"secret": "xxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}
}
}
}
"extra": {
"altis": {
"environments": {
"local": {
"modules": {
"core": {
"aws": {
"region": "us-east-1",
"key": "xxxxxxxxxxxxxxxxxxxx",
"secret": "xxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}
}
}
}
}
```

The AWS SDK can be also configured in code by using `altis.aws_sdk.params` filter which is called right before the global instance of the AWS SDK is created.
The AWS SDK can be also configured in code by using `altis.aws_sdk.params` filter which is called right before the global instance
of the AWS SDK is created.

**Note:** this filter can only be used in the bootstrap function of an Altis module as it's called very early in the loading process.
**Note:** this filter can only be used in the bootstrap function of an Altis module as it's called early in the loading process.

```php
add_filter( 'altis.aws_sdk.params', 'aws_sdk_params' );

function aws_sdk_params( array $params ) : array {
$params['region'] = 'new_region';
return $params;
$params['region'] = 'new_region';
return $params;
}
```

## Autoloader

For convenience, an autoloader which follows the WordPress class file naming standard is available. This can be used in code following the WordPress file naming standards; if using PSR-based standards, we recommend using the Composer autoloaders instead.
For convenience, an autoloader which follows the WordPress class file naming standard is available. This can be used in code
following the WordPress file naming standards; if using PSR-based standards, we recommend using the Composer autoloaders instead.

**`register_class_path( string $prefix, string $path ) : void`**

Registers the given prefix to be autoloaded from the given path. The prefix can either be a legacy-style class prefix (e.g. `Altis_CMS_`) or a namespace (e.g. `Altis\CMS`).
Registers the given prefix to be autoloaded from the given path. The prefix can either be a legacy-style class prefix (
e.g. `Altis_CMS_`) or a namespace (e.g. `Altis\CMS`).

Classes are mapped to paths through the following process:

Expand All @@ -91,22 +101,25 @@ Classes are mapped to paths through the following process:
4. Underscores in the class name (but not the parent namespace) are converted to dashes
5. The name is prefixed with `class-`

For example, with `register_class_path( 'Altis\CMS', '/dir' )`, the class `Altis\CMS\Alpha_Beta\Gamma_Delta` would be expected to live at `/dir/alpha_beta/class-gamma-delta.php`.

For example, with `register_class_path( 'Altis\CMS', '/dir' )`, the class `Altis\CMS\Alpha_Beta\Gamma_Delta` would be expected to
live at `/dir/alpha_beta/class-gamma-delta.php`.

## Configuration

The configuration for the project determines which modules are loaded and how they behave. It can also be used for arbitrary project configuration.
The configuration for the project determines which modules are loaded and how they behave. It can also be used for arbitrary project
configuration.

### Functions

**`get_config() : array`**

Returns the complete configuration for the project including modules and their defaults and any overrides from the root `composer.json` configuration.
Returns the complete configuration for the project including modules and their defaults and any overrides from the
root `composer.json` configuration.

### Filters

These filters are intended for use by autoloaded files in modules and must be hooked into early. They provide a means of adding additional configuration features such as per environment overrides and configuration post-processing.
These filters are intended for use by autoloaded files in modules and must be hooked into early. They provide a means of adding
additional configuration features such as per environment overrides and configuration post-processing.

**`altis.config.default : array $default_config`**

Expand All @@ -130,7 +143,8 @@ Note that the modules interface is intended for internal use only and is documen

**`register_module( string $slug, string $directory, string $title, ?array $default_settings, ?callable $loader ) : Module`**

Registers and returns a `Module` object. If the module setting `enabled` is true the loader callback will be run on the `altis.modules.<slug>.loaded` action hook.
Registers and returns a `Module` object. If the module setting `enabled` is true the loader callback will be run on
the `altis.modules.<slug>.loaded` action hook.

This function must be called on the `altis.modules.init` action hook.

Expand All @@ -146,4 +160,7 @@ Fired after the autoloader has been included. Modules can only be registered on

**`altis.modules.<slug>.loaded : Module $module`**

Used to fire a module's registered loader callback. Receives the `Module` object registered with the corresponding slug as an argument.
Used to fire a module's registered loader callback. Receives the `Module` object registered with the corresponding slug as an
argument.

<!-- markdownlint-disable-file MD024 -->
3 changes: 3 additions & 0 deletions docs/cli-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ The migration command runs all basic maintenance tasks required after upgrading
There are 2 ways to hook into this command:

1. Using the `altis.migrate` action hook:

```php
add_action( 'altis.migrate', function ( array $args, array $assoc_args ) {
// Run upgrade routines here.
} );
```

2. Using WP CLI hooks:

```php
WP_CLI::add_hook( 'after_invoke:altis migrate', function () {
// Run migration routines here.
Expand Down
Loading

0 comments on commit 1001179

Please sign in to comment.