Skip to content

Commit

Permalink
Added back dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
CrochetFeve0251 committed Jul 3, 2024
1 parent 1c40c34 commit 21ff723
Show file tree
Hide file tree
Showing 88 changed files with 4,405 additions and 15 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/deploy-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: normal build
run: composer install
- name: remove installers
run: composer remove composer/installers
- name: optimized build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_php8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-interaction --ignore-platform-reqs
run: composer install --prefer-dist --no-interaction --no-scripts --ignore-platform-reqs

- name: Install tests
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:3306 ${{ matrix.wp-versions }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_rocketcdn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-interaction --ignore-platform-reqs
run: composer install --prefer-dist --no-interaction --no-scripts

- name: Install tests
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:3306 ${{ matrix.wp-versions }}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
composer.phar
/vendor/
src/Dependencies
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"require-dev": {
"php": "^7 || ^8",
"brain/monkey": "^2.0",
"coenjacobs/mozart": "^0.5.1",
"coenjacobs/mozart": "^0.7",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"league/container": "^3.3",
"phpcompatibility/phpcompatibility-wp": "^2.0",
Expand Down
27 changes: 18 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

158 changes: 158 additions & 0 deletions src/Dependencies/LaunchpadCore/Activation/Activation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php

namespace RocketCDN\Dependencies\LaunchpadCore\Activation;

use RocketCDN\Dependencies\LaunchpadCore\Container\AbstractServiceProvider;
use RocketCDN\Dependencies\LaunchpadCore\Container\HasInflectorInterface;
use RocketCDN\Dependencies\LaunchpadCore\Container\PrefixAwareInterface;
use RocketCDN\Dependencies\LaunchpadCore\Dispatcher\DispatcherAwareInterface;
use RocketCDN\Dependencies\LaunchpadDispatcher\Dispatcher;
use RocketCDN\Dependencies\Psr\Container\ContainerInterface;

class Activation {

/**
* Service providers.
*
* @var array
*/
protected static $providers = [];

/**
* Parameters.
*
* @var array
*/
protected static $params = [];

/**
* Container.
*
* @var ContainerInterface
*/
protected static $container;

/**
* Hook dispatcher.
*
* @var Dispatcher
*/
protected static $dispatcher;

/**
* Set service providers.
*
* @param array $providers Service providers.
* @return void
*/
public static function set_providers( array $providers ) {
self::$providers = $providers;
}

/**
* Set parameters.
*
* @param array $params Parameters.
* @return void
*/
public static function set_params( array $params ) {
self::$params = $params;
}

/**
* Set the container.
*
* @param ContainerInterface $container Container.
* @return void
*/
public static function set_container( ContainerInterface $container ) {
self::$container = $container;
}

/**
* Set hook dispatcher.
*
* @param Dispatcher $dispatcher Hook dispatcher.
* @return void
*/
public static function set_dispatcher( Dispatcher $dispatcher ): void {
self::$dispatcher = $dispatcher;
}

/**
* Performs these actions during the plugin activation
*
* @return void
*/
public static function activate_plugin() {

$container = self::$container;

foreach ( self::$params as $key => $value ) {
self::$container->add( $key, $value );
}

$container->share( 'dispatcher', self::$dispatcher );

$container->inflector( PrefixAwareInterface::class )->invokeMethod( 'set_prefix', [ key_exists( 'prefix', self::$params ) ? self::$params['prefix'] : '' ] );
$container->inflector( DispatcherAwareInterface::class )->invokeMethod( 'set_dispatcher', [ $container->get( 'dispatcher' ) ] );

$providers = array_filter(
self::$providers,
function ( $provider ) {
if ( is_string( $provider ) ) {
$provider = new $provider();
}

if ( ! $provider instanceof ActivationServiceProviderInterface && ( ! $provider instanceof HasInflectorInterface || count( $provider->get_inflectors() ) === 0 ) ) {
return false;
}

return $provider;
}
);

/**
* Activation providers.
*
* @param AbstractServiceProvider[] $providers Providers.
* @return AbstractServiceProvider[]
*/
$providers = apply_filters( "{$container->get('prefix')}deactivate_providers", $providers );

$providers = array_map(
function ( $provider ) {
if ( is_string( $provider ) ) {
return new $provider();
}
return $provider;
},
$providers
);

foreach ( $providers as $provider ) {
self::$container->addServiceProvider( $provider );
}

foreach ( $providers as $service_provider ) {
if ( ! $service_provider instanceof HasInflectorInterface ) {
continue;
}
$service_provider->register_inflectors();
}

foreach ( $providers as $provider ) {
if ( ! $provider instanceof HasActivatorServiceProviderInterface ) {
continue;
}

foreach ( $provider->get_activators() as $activator ) {
$activator_instance = self::$container->get( $activator );
if ( ! $activator_instance instanceof ActivationInterface ) {
continue;
}
$activator_instance->activate();
}
}
}
}
14 changes: 14 additions & 0 deletions src/Dependencies/LaunchpadCore/Activation/ActivationInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace RocketCDN\Dependencies\LaunchpadCore\Activation;

interface ActivationInterface {


/**
* Executes this method on plugin activation
*
* @return void
*/
public function activate();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace RocketCDN\Dependencies\LaunchpadCore\Activation;

interface ActivationServiceProviderInterface {


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace RocketCDN\Dependencies\LaunchpadCore\Activation;

interface HasActivatorServiceProviderInterface extends ActivationServiceProviderInterface {

/**
* Returns list of activators.
*
* @return string[]
*/
public function get_activators(): array;
}
Loading

0 comments on commit 21ff723

Please sign in to comment.