Creates a new feature for the given user.

@param int        $sourceId
@param string     $name
@param mixed      $value
@param mixed|null $type

@return array Response
326237
public function createNew(
        int $sourceId,
        string $name,
        $value,
        $type = null
    ) : array {
        if ($type === null) {
            $type = $this->typeInfer($value);
        }

        return $this->sendPost(
            sprintf('/profiles/%s/features', $this->userName),
            [],
            [
                'source_id' => $sourceId,
                'name'      => $name,
                'value'     => $value,
                'type'      => $type
            ]
        );
    }
1239772
public function createEvent(StateInterface $sourceState, $eventName)
    {
        if ($sourceState instanceof State) {
            return $sourceState->getEvent($eventName);
        } else {
            throw new \InvalidArgumentException('Overwrite this method to implement a different type!');
        }
    }
522594
public function set(string $name, $value, int $type = self::TYPE_LOCAL): OptionList
    {
        if ($type == self::TYPE_GLOBAL) {
            self::$globalOptions[$name] = $value;
        } else {
            $this->options[$name] = $value;
        }

        return $this;
    }
164812
public static function create(string $name, string $value = null): self
    {
        return new self($name, $value);
    }
210683
protected function create_dc_node($name, $value = '')
    {
        if (empty($value)) {
            return;
        }
        $this->addChild($this->working_node, "dc:".$name, utf8_encode($value));
    }
1357667
public static function createFromSource($source, $type, array $options = []) {
		if (isset(self::$readers[$type])) {
			$reader = self::$readers[$type];
		} else {
			$class  = self::READERS_NAMESPACE . '\\' . ucfirst($type);
			$reader = new $class();

			if (! $reader instanceof ReaderInterface) {
				throw new InvalidReader('Reader must implement the "ReaderInterface"');
			}
			
			self::$readers[$type] = $reader;
		}
		
		// Read only lock resolve
		if (isset($options[self::OPTION_READONLY])) {
			$readOnly = (bool) $options[self::OPTION_READONLY];
			unset($options[self::OPTION_READONLY]);
		} else {
			$readOnly = true;
		}
		
		return self::create($reader->parse($source, $options), $readOnly);
	}
782670
protected function checkable($type, $name, $value, $checked, $options)
    {
        $checked = $this->getCheckedState($type, $name, $value, $checked);

        if ($checked) {
            $options['checked'] = 'checked';
        }

        return $this->input($type, $name, $value, $options);
    }
1185523
public static function build_id( $type, $name )
	{
		if ( !is_null( static::$id_prefix ) )
		{
			return static::$id_prefix.'-'.static::form_id( $type, $name );
		}
		return static::form_id( $type, $name );
	}
1303692
private function validateType($type, $value, $name = '')
    {
        $valueType = gettype($value);
        
        $codeException = $this->checkType($type, $value);
        
        if(1 === $codeException)
        {
            throw new InvalidArgumentException(sprintf('%s argument only accepts %s. Input type was: %s', $name, $type, $valueType));
        }
        
        if(2 === $codeException)
        {
            throw new RuntimeException('The argument is a resource, not is a valid type');
        }
        
        if(3 === $codeException)
        {
            throw new RuntimeException(sprintf('Value not defined in validation for %s', $type));
        }
        
        return $value;
    }
1233599
private static function createValidator($name, $type)
    {
        return \call_user_func_array([Validator::create(), ValidatorType::getMethod($type)], [$name]);
    }
777246
@Override
   protected void implementInterface(InterfaceCapableSource<?> source, Iterable<String> value, JavaSourceFacet facet)
   {
      for (String type : value)
      {
         source.addInterface(type);
      }
   }
1359459
public function actionList($sourceType, $sourceId)
    {
        $source = null;
        if ($sourceType == 'question' && Yii::$app->hasModule('question')) {
            $source = \yuncms\question\models\Question::findOne($sourceId);
        } else if ($sourceType === 'answer' && Yii::$app->hasModule('question')) {
            $source = \yuncms\question\models\QuestionAnswer::findOne($sourceId);
        } else if ($sourceType == 'article' && Yii::$app->hasModule('article')) {
            $source = \yuncms\article\models\Article::findOne($sourceId);
        } else if ($sourceType == 'live' && Yii::$app->hasModule('live')) {
            $source = \yuncms\live\models\Stream::findOne($sourceId);
        } else if ($sourceType == 'code' && Yii::$app->hasModule('code')) {
            $source = \yuncms\live\models\Stream::findOne($sourceId);
        }//etc..

        if (!$source) {
            throw new NotFoundHttpException ();
        }

        $query = Comment::find()->where([
            'model_id' => $sourceId,
            'model' => get_class($source),
        ])->with('user');

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        return $this->renderPartial('list', ['dataProvider' => $dataProvider]);
    }
156686
public void put(Object name, Object value) {
		this.source.put((name != null) ? name.toString() : null, value);
	}
535288
public void addCustomerSource(
            @NonNull String sourceId,
            @NonNull @Source.SourceType String sourceType,
            @Nullable SourceRetrievalListener listener) {
        final Map<String, Object> arguments = new HashMap<>();
        arguments.put(KEY_SOURCE, sourceId);
        arguments.put(KEY_SOURCE_TYPE, sourceType);

        final String operationId = UUID.randomUUID().toString();
        if (listener != null) {
            mSourceRetrievalListeners.put(operationId, listener);
        }
        mEphemeralKeyManager.retrieveEphemeralKey(operationId, ACTION_ADD_SOURCE, arguments);
    }
930117
protected function createInput($type, $name = null, $value = null, $attr = null)
    {
        if($type == 'textarea')
            $input = new Input\Textarea($name);
        else
            $input = new Input\Input($type, $name);

        if($name)
            $input->attr('id', $name);

        if($value)
            $input->value($value);
        else if(isset($this->data[$name]))
            $input->value($this->data[$name]);

        if($attr)
            $input->attr($attr);

        if(isset($this->override[$name]))
            $input->override($this->override[$name]);

        return $input;
    }
121281
public function createField($name, $value, $type = Field::TYPE_STRING, $stored = true, $indexed = true, $aggregated = false)
    {
        return new Field($name, $value, $type, $stored, $indexed, $aggregated);
    }
73176
public function input($type, $name, $value = '', $attributes = array())
    {
        $id = str_replace(array('[', ']'), array('_', ''), $name);

        return $this->tag('input', null)
                    ->set(array('type' => $type, 'value' => $value, 'name' => $name, 'id' => $id))
                    ->set($attributes);
    }