| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO; |
| 4 |
|
| 5 |
use Yoast\WP\Lib\Abstract_Main; |
| 6 |
use Yoast\WP\SEO\Dependency_Injection\Container_Compiler; |
| 7 |
use Yoast\WP\SEO\Generated\Cached_Container; |
| 8 |
use Yoast\WP\SEO\Surfaces\Classes_Surface; |
| 9 |
use Yoast\WP\SEO\Surfaces\Helpers_Surface; |
| 10 |
use Yoast\WP\SEO\Surfaces\Meta_Surface; |
| 11 |
|
| 12 |
if ( ! \defined( 'WPSEO_VERSION' ) ) { |
| 13 |
\header( 'Status: 403 Forbidden' ); |
| 14 |
\header( 'HTTP/1.1 403 Forbidden' ); |
| 15 |
exit(); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Class Main. |
| 20 |
* |
| 21 |
* @property Classes_Surface $classes The classes surface. |
| 22 |
* @property Meta_Surface $meta The meta surface. |
| 23 |
* @property Helpers_Surface $helpers The helpers surface. |
| 24 |
*/ |
| 25 |
class Main extends Abstract_Main { |
| 26 |
|
| 27 |
/** |
| 28 |
* The API namespace constant. |
| 29 |
* |
| 30 |
* @var string |
| 31 |
*/ |
| 32 |
public const API_V1_NAMESPACE = 'yoast/v1'; |
| 33 |
|
| 34 |
/** |
| 35 |
* The WP CLI namespace constant. |
| 36 |
* |
| 37 |
* @var string |
| 38 |
*/ |
| 39 |
public const WP_CLI_NAMESPACE = 'yoast'; |
| 40 |
|
| 41 |
/** |
| 42 |
* {@inheritDoc} |
| 43 |
*/ |
| 44 |
protected function get_container() { |
| 45 |
if ( $this->is_development() && \class_exists( '\Yoast\WP\SEO\Dependency_Injection\Container_Compiler' ) ) { |
| 46 |
// Exception here is unhandled as it will only occur in development. |
| 47 |
Container_Compiler::compile( |
| 48 |
$this->is_development(), |
| 49 |
__DIR__ . '/generated/container.php', |
| 50 |
__DIR__ . '/../config/dependency-injection/services.php', |
| 51 |
__DIR__ . '/../vendor/composer/autoload_classmap.php', |
| 52 |
'Yoast\WP\SEO\Generated', |
| 53 |
); |
| 54 |
} |
| 55 |
|
| 56 |
if ( \file_exists( __DIR__ . '/generated/container.php' ) ) { |
| 57 |
require_once __DIR__ . '/generated/container.php'; |
| 58 |
|
| 59 |
return new Cached_Container(); |
| 60 |
} |
| 61 |
|
| 62 |
return null; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* {@inheritDoc} |
| 67 |
*/ |
| 68 |
protected function get_name() { |
| 69 |
return 'yoast-seo'; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* {@inheritDoc} |
| 74 |
*/ |
| 75 |
protected function get_surfaces() { |
| 76 |
return [ |
| 77 |
'classes' => Classes_Surface::class, |
| 78 |
'meta' => Meta_Surface::class, |
| 79 |
'helpers' => Helpers_Surface::class, |
| 80 |
]; |
| 81 |
} |
| 82 |
} |
| 83 |
|