本文整理汇总了PHP中Field类的典型用法代码示例。如果您正苦于以下问题:PHP Field类的具体用法?PHP Field怎么用?PHP Field使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Field类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make
public static function make()
{
$itemFactory = new itemFactory();
$collectionFactory = new ItemCollectionFactory();
$fields = new Field();
return $fields->setItemFactory($itemFactory)->setFactory($collectionFactory)->setFormatter(new FieldFormatter());
}
示例2: add
public function add(Field $field)
{
$attr = $field->name();
$field->setValue($this->entity->{$attr}());
$this->fields[] = $field;
return $this;
}
示例3: __construct
/**
* Конструктор, нужен для реализации паттерна Observer
*
* @param \REXFramework\forms\Field $field
* @param mixed $criterion Критерий для валидатора, например, регулярное выражение
* @param string $message Сообщение об ошибке
*/
public function __construct(Field $field, $criterion = null, $message = '')
{
$this->field = $field;
$this->criterion = $criterion;
$this->message = $message;
$field->attach($this);
}
示例4: getKeyKey
/**
* @return mixed
*/
protected function getKeyKey()
{
$n = get_called_class();
if (!isset(self::$k_cache[$n])) {
$key = null;
$r = $this->getReflection();
//Parse the annotations in a class
$reader = new \Phalcon\Annotations\Reader();
$parsing = $reader->parse($r->getName());
//Create the reflection
$annotations = new \Phalcon\Annotations\Reflection($parsing);
if ($annotations->getClassAnnotations()->has('key')) {
$key = $annotations->getClassAnnotations()->get('key');
} else {
foreach ($r->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
if (!$property->isPublic() || $property->isStatic()) {
continue;
}
$f = new Field($r, $property);
if ($f->isKey()) {
$key = $property->getName();
break;
}
}
}
self::$k_cache[$n] = $key;
}
return self::$k_cache[$n];
}
示例5: removeField
public function removeField(Field $field)
{
if (isset($this->fields[$field->getName()])) {
unset($this->fields[$field->getName()]);
}
return $this;
}
示例6: addField
/**
* @param Field $field
* @throws DuplicateFieldException
*/
public function addField(Field $field)
{
if (isset($this->fields[$field->getName()])) {
throw new DuplicateFieldException('Field `' . $field->getName() . '` already exists');
}
$this->fields[$field->getName()] = $field;
}
示例7: resolve
/**
* @param Field $field
*
* @return array
*/
public function resolve(Field $field)
{
$defaults = ['required' => false, 'label' => $field->getLabel()];
$definition = $this->registry->findDefinitionFor($field->getDocument());
$attributes = $definition->getAttributes($field);
return array_merge($defaults, $this->trim($attributes));
}
示例8: process
public function process($input)
{
$id = 0;
$minesAll = array();
while(count($input)>0)
{
$line = array_shift($input);
if($this->isNewField($line))
{
$dim = $this->getFieldDimensions($line);
$m = $dim[0];
$n = $dim[1];
if(!$this->IsTheEnd($m, $n))
{
if(!$this->isValidDim($m, $n)){
throw new Exception ("Error: Invalid field dimensions! $m, $n");
}
++$id;
$lineNum = 0;
$field = new Field($id, $m, $n);
$field->setDebug($this->debug);
$this->fields[$id] = $field;
}
}
else
{
if( count($this->fields)<=0 ){
throw new Exception ("Error something wrong\n");
}
$field = $this->getField($id);
$id = $field->getFieldId();
/* line data process */
foreach(str_split($line) as $x=>$cellvalue)
{
$field->addCell($x, $lineNum);
/* detecting mines */
if($this->isMinedCell($cellvalue)){
$minesAll[$id][] = array($x, $lineNum);
}
}
$this->fields[$id] = $field;
$lineNum++;
}
}
if(count($minesAll)>0)
{
foreach($minesAll as $id=>$mines)
{
$field = $this->getField($id);
$field = $this->MineField($field, $mines);
}
}
return $this->getOutput();
}
示例9: alterField
function alterField(\Field $field, $add = false)
{
$q = $this->db->dsql()->expr('alter table [al_table] add [field_name] [type_expr]');
$q->setCustom('al_table', $this->table);
$q->setCustom('field_name', $x = $field->actual_field ?: $field->short_name);
$q->setCustom('type_expr', $this->db->dsql()->expr($this->resolveFieldType($field->type())));
$q->execute();
}
示例10: testCanOverrideInvalidRelation
public function testCanOverrideInvalidRelation()
{
$args = array('type' => 'taxonomy', 'taxonomy' => 'category', 'relation' => 'IN');
$f = new Field($args);
$defaults = $f->getDefaults();
$default_relation = $defaults['relation'];
$this->assertTrue($f->getRelation() == $default_relation);
}
示例11: DoAddField
/**
* @param Field $field
* @return void
*/
protected function DoAddField($field)
{
$sourceTable = $field->GetSourceTable();
if (!isset($sourceTable) || $sourceTable == '') {
$sourceTable = $this->tableName;
}
$this->GetSelectCommand()->AddField($sourceTable, $field->GetName(), $field->GetEngFieldType(), $field->GetAlias());
}
示例12: addField
/**
* Add field
*
* @param Field $field
* @throws \LogicException
*/
public function addField(Field $field)
{
$name = $field->getName();
if (isset($this->fields[$name])) {
throw new \LogicException(sprintf('Field "%s" already exists', $name));
}
$this->fields[$name] = $field;
}
示例13: add
/**
* Méthode permettant d'ajouter un champ à la liste
*
* @param \OCFram\Field $field
* @return \OCFram\Form
*/
public function add(Field $field)
{
$attr = $field->name();
// Récupérer le nom du champ
$field->setValue($this->entity->{$attr}());
// Assigner la valeur correspondante au champ
$this->fields[] = $field;
// Ajouter le champ passé en argument à la liste des champs
return $this;
}
示例14: update
public function update()
{
$f = new Field();
$f->name = $this->getFieldName();
$f->type = $this->getFieldType();
$f->save();
$this->fieldSetup($f);
$f->save();
return $f;
}
示例15: validate
/**
* Validates the given data against this constraint. If the constraint was
* already triggered before, then it will return the last result.
*
* @param mixed $data The data
*
* @return boolean
*/
public function validate(Field $field, $data)
{
if (true === $this->checked) {
return;
}
$this->checked = true;
if (true === $this->check($data)) {
return;
}
$field->addError(new Error($field->getInternalName(), $this->getMessage()));
}