src/Callbacks/CommaDelimiterSkuRelationsValidatorCallback.php
/**
     * Will be invoked by the observer it has been registered for.
     *
     * @param string|null $attributeCode  The code of the attribute that has to be validated
     * @param string|null $attributeValue The attribute value to be validated
     *
     * @return mixed The modified value
     */
Will be invoked by the observer it has been registered for.
@param string|null $attributeCode  The code of the attribute that has to be validated
@param string|null $attributeValue The attribute value to be validated

@return mixed The modified value
Will be invoked by the observer it has been registered for . @param string|null $attributeCode The code of the attribute that has to be validated @param string|null $attributeValue The attribute value to be validated @return mixed The modified value
public function handle($attributeCode = null, $attributeValue = null)
    {
        if ($this->isNullable($values = $this->getSubject()->explode($attributeValue, ','))) {
            return;
        }
        $validations = $this->getValidations();
        $rowSku = $this->getSubject()->getValue(ColumnKeys::SKU);
        $rowProductType = $this->getSubject()->getValue(ColumnKeys::PRODUCT_TYPE);
        $skuErrors = [];
        foreach ($values as $value) {
            list($value) = $this->getSubject()->explode($value, '=');
            if (in_array($value, $validations)) {
                continue;
            }
            array_push($skuErrors, $value);
        }
        if (count($skuErrors) > 0) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Found invalid SKUs "%s" to be related to %s product with SKU "%s"',
                    implode(',', $skuErrors),
                    $rowProductType,
                    $rowSku
                )
            );
        }
    }
public function handle ( $ attributeCode = null , $ attributeValue = null ) { if ( $ this -> isNullable ( $ values = $ this -> getSubject ( ) -> explode ( $ attributeValue , ',' ) ) ) { return ; } $ validations = $ this -> getValidations ( ) ; $ rowSku = $ this -> getSubject ( ) -> getValue ( ColumnKeys :: SKU ) ; $ rowProductType = $ this -> getSubject ( ) -> getValue ( ColumnKeys :: PRODUCT_TYPE ) ; $ skuErrors = [ ] ; foreach ( $ values as $ value ) { list ( $ value ) = $ this -> getSubject ( ) -> explode ( $ value , '=' ) ; if ( in_array ( $ value , $ validations ) ) { continue ; } array_push ( $ skuErrors , $ value ) ; } if ( count ( $ skuErrors ) > 0 ) { throw new \ InvalidArgumentException ( sprintf ( 'Found invalid SKUs "%s" to be related to %s product with SKU "%s"' , implode ( ',' , $ skuErrors ) , $ rowProductType , $ rowSku ) ) ; } }
Will be invoked by the observer it has been registered for.
Will be invoked by the observer it has been registered for .
// query whether or not an empty value is allowed // load the validations for the column // load the parent SKU from the row // iterate over the values and validate them // First element always SKU // query whether or not the value is valid // collect single sku for error // throw an exception if the value is NOT in the array