MailPoet\EmailEditor\Engine\Patterns

Abstract_Pattern{}WC 1.0

Abstract class for block patterns.

No Hooks.

Usage

$Abstract_Pattern = new Abstract_Pattern();
// use class methods

Methods

  1. public get_content()
  2. protected get_description()
  3. public get_name()
  4. public get_namespace()
  5. public get_properties()
  6. public get_title()

Abstract_Pattern{} code WC 9.8.1

abstract class Abstract_Pattern {
	/**
	 * Name of the pattern.
	 *
	 * @var string $name
	 */
	protected $name = '';
	/**
	 * Namespace of the pattern.
	 *
	 * @var string $namespace
	 */
	protected $namespace = '';
	/**
	 * List of block types.
	 *
	 * @var array $block_types
	 */
	protected $block_types = array();
	/**
	 * List of template types.
	 *
	 * @var string[] $template_types
	 */
	protected $template_types = array();
	/**
	 * Flag to enable/disable inserter.
	 *
	 * @var bool $inserter
	 */
	protected $inserter = true;
	/**
	 * Source of the pattern.
	 *
	 * @var string $source
	 */
	protected $source = 'plugin';
	/**
	 * List of categories.
	 *
	 * @var array $categories
	 */
	protected $categories = array();
	/**
	 * Viewport width.
	 *
	 * @var int $viewport_width
	 */
	protected $viewport_width = 620;

	/**
	 * Get name of the pattern.
	 *
	 * @return string
	 */
	public function get_name(): string {
		return $this->name;
	}

	/**
	 * Get namespace of the pattern.
	 *
	 * @return string
	 */
	public function get_namespace(): string {
		return $this->namespace;
	}

	/**
	 * Return properties of the pattern.
	 *
	 * @return array
	 */
	public function get_properties(): array {
		return array(
			'title'         => $this->get_title(),
			'content'       => $this->get_content(),
			'description'   => $this->get_description(),
			'categories'    => $this->categories,
			'inserter'      => $this->inserter,
			'blockTypes'    => $this->block_types,
			'templateTypes' => $this->template_types,
			'source'        => $this->source,
			'viewportWidth' => $this->viewport_width,
		);
	}

	/**
	 * Get content.
	 *
	 * @return string
	 */
	abstract protected function get_content(): string;

	/**
	 * Get title.
	 *
	 * @return string
	 */
	abstract protected function get_title(): string;

	/**
	 * Get description.
	 *
	 * @return string
	 */
	protected function get_description(): string {
		return '';
	}
}