CRUDlex\AbstractData::hasManySet PHP Method

hasManySet() abstract public method

Checks whether a given set of ids is assigned to any entity exactly like it is given (no subset, no superset).
abstract public hasManySet ( string $field, array $thatIds, string | null $excludeId = null ) : boolean
$field string the many field
$thatIds array the id set to check
$excludeId string | null one optional own id to exclude from the check
return boolean true if the set of ids exists for an entity
    public abstract function hasManySet($field, array $thatIds, $excludeId = null);

Usage Example

Beispiel #1
0
 /**
  * Checks whether the unique constraint is valid for a many-to-many field.
  *
  * @param array $value
  * the value to check
  * @param AbstractData $data
  * the data to perform the check with
  * @param Entity $entity
  * the entity to perform the check on
  * @param $field
  * the many field to perform the check on
  *
  * @return boolean
  * true if it is a valid unique many-to-many constraint
  */
 protected function isValidUniqueMany(array $value, AbstractData $data, Entity $entity, $field)
 {
     return !$data->hasManySet($field, array_column($value, 'id'), $entity->get('id'));
 }