Yoast\WP\SEO\Introductions\Domain

Introductions_Bucket{}Yoast 1.0

A collection domain object.

Хуков нет.

Использование

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

Методы

  1. public __construct()
  2. public add_introduction( Introduction_Item $introduction )
  3. public to_array()

Код Introductions_Bucket{} Yoast 24.4

class Introductions_Bucket {

	/**
	 * Holds the introductions.
	 *
	 * @var Introduction_Item[]
	 */
	private $introductions;

	/**
	 * The constructor.
	 */
	public function __construct() {
		$this->introductions = [];
	}

	/**
	 * Adds an introduction to this bucket.
	 *
	 * @param Introduction_Item $introduction The introduction.
	 *
	 * @return void
	 */
	public function add_introduction( Introduction_Item $introduction ) {
		$this->introductions[] = $introduction;
	}

	/**
	 * Returns the array representation of the introductions.
	 *
	 * @return array
	 */
	public function to_array() {
		// No sorting here because that is done in JS.
		return \array_map(
			static function ( $item ) {
				return $item->to_array();
			},
			$this->introductions
		);
	}
}