container = $container; } /** * {@inheritdoc} */ public function get_id(): string { return 'pos'; } /** * {@inheritdoc} */ public function get_product_feed_query_args(): array { return array( 'type' => array( 'simple', 'variable', 'variation' ), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query 'tax_query' => array( array( 'taxonomy' => 'pos_product_visibility', 'field' => 'slug', 'terms' => 'pos-hidden', 'operator' => 'NOT IN', ), ), ); } /** * {@inheritdoc} */ public function register_hooks(): void { add_action( 'rest_api_init', array( $this, 'rest_api_init' ) ); $this->container->get( AsyncGenerator::class )->register_hooks(); $this->container->get( POSProductVisibilitySync::class )->register_hooks(); } /** * Initialize the REST API. * * @return void */ public function rest_api_init(): void { // Only load the controller when necessary. $this->container->get( ApiController::class )->register_routes(); } /** * {@inheritdoc} */ public function activate(): void { // At the moment, there are no activation steps for the POS catalog. } /** * {@inheritdoc} */ public function deactivate(): void { // At the moment, there are no deactivation steps for the POS catalog. } /** * {@inheritdoc} * * POS catalog feeds are generated in chunks across multiple processes, so this returns a feed that * supports the resumable lifecycle. Narrowing the return type (a covariant override of the base * {@see FeedInterface} contract) guarantees that at the language level for callers such as * {@see AsyncGenerator}, instead of relying on a PHPDoc hint or a runtime check. * * @return ResumableFeedInterface */ public function create_feed(): ResumableFeedInterface { return new JsonFileFeed( 'pos-catalog-feed' ); } /** * {@inheritdoc} */ public function get_product_mapper(): ProductMapper { return $this->container->get( ProductMapper::class ); } /** * {@inheritdoc} */ public function get_feed_validator(): FeedValidatorInterface { return $this->container->get( FeedValidator::class ); } }