Creates a legend for this fieldset.

@param string $type The class name of the legend.

@return Legend
483362
public function createLegend($type = 'legend')
  {
    switch ($type)
    {
      case 'legend':
        $tmp = new Legend();
        break;

      default:
        $tmp = new $type();
    }

    $this->legend = $tmp;

    return $tmp;
  }
1020910
public function setType(Type $type = null)
    {
        if ($this->type !== $type) {
            $this->type = $type;
        }

        return $this;
    }
664522
public function getType(string $type): Type
    {
        if (isset($this->types[$type])) {
            return $this->types[$type];
        }

        $instance = $this->createType($type);
        $this->addType($instance);
        $this->types[$type] = $instance;

        return $instance;
    }
608347
public function fieldset_open($attributes = array(), $legend = null)
	{
		$fieldset_open = '<fieldset ' . array_to_attr($attributes) . ' >';

		! is_null($legend) and $attributes['legend'] = $legend;
		if ( ! empty($attributes['legend']))
		{
			$fieldset_open.= "\n<legend>".$attributes['legend']."</legend>";
		}

		return $fieldset_open;
	}
187888
public static function factory($type)
    {
        if ($type instanceof TypeInterface) return $type;

        if (strpos($type, "\\") === false) {
            $type = ucfirst(trim(strval($type)));
            if (strripos(strrev($type), strrev('type')) === false) $type .= 'Type';

            $type = "DataEntity\\Type\\" . $type;
        }

        if (
            !class_exists($type)
            || !in_array("DataEntity\\TypeInterface", class_implements($type))
        ) throw new \InvalidArgumentException('Type ' . $type . ' is invalid.');

        return new $type;
    }
349928
protected function getBasicTemplate(string $type) : string
    {
        $view = $this->config->getView();
        $result = $view->Form->control('{{name}}', [
            'value' => '{{value}}',
            'type' => $type,
            'label' => false
        ]);

        return $result;
    }
1113961
public function withType(string $type): self
    {
        $metadata = clone $this;
        $metadata->type = $type;

        return $metadata;
    }
1318802
private function getTypeXml($type)
    {
        if (!isset($this->styles[$type])) {
            return "<{$type}/>";
        }

        return sprintf(StyleXml::BORDER_TYPE_XML,
            $type, $this->styles[$type], $this->colors[$type], $type);
    }
579088
public function setType($type)
    {
        if ($type === null) {
            $this->$type = $type;
        } else {
            $iconSetType = new IconSetTypeEnum($type);
            $this->type = $iconSetType->getValue();
        }

        return $this;
    }
372728
public function createSeries( $data, $title = null, $type = null )
	{
        return new Series( $data, $title, $this->jsWriter );
	}
361206
public function getColorForType($type)
    {
        // if we don't have a type return default color
        if (!isset($this->colors[$type])) {
            return Colours::DEFAULT_;
        }

        return $this->colors[$type];
    }
896212
protected function buildCreative($type)
    {
        // check type
        $creativeClassName = $this->buildCreativeClassName($type);
        if (!class_exists($creativeClassName)) {
            throw new \Exception('Wrong creative specified: ' . var_export($creativeClassName, true));
        }

        // get container
        if (!$this->creativesDomElement) {
            // get creatives tag
            $this->creativesDomElement = $this->adDomElement->getElementsByTagName('Creatives')->item(0);
            if (!$this->creativesDomElement) {
                $this->creativesDomElement = $this->adDomElement->ownerDocument->createElement('Creatives');
                $this->getDomElement()->appendChild($this->creativesDomElement);
            }
        }

        // Creative dom element: <Creative></Creative>
        $creativeDomElement = $this->creativesDomElement->ownerDocument->createElement('Creative');
        $this->creativesDomElement->appendChild($creativeDomElement);

        // Creative type dom element: <Creative><Linear></Linear></Creative>
        $creativeTypeDomElement = $this->adDomElement->ownerDocument->createElement($type);
        $creativeDomElement->appendChild($creativeTypeDomElement);

        // object
        $creative = new $creativeClassName($creativeDomElement);
        $this->creatives[] = $creative;

        return $creative;
    }
1113995
public function build($type)
    {
        if (!isset(self::$mapping[$type])) {
            throw new UnknownPacketTypeException(sprintf('Unknown packet type %d.', $type));
        }

        $class = self::$mapping[$type];

        return new $class();
    }
858956
public static function createWriter($type)
    {
        switch ($type) {
            case self::JSON:
                return new Impl\Json();
            case self::YAML:
                return new Impl\Yaml();
            case self::INI:
                return new Impl\Ini();
            case self::COLUMNS:
                return new Impl\Columns();
            case self::TABLE:
                return new Impl\ConsoleTable();
            case self::MARKDOWN:
                return new Impl\MarkdownTable();
            case self::DUMP:
                return new Impl\Dump();
        }

        throw new UnknownWriterTypeException("Sorry, writer type {$type} is not something I do");
    }
1073689
public function type($type = null)
    {
        if (is_null($type)) {
            return $this->type;
        }

        $this->type = $type;

        return $this;
    }
631330
public static function factory(StyleType $type): Style
    {
        return self::evaluate($type)->isInstanceOf(Style::class)->getValue();
    }
582847
public function actionCreate($type)
    {
        $model = new ProductTypeMeta();
        $model->product_type = $type;

        if ($model->loadAll(request()->post())) {
            $model->product_type = $type;
            if ($model->saveAll()) {
                return $this->redirect(['update', 'id' => $model->id]);
            }
        }

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