本文整理匯總了PHP中Attribute::setName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Attribute::setName方法的具體用法?PHP Attribute::setName怎麽用?PHP Attribute::setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Attribute
的用法示例。
在下文中一共展示了Attribute::setName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGroupsToArray
public function testGroupsToArray()
{
$array = array('BMI' => array('groups' => array('group1', 'group2')));
$attr = new Attribute();
$attr->setName('BMI');
$attr->addGroup('group1');
$attr->addGroup('group2');
$this->assertEquals($array, $attr->toArray());
}
示例2: parseAttributes
protected function parseAttributes()
{
$attributes = array();
foreach ($this->XPath->evaluate('//dd:DataDescription/Dictionary[@default="true"]/Field') as $f) {
$attribute = new Attribute();
foreach ($f->childNodes as $n) {
if ($n->nodeName == "Name") {
$attribute->setName($n->nodeValue);
}
if ($n->nodeName == "Category") {
$attribute->addCategory($n->nodeValue);
}
if ($n->nodeName == "Interval") {
$closure = $n->getAttribute('closure');
$interval = substr($closure, 0, 4) === 'open' ? '(' : '<';
$interval .= $n->getAttribute('leftMargin') . ';' . $n->getAttribute('rightMargin');
$interval .= substr($closure, -4, 4) === 'Open' ? ')' : '>';
$attribute->addInterval($interval);
}
}
array_push($attributes, $attribute);
}
return $attributes;
}
示例3: create
/**
* Creates SK ITC Bundle DTD Attribute List
*
* @param string $source
* SK ITC Bundle DTD Attribute List Source
* @return \SK\ITCBundle\ORM\DTD\AttributeList
*/
public static function create($source, Document $document)
{
$entity = null;
$sourceAttributes = explode(" ", $source);
$instance = new self($source);
$entity = array_shift($sourceAttributes);
$j = 0;
for ($i = 0; $i < count($sourceAttributes); $i++) {
$sourceAttribute = $sourceAttributes[$i];
if (preg_match("/%/", $sourceAttribute) && $j == 0) {
$j = $j + 2;
$attribute = new Attribute("");
$instance->setAttribute($attribute);
} else {
$column = $j % 3;
switch ($column) {
case 0:
$attributeName = $sourceAttribute;
++$j;
break;
case 1:
$attributeEntity = $sourceAttribute;
++$j;
break;
case 2:
$attributeDefaultValue = $sourceAttribute;
$attribute = new Attribute("");
$attribute->setDocument($document);
$attribute->setName($attributeName);
$attribute->setEntity($document->getEntity($attributeEntity));
$attribute->setDefaultValue($attributeDefaultValue);
$instance->setAttribute($attribute);
$j = 0;
break;
}
}
}
return $instance;
}