get_id(); if ( isset( $this->templates[ $id ] ) ) { throw new \ValueError( 'A template with the specified ID already exists in the registry.' ); } /** * Fires when a template is registered. * * @param BlockTemplateInterface $template Template that was registered. * * @since 8.2.0 */ do_action( 'woocommerce_block_template_register', $template ); $this->templates[ $id ] = $template; } /** * Get the registered templates. */ public function get_all_registered(): array { return $this->templates; } /** * Get a single registered template. * * @param string $id ID of the template. */ public function get_registered( $id ): BlockTemplateInterface { return isset( $this->templates[ $id ] ) ? $this->templates[ $id ] : null; } }