2015-12-11
@param string $name
@param string|null|Phrase $label [optional]
@param array(string => mixed) $data [optional]
@return Quantity|E
501145
protected function size($name, $label = null, $data = []) {return $this->quantity(
		$name, $label, $data + [Quantity::P__VALUES => SizeUnit::s()->toOptionArray()]
	);}
759284
public function required($name, $data = null)
	{
		if (null === $data)
		{
			return isset($this->data[$name]);
		}
		else
		{
			return isset($data[$name]);
		}
	}
283053
final protected function textarea($name, $label = null, $data = []) {return $this->field(
		$name, Textarea::class, $label, $data
	);}
557712
public function getValue(string $name): ?string
    {
        if (isset($this->data[$name])) {
            return $this->data[$name]->value;
        }
        return null;
    }
764711
protected function getTerm($name, Row $row, $vocabulary) {
    // Attempt to fetch an existing term.
    $properties = [];
    if (!empty($name)) {
      $properties['name'] = $name;
    }
    $vocabularies = taxonomy_vocabulary_get_names();
    if (isset($vocabularies[$vocabulary])) {
      $properties['vid'] = $vocabulary;
    }
    else {
      // Return NULL when filtering by a non-existing vocabulary.
      return NULL;
    }

    $terms = \Drupal::getContainer()->get('entity.manager')->getStorage('taxonomy_term')->loadByProperties($properties);
    $term = reset($terms);
    if (!empty($term)) {
      if ($row->getDestinationProperty('langcode') && $row->getDestinationProperty('langcode') != LanguageInterface::LANGCODE_NOT_SPECIFIED) {
        if (!$term->hasTranslation($row->getDestinationProperty('langcode'))) {
          $term->addTranslation($row->getDestinationProperty('langcode'));
        }
        $term = $term->getTranslation($row->getDestinationProperty('langcode'));
      }
      return $term;
    }
    // Fallback, create a new term.
    $term = Term::create($properties);
    if ($row->getDestinationProperty('langcode')) {
      $term->langcode = $row->getDestinationProperty('langcode');
    }
    return $term;
  }
331736
public function addEmail($name, $label = '',$is_mandatory = true )
    {
        $e = new \FrenchFrogs\Form\Element\Email($name, $label);
        $this->addElement($e);

        if ($is_mandatory) {
            $e->addRule('required');
        } else {
            $e->addFilter('nullable');
        }
        $e->addRule('email');

        return $e;
    }
571364
public function startMeasure($name, $label = null, $collector = null)
    {
        $start                        = microtime(true);
        $this->startedMeasures[$name] = [
            'label'     => $label ?: $name,
            'start'     => $start,
            'collector' => $collector,
        ];
    }
1340566
public static function checkLabel( $label, $name, $id, $checked = false, $attribs = array() ) {
		return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) .
			   '&#160;' .
			   self::label( $label, $id, $attribs );
	}
371067
private function getDataSet($label, $data, $index = 0)
    {
        $set = $this->datasets[$index];
        $set['label'] = $label;
        $set['data'] = $data;

        return $set;
    }
128608
public function label($name, $label, array $attr = null)
    {
        return $this->input($name, [ 'type' => 'label', 'label' => $label, 'attr' => $attr ]);
    }
66753
public function addBoolean($name, $label = '', $attr = [])
    {

        $c = new Column\Boolean($name, $label, $attr);
        $this->addColumn($c);

        return $c;
    }
802044
public function name(string $name, string $label) : ChartViewDefiner
    {
        $definer = new ChartViewDefiner($this->dataSource, $name, $label);

        $this->viewDefiners[] = $definer;

        return $definer;
    }
306518
public function addLabel($name, $label = '', $attr = [] )
    {
        $e = new \FrenchFrogs\Form\Element\Label($name, $label, $attr);
        $this->addElement($e);
        return $e;
    }
259564
protected function parseSingleIdentityInRelationship($name, array $data)
    {
        list ($type, $idx) = $this->parseTypeAndId($data);

        $isValid = true;
        if (empty($type) === true || is_string($type) === false) {
            $isValid  = false;
            $this->errors->addRelationshipTypeError($name, 'Element should be non empty string.');
        }
        if ($idx === null || is_string($idx) === false) {
            $isValid = false;
            $this->errors->addRelationshipIdError($name, 'Element should be non empty string.');
        }

        $result = $isValid === true ? new ResourceIdentifierObject($type, $idx) : null;

        return $result;
    }
747430
public function createEmailElement($name, $label, $required = false, $multi = false) {
        $options['label']     = $label;
        $options['maxlength'] = 250;
        $options['required']  = $required;
        $options['size']      = 50;

        $element = $this->_form->createElement('text', $name, $options);

        if ($multi) {
            $element->addValidator('SimpleEmails');
        } else {
            $element->addValidator('SimpleEmail');
        }

        return $element;
    }
884384
private Label getOrCreateLabel(final String name) {

		Label label = labelCache.get(name);
		if (label == null) {

			label = new LabelImpl(name);
			labelCache.put(name, label);
		}

		return label;
	}
103981
public function addDateTime($name, $label)
	{
		$comp = new DateTimeInput($label);
		$this->addComponent($comp, $name);

		return $comp;
	}