2022-03-08 15:55:41 +01:00
|
|
|
<?php namespace ProcessWire;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ProcessWire Fields Array
|
|
|
|
*
|
|
|
|
* WireArray of Field instances, as used by Fields class
|
|
|
|
*
|
2024-04-04 14:37:20 +02:00
|
|
|
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
2022-03-08 15:55:41 +01:00
|
|
|
* https://processwire.com
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
class FieldsArray extends WireArray {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Per WireArray interface, only Field instances may be added
|
|
|
|
*
|
|
|
|
* @param Wire $item
|
|
|
|
* @return bool
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function isValidItem($item) {
|
|
|
|
return $item instanceof Field;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Per WireArray interface, Field keys have to be integers
|
|
|
|
*
|
|
|
|
* @param int $key
|
2024-04-04 14:37:20 +02:00
|
|
|
* @return bool
|
2022-03-08 15:55:41 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function isValidKey($key) {
|
|
|
|
return is_int($key) || ctype_digit($key);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Per WireArray interface, Field instances are keyed by their ID
|
|
|
|
*
|
|
|
|
* @param Field $item
|
|
|
|
* @return int
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function getItemKey($item) {
|
|
|
|
return $item->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Per WireArray interface, return a blank Field
|
|
|
|
*
|
|
|
|
* @return Field
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function makeBlankItem() {
|
|
|
|
return $this->wire(new Field());
|
|
|
|
}
|
2024-04-04 14:37:20 +02:00
|
|
|
}
|