本文整理汇总了PHP中Property类的典型用法代码示例。如果您正苦于以下问题:PHP Property类的具体用法?PHP Property怎么用?PHP Property使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Property类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadXML
public function loadXML($xml)
{
$dom = new \SimpleXMLElement($xml);
if (!isset($dom->tokenXPath) || count($dom->tokenXPath) != 1) {
throw new \LengthException('exactly one tokenXPath has to be provided');
}
$this->tokenXPath = $dom->tokenXPath;
if (!isset($dom->tokenValueXPath) || count($dom->tokenValueXPath) != 1) {
throw new \LengthException('exactly one tokenValueXPath has to be provided');
}
$this->tokenValueXPath = $dom->tokenValueXPath;
if (!isset($dom->properties) || !isset($dom->properties->property) || count($dom->properties->property) == 0) {
throw new \LengthException('no token properties defined');
}
$n = 1;
$names = array();
foreach ($dom->properties->property as $i) {
$prop = new Property($i, $n++);
$this->properties[] = $prop;
$names[] = $prop->getName();
}
if (count($names) !== count(array_unique($names))) {
throw new \RuntimeException('property names are not unique');
}
if (isset($dom->namespaces) && isset($dom->namespaces->namespace)) {
foreach ($dom->namespaces->namespace as $i) {
$this->namespaces[(string) $i->prefix[0]] = (string) $i->uri[0];
}
}
}
示例2: doNode
public function doNode(\SimpleXMLElement $node)
{
$this->id = trim((string) $node['id']);
if ($this->id == '') {
throw new IocException("A bean without id has been found !");
}
$this->className = trim((string) $node['class']);
if ($this->className == '') {
throw new IocException("Bean ({$this->id}) must have a class attribute");
}
$this->scope = trim((string) $node['scope']);
if ($this->scope == '') {
$this->scope = self::SCOPE_SINGLETON;
}
foreach ($node->property as $property) {
$prop = new Property();
$prop->doNode($property);
$this->properties[] = $prop;
}
$this->initMethod = trim((string) $node['init-method']);
$lazyInit = trim((string) $node['lazy-init']);
if ($lazyInit == 'false') {
$this->lazyInit = false;
}
$this->exported = trim((string) $node['export']);
}
示例3: init
private function init()
{
$this->url = $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'];
include_once 'classes/Property.php';
$property = new Property();
if ($this->rrdtool = $property->get_property("path_rrdtool")) {
} else {
print $property->get_error();
exit;
}
if ($this->rrd_dir = $property->get_property("path_rrddir")) {
} else {
print $property->get_error();
exit;
}
if (!$this->rrdtool || $this->rrdtool == '') {
print "Could not find rrdtool";
exit;
}
if (!$this->rrd_dir || $this->rrd_dir == '') {
print "Could not find rrd_dir";
exit;
}
return;
}
示例4: addProperty
public function addProperty(Property $property)
{
if ($property->getVarName()) {
$this->properties[$property->getVarName()] = $property;
}
return $this;
}
示例5: prepareObjectAttributes
public function prepareObjectAttributes($record)
{
$property = array();
foreach ($record->metas as $meta) {
//
// NEED TO REFACTORED
//
$prop_attr['key_name'] = $meta->meta->key_name;
$prop_attr['value'] = $meta->meta_value;
$prop_attr['descr'] = $meta->meta->descr;
$prop_attr['id'] = $meta->id;
//
// ====
$prop = new Property();
$prop->setAttributes($prop_attr);
$property[] = $prop->getAttributes();
}
$objects = array();
foreach ($record->objects as $object) {
$objects[] = array('name' => $object->name, 'text_value' => $object->text_value, 'descr' => $object->descr, 'id' => $object->id);
}
$attr = $record->getAttributes();
$attr['type'] = $record->type->name;
$attr['property'] = $property;
$attr['objects'] = $objects;
return $attr;
}
示例6: test_destroying_should_cascade
public function test_destroying_should_cascade()
{
$Property = new Property(array('description' => 'This is a Property'));
$Picture = $Property->picture->create(array('title' => 'Front'));
$Property->destroy();
$this->assertFalse($this->Property->find('first', array('default' => false)));
$this->assertFalse($this->Picture->find('first', array('default' => false)));
}
示例7: testNoModifiers
public function testNoModifiers()
{
$node = new Property(0, array());
$this->assertTrue($node->isPublic());
$this->assertFalse($node->isProtected());
$this->assertFalse($node->isPrivate());
$this->assertFalse($node->isStatic());
}
示例8: testStaticImplicitlyPublic
public function testStaticImplicitlyPublic()
{
$node = new Property(Class_::MODIFIER_STATIC, array());
$this->assertTrue($node->isPublic());
$this->assertFalse($node->isProtected());
$this->assertFalse($node->isPrivate());
$this->assertTrue($node->isStatic());
}
示例9: test___construct_returnsSelf_ifNamesIsString
/**
* __construct() should set the names and message if $names is a string
*/
public function test___construct_returnsSelf_ifNamesIsString()
{
$name = 'foo';
$e = new Property($name);
$this->assertEquals([$name], $e->getNames());
$this->assertEquals("Property {$name} could not be found", $e->getMessage());
return;
}
示例10: set
/**
* Shorthand to create or update properties
*
* @return void
* @author Carlos Escribano <carlos@markhaus.com>
**/
public static function set($key, $value)
{
if (!($p = Doctrine::getTable('Property')->findOneBy('keey', $key))) {
$p = new Property();
$p->setKeey($key);
}
$p->setValue($value);
$p->save();
}
示例11: add
/**
* Adds a Property. If Property already exists an Exception will be thrown.
*
* @param Property $property
*
* @return $this
*
* @throws \Exception
*/
public function add(Property $property)
{
// Property already exists?
if (null !== $this->get($property->getName())) {
throw new \Exception("Property with name '{$property->getName()}' already exists");
}
$this->elements[] = $property;
return $this;
}
示例12: actionCreate
/**
* Creates a new Property model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Property();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->property_id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例13: add
/**
* @param Property $property
*/
public function add(Property $property)
{
$propertyName = $property->getName();
if (isset($this->properties[$propertyName])) {
$existantProperty = $this->properties[$propertyName];
$this->properties[$propertyName] = $existantProperty->merge($property);
} else {
$this->properties[$propertyName] = $property;
}
}
示例14: it_returns_value_read_with_property_accessor
/**
* @test
*/
function it_returns_value_read_with_property_accessor()
{
$property = 'property';
$data = array('some data');
$propertyValue = 'property value';
$this->accessor->expects($this->once())->method('getValue')->with($data, $property)->willReturn($propertyValue);
$filter = new Property($this->accessor);
$filter->setProperty($property);
$this->assertSame($propertyValue, $filter->filter($data));
}
示例15: __construct
public function __construct(Property $property, User $user, $action)
{
$this->user = $user;
$this->property = $property;
$this->name = $property->getName();
$this->datatype = $property->getDatatype();
$this->description = $property->getDescription();
$this->descr = $property->getDescr();
$this->action = $action;
$this->action_time = new \DateTime();
}