common/actions/meta/Create.php
public function run() {

		$parent	= $this->model;

		if( isset( $parent ) ) {

			$metaClass	= $this->metaService->getModelClass();

			$meta = new $metaClass;

			if( $meta->hasAttribute( 'modelId' ) ) {

				$meta->modelId = $parent->id;
			}
			else {

				$meta->parentId		= $parent->id;
				$meta->parentType	= $this->modelService->getParentType();
			}

			if( empty( $meta->type ) ) {

				$meta->type = CoreGlobal::TYPE_DEFAULT;
			}

			if( empty( $meta->valueType ) ) {

				$meta->valueType = IMeta::VALUE_TYPE_TEXT;
			}

			if( $meta->load( Yii::$app->request->post(), $meta->getClassName() ) && $meta->validate() ) {

				$this->metaService->create( $meta );

				$data = [ 'id' => $meta->id, 'name' => $meta->name, 'value' => HtmlPurifier::process( $meta->value ) ];

				// Trigger Ajax Success
				return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
			}

			// Generate Errors
			$errors = AjaxUtil::generateErrorMessage( $meta );

			// Trigger Ajax Failure
			return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
public function run() {

		$parent	= $this->model;

		if( isset( $parent ) ) {

			$metaClass	= $this->metaService->getModelClass();

			$meta = new $metaClass;

			if( $meta->hasAttribute( 'modelId' ) ) {

				$meta->modelId = $parent->id;
			}
			else {

				$meta->parentId		= $parent->id;
				$meta->parentType	= $this->modelService->getParentType();
			}

			if( empty( $meta->type ) ) {

				$meta->type = CoreGlobal::TYPE_DEFAULT;
			}

			if( empty( $meta->valueType ) ) {

				$meta->valueType = IMeta::VALUE_TYPE_TEXT;
			}

			if( $meta->load( Yii::$app->request->post(), $meta->getClassName() ) && $meta->validate() ) {

				$this->metaService->create( $meta );

				$data = [ 'id' => $meta->id, 'name' => $meta->name, 'value' => HtmlPurifier::process( $meta->value ) ];

				// Trigger Ajax Success
				return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
			}

			// Generate Errors
			$errors = AjaxUtil::generateErrorMessage( $meta );

			// Trigger Ajax Failure
			return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
public function run ( ) { $ parent = $ this -> model ; if ( isset ( $ parent ) ) { $ metaClass = $ this -> metaService -> getModelClass ( ) ; $ meta = new $ metaClass ; if ( $ meta -> hasAttribute ( 'modelId' ) ) { $ meta -> modelId = $ parent -> id ; } else { $ meta -> parentId = $ parent -> id ; $ meta -> parentType = $ this -> modelService -> getParentType ( ) ; } if ( empty ( $ meta -> type ) ) { $ meta -> type = CoreGlobal :: TYPE_DEFAULT ; } if ( empty ( $ meta -> valueType ) ) { $ meta -> valueType = IMeta :: VALUE_TYPE_TEXT ; } if ( $ meta -> load ( Yii :: $ app -> request -> post ( ) , $ meta -> getClassName ( ) ) && $ meta -> validate ( ) ) { $ this -> metaService -> create ( $ meta ) ; $ data = [ 'id' => $ meta -> id , 'name' => $ meta -> name , 'value' => HtmlPurifier :: process ( $ meta -> value ) ] ; // Trigger Ajax Success return AjaxUtil :: generateSuccess ( Yii :: $ app -> coreMessage -> getMessage ( CoreGlobal :: MESSAGE_REQUEST ) , $ data ) ; } // Generate Errors $ errors = AjaxUtil :: generateErrorMessage ( $ meta ) ; // Trigger Ajax Failure return AjaxUtil :: generateFailure ( Yii :: $ app -> coreMessage -> getMessage ( CoreGlobal :: ERROR_REQUEST ) , $ errors ) ; } // Trigger Ajax Failure return AjaxUtil :: generateFailure ( Yii :: $ app -> coreMessage -> getMessage ( CoreGlobal :: ERROR_NOT_FOUND ) ) ; }
Create Meta for given parent slug and parent type.
Create Meta for given parent slug and parent type .