| @@ -12,10 +12,10 @@ | ||
| 12 | 12 | namespace WindPress\WindPress\Integration; |
| 13 | 13 | |
| 14 | 14 | use Exception; |
| 15 | 15 | use ReflectionClass; |
| 16 | +use WindPressDeps\Symfony\Component\Finder\Finder; | |
| 16 | 17 | use WIND_PRESS; |
| 17 | -use WindPressPackages\Symfony\Component\Finder\Finder; | |
| 18 | 18 | class Loader |
| 19 | 19 | { |
| 20 | 20 | /** |
| 21 | 21 | * List of Integrations services. |
| @@ -54,9 +54,9 @@ | ||
| 54 | 54 | * instance. On the first run, it creates a singleton object and places it |
| 55 | 55 | * into the static property. On subsequent runs, it returns the client existing |
| 56 | 56 | * object stored in the static property. |
| 57 | 57 | */ |
| 58 | - public static function get_instance() : self | |
| 58 | + public static function get_instance(): self | |
| 59 | 59 | { |
| 60 | 60 | if (!isset(self::$instance)) { |
| 61 | 61 | self::$instance = new self(); |
| 62 | 62 | self::$instance->scan_integrations(); |
| @@ -67,9 +67,9 @@ | ||
| 67 | 67 | { |
| 68 | 68 | // Get cached Integrations |
| 69 | 69 | $transient_name = 'windpress_scanned_integrations_' . WIND_PRESS::VERSION; |
| 70 | 70 | /** @var IntegrationInterface[]|false $cached */ |
| 71 | - $cached = \get_transient($transient_name); | |
| 71 | + $cached = get_transient($transient_name); | |
| 72 | 72 | if (!\WP_DEBUG && $cached !== \false) { |
| 73 | 73 | $this->integrations = $cached; |
| 74 | 74 | return; |
| 75 | 75 | } |
| @@ -79,20 +79,20 @@ | ||
| 79 | 79 | * Add additional places to scan for Integrations. |
| 80 | 80 | * |
| 81 | 81 | * @param Finder $finder The Finder instance. |
| 82 | 82 | */ |
| 83 | - \do_action('a!windpress/integration/loader:scan_integrations.before_scan', $finder); | |
| 83 | + do_action('a!windpress/integration/loader:scan_integrations.before_scan', $finder); | |
| 84 | 84 | foreach ($finder as $file) { |
| 85 | 85 | $integration_file = $file->getPathname(); |
| 86 | - if (!\is_readable($integration_file)) { | |
| 86 | + if (!is_readable($integration_file)) { | |
| 87 | 87 | continue; |
| 88 | 88 | } |
| 89 | 89 | require_once $integration_file; |
| 90 | 90 | } |
| 91 | 91 | // Find any Integrations that extends IntegrationInterface class |
| 92 | - $declared_classes = \get_declared_classes(); | |
| 92 | + $declared_classes = get_declared_classes(); | |
| 93 | 93 | foreach ($declared_classes as $declared_class) { |
| 94 | - if (!\class_exists($declared_class)) { | |
| 94 | + if (!class_exists($declared_class)) { | |
| 95 | 95 | continue; |
| 96 | 96 | } |
| 97 | 97 | $reflector = new ReflectionClass($declared_class); |
| 98 | 98 | if (!$reflector->isSubclassOf(\WindPress\WindPress\Integration\IntegrationInterface::class)) { |
| @@ -103,14 +103,14 @@ | ||
| 103 | 103 | $integration = $reflector->newInstanceWithoutConstructor(); |
| 104 | 104 | $this->integrations[$integration->get_name()] = ['name' => $integration->get_name(), 'file_path' => $reflector->getFileName(), 'class_name' => $reflector->getName()]; |
| 105 | 105 | } |
| 106 | 106 | // Cache the scanned Integrations |
| 107 | - \set_transient($transient_name, $this->integrations, \HOUR_IN_SECONDS); | |
| 107 | + set_transient($transient_name, $this->integrations, \HOUR_IN_SECONDS); | |
| 108 | 108 | } |
| 109 | 109 | /** |
| 110 | 110 | * Register Integrations. |
| 111 | 111 | */ |
| 112 | - public function register_integrations() : void | |
| 112 | + public function register_integrations(): void | |
| 113 | 113 | { |
| 114 | 114 | /** |
| 115 | 115 | * Filter the Integrations before register to WP Rest. |
| 116 | 116 | * |
| @@ -117,9 +117,9 @@ | ||
| 117 | 117 | * @param IntegrationInterface[] $integrations |
| 118 | 118 | * @return IntegrationInterface[] |
| 119 | 119 | */ |
| 120 | 120 | /** @var IntegrationInterface[] $integrations */ |
| 121 | - $integrations = \apply_filters('f!windpress/integration/loader:register_integrations', $this->integrations); | |
| 121 | + $integrations = apply_filters('f!windpress/integration/loader:register_integrations', $this->integrations); | |
| 122 | 122 | foreach ($integrations as $integration) { |
| 123 | 123 | // Create new instance of Integration class and register custom endpoints |
| 124 | 124 | /** @var IntegrationInterface $integrationInstance */ |
| 125 | 125 | $integrationInstance = new $integration['class_name'](); |
| @@ -130,9 +130,9 @@ | ||
| 130 | 130 | * Get the list of Integrations. |
| 131 | 131 | * |
| 132 | 132 | * @return IntegrationInterface[] |
| 133 | 133 | */ |
| 134 | - public function get_integrations() : array | |
| 134 | + public function get_integrations(): array | |
| 135 | 135 | { |
| 136 | 136 | return $this->integrations; |
| 137 | 137 | } |
| 138 | 138 | } |