eZ\Bundle\EzPublishCoreBundle\Features\Context\FieldTypeContext::setFieldContentState PHP Метод

setFieldContentState() публичный Метод

Executes necessary operations to guarantee a given state, recursive function that calls it self to make sure prerequisites are met.
public setFieldContentState ( integer $stateFlag, string $field = null, mixed $value = null )
$stateFlag integer Desired state, only predefined constants accepted
$field string Name of the field, optional
$value mixed Value of the field, optional
    public function setFieldContentState($stateFlag, $field = null, $value = null)
    {
        if ($stateFlag <= $this->fieldConstructionObject['objectState'] || $stateFlag < self::FIELD_TYPE_NOT_CREATED) {
            return;
        }
        // recursively set previous states if necessary
        $this->setFieldContentState($stateFlag - 1, $field, $value);
        switch ($stateFlag) {
            case self::FIELD_TYPE_NOT_CREATED:
                throw new \Exception('A field type must be declared before anything else');
                break;
            case self::CONTENT_TYPE_CREATED:
                $this->createContentType();
                break;
            case self::FIELD_TYPE_ASSOCIATED:
                $this->associateFieldToContentType();
                break;
            case self::CONTENT_TYPE_PUBLISHED:
                $this->publishContentType();
                break;
            case self::CONTENT_PUBLISHED:
                $this->createAndPublishContent($field, $value);
                break;
        }
    }