Create sample content for response.

@param $type

@return string
325345
protected function createContent($type)
    {
        if ($type == 'json') {
            $this->headers['content_type'] = 'application/json; charset=UTF-8';

            return json_encode(['url' => $this->ch, 'status' => 'ok']);
        } elseif ($type == 'xml') {
            $this->headers['content_type'] = 'text/xml; charset=UTF-8';

            return '<?xml version="1.0" encoding="UTF-8"?><result><url>'.$this->ch.'</url><status>ok</status></result>';
        }

        return 'ok';
    }
1220065
public function &create($type, $parameters = array())
	{
		$class = $this->get_class($type);

		if (in_array($class, $this->legacy))
		{
			switch ($type)
			{
				case 'locator':
					// Legacy: file, timeout, useragent, file_class, max_checked_feeds, content_type_sniffer_class
					// Specified: file, timeout, useragent, max_checked_feeds
					$replacement = array($this->get_class('file'), $parameters[3], $this->get_class('content_type_sniffer'));
					array_splice($parameters, 3, 1, $replacement);
					break;
			}
		}

		if (!method_exists($class, '__construct'))
		{
			$instance = new $class;
		}
		else
		{
			$reflector = new ReflectionClass($class);
			$instance = $reflector->newInstanceArgs($parameters);
		}

		if (method_exists($instance, 'set_registry'))
		{
			$instance->set_registry($this);
		}
		return $instance;
	}
191547
function createFile($name, $type = 'controller')
    {
        $name = $type == 'html'?strtolower($name):$name;
        $path = _APP.ucfirst($type).'/';
        $ext = $type == 'html'?'.html':'.php';

        if(file_exists($path.$name.$ext))
            return "\n\n  WARNNING: this file already exists!\n  ".$path.$name.$ext."\n\n";

        if(!$this->checkAndOrCreateDir(dirname($path.$name.$ext),true))
            return "\n\n  WARNNING: access denied in directory '".dirname($path.$name.$ext)."'\n\n";

        //get template
        $file = file_get_contents($this->cliPath.'templates/'.$type.'.tpl');

        //replace %namespace% and %name%
        $file = str_replace('%name%', ucfirst(basename($name)), $file);
        $namespace = ucfirst($type).'\\';
        foreach(explode('/', dirname($name)) as $namespc){
            if($namespc == '.') break;
            $namespace .= ucfirst($namespc).'\\';
        }
        $file = str_replace('%namespace%', trim($namespace, '\\'), $file);

        //saving the file
        $ok = file_put_contents($path.$name.$ext, $file);

        if($ok) return "\n\n  Arquivo '".$path.$name.$ext."' criado com sucesso!\n\n";
        else return "\n\n  Não foi possível criar '".$path.$name."'!\n\n";
    }
823304
protected function makeRequest($type) {

        if(isset($this->{$type . 'Request'}) && $this->{$type . 'Request'}) {
            $request = app()->make($this->{$type . 'Request'});
            if (!$request instanceof Request) {
                throw new \Exception("Class {$this->{$type . 'Request'}} must be an instance of Illuminate\\Http\\Request");
            }
            return $request;
        }

    }
239637
public function setContent($data, $type = DataFormats::PHP_ARRAY)
    {
        $this->content = $data;

        switch ($type) {
            case DataFormats::PHP_ARRAY:
                $this->contentAsArray = $data;
                $this->contentType = ''; // this could be null, but may cause issues with clients
                break;
            case DataFormats::JSON:
                $this->contentAsArray = json_decode($data, true);
                $this->contentType = DataFormats::toMimeType($type);
                break;
        }

        return $this;
    }
932584
public function mapResponseToType($type) {

        if (!empty($this->rawData)) {

            foreach ($this->rawData as $dataSet) {

                if (!is_array($dataSet)) {
                    $this->data = (new $type())->initFromArray($this->rawData);
                    break;
                }

                $this->data[] = (new $type())->initFromArray($dataSet);

            }

        }

        if (!empty($this->rawData['before'])) {
            $this->data->setBefore($this->rawData['before']);
        }

        if (!empty($this->rawData['after'])) {
            $this->data->setAfter($this->rawData['before']);
        }

        if (!empty($this->rawData['message'])) {
            $this->data->setMessage($this->rawData['message']);
        }

        return $this;

    }
6374
public function content($type)
	{
		$assets = array();
		
		foreach ($this->assets as $asset) {
			if ('style' == $type && 'css' !== $asset['ext'] && 'less' !== $asset['ext']) {
				continue;
			}
			else if ('script' == $type && 'js' !== $asset['ext']) {
				continue;
			}
			
			$assets[] = $this->process($asset);
		}
		
		if (empty($assets)) {
			return '';
		}
		
		if (count($assets) > 1 || $this->minify) {
			$assets = $this->combine($assets, $type);
		}
		
		$content = array();
		
		foreach ($assets as $asset) {
			$content[] = File::get(array_get($asset, 'path'));
		}
		
		return implode("\n\n", $content);
	}
1200629
public static function create($type = self::TYPE_SESSION)
    {
        $class_name = '\\cms\\login\\driver\\' . ucfirst($type) . 'Login';
        if (class_exists($class_name)) {
            try {
                return $class_name::instance();
            } catch (\Exception $e) {}
        }
    }
1057771
public static function create($type) {
        switch ($type) {
            case Field::TYPE_CHARACTER:
                return new field\CharacterField;
            case Field::TYPE_DATE:
                return new field\DateField;
            case Field::TYPE_LOGICAL:
                return new field\LogicalField;
            case Field::TYPE_MEMO:
                return new field\MemoField;
            case Field::TYPE_NUMERIC:
                return new field\NumericField;
            default:
                throw new Exception("Unsupported field `$type`");
        }
    }
1189558
public function newAction($type) {
        $entity = new Media();
        $entity->setMediaType($type);
        $form = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
1185782
public function createContent($translatedContent, $type = null, $father = null)
    {
        if (isset($translatedContent['content']) and
            is_array($translatedContent['content']) and
            $id = $this->contentManager->createContent($translatedContent['content']) and
            $content = $this->content->find($id)
        ) {
            if ($father) {
                $father = $this->content->find($father);
                $first = $this->subContent->findOneBy(array('back' => null, 'father' => $father));
                $subContent = new SubContent($first);
                $subContent->setFather($father);
                $subContent->SetChild($content);
                $this->manager->persist($subContent);
            } else {
                $type = $this->type->findOneBy(array('name' => $type));
                $first = $this->contentType->findOneBy(array('back' => null, 'type' => $type));
                $contentType = new Content2Type($first);
                $contentType->setContent($content);
                $contentType->setType($type);
                $this->manager->persist($contentType);
            }

            $this->manager->flush();

            return $content->getId();
        }
    }
1089249
public function makeGenerated($type)
    {
        while($this->password == null) {
            $password = ($type == 'wordbased') ? Passworder::createWordBasedPassword() : Passworder::createRandomPassword();

            $this->info('Password: ' . $password);
            $this->info('Nato version: ' . $password->toNato());
            $passwordOk = $this->ask('Is this password ok? [y/n]');

            if (strtolower($passwordOk) == 'y') {
                $this->password = $password;
            }
        }
    }
166547
public function listContents($type)
    {
        $names = [];
        $files = $this->listFiles($type);

        foreach ($files as $file) {
            $names[] = static::getName($file);
        }

        return $names;
    }
1159930
public function build($type)
    {
        if (!isset($this->types[$type])) {
            throw new \Exception("Unknown request type.");
        }
        return new $this->types[$type]();
    }
1055894
public function make($type)
    {
        if ($instance = array_get($this->resolved, $type)) {
            return $instance;
        }

        return $this->build($type);
    }
736096
public function from($type)
    {
        switch ($type) {
            case 'ini':
                $this->data = Ini::decode($this->string);
                break;

            case 'json':
                $this->data = Json::decode($this->string);
                break;

            case 'php':
                $this->data = Php::decode($this->string);
                break;

            case 'xml':
                $this->data = Xml::decode($this->string);
                break;

            case 'yml':
            case 'yaml':
                $this->data = Yaml::decode($this->string);
                break;
            
            default:
                throw new \Exception("Format not supported: " . $type);
        }

        return $this;
    }
679830
public function actionCreate($type)
    {
        if (!is_term_type_name($type)) {
            throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
        }
        $model = new Term();
        $model->term_type = $type;
        if ($model->loadAll(request()->post())) {
            $model->term_type = $type;
            if ($model->saveAll()) {
                set_flash_has_been_saved();
                $seo = new Seo([
                    'title'              => $model->name,
                    'slug'               => $model->slug,
                    'description'        => substr(strip_tags($model->description), 0, 255),
                    'social_image'       => $model->feature_img,
                    'social_title'       => $model->name,
                    'social_description' => substr(strip_tags($model->description), 0, 255),
                    'obj_type'           => $model->term_type,
                    'obj_id'             => $model->id,
                ]);
                $seo->save();

                return $this->redirect([
                    'update',
                    'id' => $model->id,
                ]);
            } else {
                set_flash_has_not_been_saved();

                return $this->render('create', [
                    'model'    => $model,
                    'termType' => $type,
                ]);
            }
        }

        return $this->render('create', [
            'model'    => $model,
            'termType' => $type,
        ]);
    }