Yoast\WP\SEO\Repositories
Indexable_Repository::find_by_multiple_ids_and_type() public Yoast 1.0
Retrieves multiple indexables at once by their id's and type.
{} Это метод класса: Indexable_Repository{}
Хуков нет.
Возвращает
Indexable[]
. An array of indexables.
Использование
$Indexable_Repository = new Indexable_Repository(); $Indexable_Repository->find_by_multiple_ids_and_type( $object_ids, $object_type, $auto_create );
- $object_ids(число[]) (обязательный)
- The array of indexable object id's.
- $object_type(строка) (обязательный)
- The indexable object type.
- $auto_create(true/false)
- Create the indexable if it does not exist.
Код Indexable_Repository::find_by_multiple_ids_and_type() Indexable Repository::find by multiple ids and type Yoast 16.1.1
public function find_by_multiple_ids_and_type( $object_ids, $object_type, $auto_create = true ) {
if ( empty( $object_ids ) ) {
return [];
}
/**
* Represents an array of indexable objects.
*
* @var Indexable[] $indexables
*/
$indexables = $this->query()
->where_in( 'object_id', $object_ids )
->where( 'object_type', $object_type )
->find_many();
if ( $auto_create ) {
$indexables_available = [];
foreach ( $indexables as $indexable ) {
$indexables_available[] = $indexable->object_id;
}
$indexables_to_create = \array_diff( $object_ids, $indexables_available );
foreach ( $indexables_to_create as $indexable_to_create ) {
$indexables[] = $this->builder->build_for_id_and_type( $indexable_to_create, $object_type );
}
}
return \array_map( [ $this, 'ensure_permalink' ], $indexables );
}