src/Graviton/SchemaBundle/Model/SchemaModel.php
public function getRequiredFields($variationName = null)
    {
        if (is_null($variationName)) {
            return $this->schema->required;
        }

        /* compose required fields based on variation */
        $requiredFields = $this->getRequiredFields();
        foreach ($this->schema->properties as $fieldName => $fieldAttributes) {
            $onVariation = $this->getOnVariaton($fieldName);

            if (is_object($onVariation) && isset($onVariation->{$variationName}->required)) {
                $thisRequired = $onVariation->{$variationName}->required;

                if ($thisRequired === true) {
                    $requiredFields[] = $fieldName;
                }

                if ($thisRequired === false) {
                    // see if its set
                    $fieldIndex = array_search($fieldName, $requiredFields);
                    if ($fieldName !== false) {
                        unset($requiredFields[$fieldIndex]);
                    }
                }
            }
        }

        return array_values(
            array_unique(
                $requiredFields
            )
        );
    }
public function getRequiredFields($variationName = null)
    {
        if (is_null($variationName)) {
            return $this->schema->required;
        }

        /* compose required fields based on variation */
        $requiredFields = $this->getRequiredFields();
        foreach ($this->schema->properties as $fieldName => $fieldAttributes) {
            $onVariation = $this->getOnVariaton($fieldName);

            if (is_object($onVariation) && isset($onVariation->{$variationName}->required)) {
                $thisRequired = $onVariation->{$variationName}->required;

                if ($thisRequired === true) {
                    $requiredFields[] = $fieldName;
                }

                if ($thisRequired === false) {
                    // see if its set
                    $fieldIndex = array_search($fieldName, $requiredFields);
                    if ($fieldName !== false) {
                        unset($requiredFields[$fieldIndex]);
                    }
                }
            }
        }

        return array_values(
            array_unique(
                $requiredFields
            )
        );
    }
public function getRequiredFields ( $ variationName = null ) { if ( is_null ( $ variationName ) ) { return $ this -> schema -> required ; } /* compose required fields based on variation */ $ requiredFields = $ this -> getRequiredFields ( ) ; foreach ( $ this -> schema -> properties as $ fieldName => $ fieldAttributes ) { $ onVariation = $ this -> getOnVariaton ( $ fieldName ) ; if ( is_object ( $ onVariation ) && isset ( $ onVariation -> { $ variationName } -> required ) ) { $ thisRequired = $ onVariation -> { $ variationName } -> required ; if ( $ thisRequired === true ) { $ requiredFields [ ] = $ fieldName ; } if ( $ thisRequired === false ) { // see if its set $ fieldIndex = array_search ( $ fieldName , $ requiredFields ) ; if ( $ fieldName !== false ) { unset ( $ requiredFields [ $ fieldIndex ] ) ; } } } } return array_values ( array_unique ( $ requiredFields ) ) ; }
get required fields for this object

@param string $variationName a variation that can alter which fields are required

@return string[]
get required fields for this object