@throws InvalidConfigException

$this->attribute is the attribute name of the stored and cropped file name
Other attributes are derived from that:
__<attr>_file__
__<attr>_crop__
__<attr>_delete__
16576
public function run()    {
        if (! $this->hasModel() || ! $this->attribute)    {
            throw new InvalidConfigException('Uploader widget must have model and attribute.');
        }

        $ill = $this->illustration;
        $view = $this->view;
        $id = $this->id;

        /** @var ActiveRecord $model */
        $model = $this->model;

        if (! is_numeric($ill->aspectRatio) && ! $model->{$ill->aspectRatio}) $model->{$ill->aspectRatio} = $this->defaultAspect;

        $view->registerAssetBundle(CropperAsset::class);
        $view->registerAssetBundle(StylefileAsset::class);

        $cropVal = Html::getInputId($model, "__{$this->attribute}_crop__");
        $delSwitch = Html::getInputId($model, "__{$this->attribute}_delete__");

        $aspect = is_numeric($ill->aspectRatio) ? $ill->aspectRatio : $this->defaultAspect;
        $this->cropperOptions['aspectRatio'] = $aspect;
        $this->cropperOptions['minSize'] = $ill->cropSize;
        $this->cropperOptions['change'] = new JsExpression("function(e,c) { $('#$cropVal').val(JSON.stringify(c)); }");

        $cropOpts = $this->encode($this->cropperOptions);
        $stylefileOpts = $this->encode($this->stylefileOptions);

        $initAsp = '';
        if ($this->aspectOptions) {
            $aspect *= 1000;
            if ($this->radio)   {
                $view->registerJs("$('#$id [type=radio]').on('change',function(){ $id.cropper('option','aspectRatio',this.value/1000);})");
                $initAsp = "$('#$id [type=radio]').prop('disabled',false)/*.filter('[value='+$aspect+']').prop('checked',true)*/;";
            }
            else    {
                $view->registerJs("$('#$id .uploader-select').on('change',function(){ $id.cropper('option','aspectRatio',this.value/1000);})");
                $initAsp = "$('#$id .uploader-select').prop('disabled',false).val($aspect);";
            }
        }

        $view->registerJs("var $id=$('#$id .cropper').cropper($cropOpts);");
        $view->registerJs("$('#$id [type=file]').stylefile($stylefileOpts).on('change',function(evt){ $initAsp $id.cropper('loadImage',evt.target.files);$(this).closest('.uploader').find('.del-switch').prop('checked',false).prop('disabled',true);});");
        $view->registerJs("$('#$delSwitch').change(function(){ $(this).closest('.uploader').find('img').fadeTo('slow', $(this).prop('checked') ? .2 : 1);});");

        $current = $this->_current = $ill->imgSrc;
        if ($current)   {
            $view->registerJs("$id.cropper('loadImage', '$current');");
        }

        $widget = $this->viewPath . DIRECTORY_SEPARATOR . 'widget.php';
        echo $view->renderFile($widget, [
            'uploader' => $this,
        ]);
    }
13051
public function onCropImage()
    {
        $this->abortIfReadOnly();

        $imageSrcPath = trim(Input::get('img'));
        $selectionData = Input::get('selection');
        $cropSessionKey = Input::get('cropSessionKey');
        $path = Input::get('path');
        $path = MediaLibrary::validatePath($path);

        if (!strlen($imageSrcPath)) {
            throw new ApplicationException('Invalid input data');
        }

        if (!preg_match('/^[0-9a-z]+$/', $cropSessionKey)) {
            throw new ApplicationException('Invalid input data');
        }

        if (!is_array($selectionData)) {
            throw new ApplicationException('Invalid input data');
        }

        $result = $this->cropImage($imageSrcPath, $selectionData, $cropSessionKey, $path);

        $selectionMode = Input::get('selectionMode');
        $selectionWidth = Input::get('selectionWidth');
        $selectionHeight = Input::get('selectionHeight');

        $this->setSelectionParams($selectionMode, $selectionWidth, $selectionHeight);

        return $result;
    }
676628
private function assertValidAttribute($attribute)
    {
        if ( ! isset($this->documentChangeSet[$attribute])) {
            throw new \InvalidArgumentException(sprintf(
                'Attribute "%s" is not a valid attribute of the document "%s" in PreUpdateEventArgs.',
                $attribute,
                get_class($this->getDocument())
            ));
        }
    }
704826
protected function validateAttributes()
    {
        if ($this->file === null && count($this->dirsets) === 0 && count($this->filesets) === 0 && count($this->filelists) === 0) {
            throw new BuildException("CopyTask. Specify at least one source - a file, fileset or filelist.");
        }

        if ($this->destFile !== null && $this->destDir !== null) {
            throw new BuildException("Only one of destfile and destdir may be set.");
        }

        if ($this->destFile === null && $this->destDir === null) {
            throw new BuildException("One of destfile or destdir must be set.");
        }

        if ($this->file !== null && $this->file->exists() && $this->file->isDirectory()) {
            throw new BuildException("Use a fileset to copy directories.");
        }

        if ($this->destFile !== null && (count($this->filesets) > 0 || count($this->dirsets) > 0)) {
            throw new BuildException("Cannot concatenate multiple files into a single file.");
        }

        if ($this->destFile !== null) {
            $this->destDir = new PhingFile($this->destFile->getParent());
        }
    }
714283
protected function initConfig() {
		$config = Xml::read($this->file);

		if ($config->getName() !== 'container') {
			throw new InvalidConfig('Root element of a config must be a "container"', null, null, $config);
		}

		$this->override = ($config->override === 'true');
		
		$this->includes     = [];
		$this->parameters   = new stdClass();
		$this->services     = new stdClass();
		$this->initializers = new stdClass();
		
		foreach ($config->getContent() as $element) {
			$name = $element->getName();
			
			if ($name === 'includes') {
				$this->includes = array_merge($this->includes, $this->processIncludes($element));
				continue;
			}
			
			if ($name === 'parameters') {
				$this->parameters = Std::objectMerge($this->parameters, $this->processParameters($element));
				continue;
			}
			
			if ($name === 'services') {
				$this->services = Std::objectMerge($this->services, $this->processServices($element));
				continue;
			}
			
			if ($name === 'initializers') {
				$this->initializers = Std::objectMerge($this->initializers, $this->processInitializers($element));
				continue;
			}
			
			throw new InvalidConfig('Unknown element "' . $element->getName() . '" in container', null, null, $element->getName());
		}
	}
1290698
public function init()
    {
        parent::init();

        if (!$this->imageSrc) {
            $imageSrc = ArrayHelper::remove($this->imageOptions, 'src', null);
            if (!$imageSrc) {
                throw new InvalidConfigException("Image src must be defined.");
            }

            $this->imageSrc = $imageSrc;
        }

        Html::addCssClass($this->imageOptions, ['plugin' => 'materialboxed']);

        if ($this->imageCaption !== false) {
            $this->imageOptions['data-caption'] = $this->encodeImageCaption ? Html::encode($this->imageCaption) : $this->imageCaption;
        }
    }
620223
public function init()
    {
        parent::init();
        if (!Yii::$app->has('wechat')) {
            throw new InvalidConfigException("Unknown component ID: wechat.");
        }
        $this->wechat = Yii::$app->wechat;
    }
1076249
protected function initAttributes()
    {
        foreach ($this->attributeCollection as $attribute) {
            $this->attributes[$attribute->getAttributeCode()] = [
                'id' => $attribute->getId(),
                'is_required' => $attribute->getIsRequired(),
                'is_static' => $attribute->isStatic(),
                'rules' => $attribute->getValidateRules() ? unserialize($attribute->getValidateRules()) : null,
                'type' => Import::getAttributeType($attribute),
                'options' => $this->getAttributeOptions($attribute),
                'attribute' => $attribute
            ];
        }

        return $this;
    }
888638
public function setAttribute($key, $value) {
    if (($key == static::$table_type_field) || (!$this->isInAllAttributes($key))) {
      throw new InvalidAttributeException("The attribute {$key} is non available.");
    }

    return parent::setAttribute($key, $value);
  }
1348689
public function removeAttribute() {
    $args = func_get_args();
    foreach ($args as $arg) {
      // Support arrays or multiple arguments.
      if (is_array($arg)) {
        foreach ($arg as $value) {
          unset($this->storage[$value]);
        }
      }
      else {
        unset($this->storage[$arg]);
      }
    }

    return $this;
  }
775491
public function addAttributes( $attributes = array() )
	{
		foreach( $attributes as $key => $value )
		{
			if( $key == 'class' )
			{
				if( is_string( $value ) )
					$value	= explode( " ", $value );
				if( !is_array( $value ) && !( $value instanceof ArrayIterator ) )
					throw new InvalidArgumentException( 'Class attribute must be string, array or iterator' );
				foreach( $value as $class )
					$this->addClass( $class );
				continue;
			}
			else
				$this->attributes[$key]	= $value;
		}
	}
163844
public void setAttribute(String domainName, String beanName, String attrName, Object value) throws Exception {
		setAttribute(ObjectNameUtil.makeObjectName(domainName, beanName), attrName, value);
	}
901941
private function initAttributes() {
    if ($this->attributes == null) {
      $this->attributes = [];
      $this->attributes['byname'] = [];
      $this->attributes['refs'] = [];

      $attributes = $this->getAttributes();
      foreach ($attributes as $attribute) {
        $this->attributes['byname'][$attribute->getName()] = $attribute;
        if ($attribute instanceof ReferenceDescription) {
          $this->attributes['refs'][] = $attribute;
        }
      }
    }
  }
1255772
protected function initData()
    {
        if (empty($this->data)) {
            return;
        }

        if (is_array($this->data) || $this->data instanceof JsExpression) {
            $this->clientOptions['data'] = $this->data;
        } elseif (is_string($this->data)) {
            $this->clientOptions['data'] = new JsExpression($this->data);
        } else {
            throw new InvalidConfigException('The "data" option can only be a string or an array');
        }
    }
109510
public function init()
    {
        if ($this->dataProvider === null) {
            throw new InvalidConfigException('The "dataProvider" property must be set.');
        }
        if ($this->emptyText === null) {
            $this->emptyText = Yii::t('yii', 'No results found.');
        }
        if (!isset($this->options['id'])) {
            $this->options['id'] = $this->getId();
        }

        if ($this->formatter == null) {
            $this->formatter = Yii::$app->getFormatter();
        } elseif (is_array($this->formatter)) {
            $this->formatter = Yii::createObject($this->formatter);
        }
        if (!$this->formatter instanceof Formatter) {
            throw new InvalidConfigException('The "formatter" property must be either a Format object or a configuration array.');
        }

        if (!$this->keyColumnName) {
            throw new InvalidConfigException('The "keyColumnName" property must be specified"');
        }
        if (!$this->parentColumnName) {
            throw new InvalidConfigException('The "parentColumnName" property must be specified"');
        }

        $this->initColumns();
    }
137688
public function init()
    {
        if (empty($this->models) && !$this->modelClass) {
            throw new InvalidConfigException('You must at least specify "models" or "modelClass"');
        }

        if ($this->form !== null && !$this->form instanceof ActiveForm) {
            throw new InvalidConfigException('Property "form" must be an instance of yii\widgets\ActiveForm');
        }

        if (!is_array($this->models)) {
            throw new InvalidConfigException('Property "models" must be an array');
        }

        if ($this->models) {
            $modelClasses = [];
            foreach ($this->models as $model) {
                if (!$model instanceof Model) {
                    throw new InvalidConfigException('Model has to be an instance of yii\base\Model');
                }

                $modelClasses[get_class($model)] = true;
            }

            if (count($modelClasses) > 1) {
                throw new InvalidConfigException("You cannot use models of different classes");
            }

            $this->modelClass = key($modelClasses);
        }

        parent::init();
    }
742319
public function setAttributes($figNamespace, array $attributes)
    {
        // We don't call the parent version, which does extraneous work of resolving conds and walks etc.,
        // whereas we just need to check existence of class attribute.
        // A feed tag is oblivious to other control directives.


        $this->dataFile = isset($attributes['file']) ? $attributes['file'] : null;

        if(null === $this->dataFile) {
            throw new RequiredAttributeException($this->getTagName(),
                $this->xmlLineNumber,
                'file');
        }

    }