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;
        }
    }
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;
        }
    }
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 ; } }
Executes necessary operations to guarantee a given state, recursive
function that calls it self to make sure prerequisites are met.

@param int $stateFlag Desired state, only predefined constants accepted
@param string $field Name of the field, optional
@param mixed $value Value of the field, optional
Executes necessary operations to guarantee a given state recursive function that calls it self to make sure prerequisites are met .