You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					30 lines
				
				532 B
			
		
		
			
		
	
	
					30 lines
				
				532 B
			| 
											7 years ago
										 | <?php
 | ||
|  | /**
 | ||
|  |  * Created by Error202
 | ||
|  |  * Date: 08.08.2018
 | ||
|  |  */
 | ||
|  | 
 | ||
|  | namespace common\behaviors;
 | ||
|  | 
 | ||
|  | use yii\helpers\Html;
 | ||
|  | use yii\base\Behavior;
 | ||
|  | 
 | ||
|  | class WidgetContentBehavior extends Behavior
 | ||
|  | {
 | ||
|  | 	/**
 | ||
|  | 	 * Parse Widgets [?= ... ?]
 | ||
|  | 	 * @param $text
 | ||
|  | 	 *
 | ||
|  | 	 * @return string
 | ||
|  | 	 */
 | ||
|  | 	public function content($text): string
 | ||
|  | 	{
 | ||
|  | 		$content = preg_replace_callback('/\[\?= (.*)\((.*)\) \?\]/m', function ($m) {
 | ||
|  | 			$array  = [];
 | ||
|  | 			$string = Html::decode( $m[2] );
 | ||
|  | 			eval( "\$array = $string;" );
 | ||
|  | 			return $m[1]( $array );
 | ||
|  | 		}, $text);
 | ||
|  | 		return $content;
 | ||
|  | 	}
 | ||
|  | }
 |