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; } }