本文整理汇总了PHP中property_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP property_exists函数的具体用法?PHP property_exists怎么用?PHP property_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了property_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Database &$db, $model_name)
{
$this->db =& $db;
$this->model_name = $model_name;
$this->field_prefix = strtolower($model_name);
$this->table_name = property_exists($model_name, 'table_name') ? $model_name::$table_name : $this->tableNameFromEntity($model_name);
}
示例2: __set
public function __set($property, $value)
{
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
return $this;
}
示例3: getItem
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
$pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
$table = $this->getTable();
if ($pk > 0) {
// Attempt to load the row.
$return = $table->load($pk);
// Check for a table object error.
if ($return === false && $table->getError()) {
$this->setError($table->getError());
return false;
}
}
// Convert to the JObject before adding other data.
$properties = $table->getProperties(1);
$item = JArrayHelper::toObject($properties, 'JObject');
if (property_exists($item, 'params')) {
$registry = new JRegistry();
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (property_exists($item, 'order_params')) {
$registry = new JRegistry();
$registry->loadString($item->order_params);
$item->order_params = $registry->toArray();
}
return $item;
}
示例4: getLogout
/**
* Log the user out of the application.
*
* @return \Illuminate\Http\Response
*/
public function getLogout()
{
$user = \Auth::user()->name;
\Auth::logout();
\Session::flash('flash_message', $user . ': You have been logged out.');
return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
}
示例5: fromObject
/**
* @param object $object
* @return $this
* @throws UnexpectedValueException
*/
public function fromObject($object)
{
parent::fromObject($object);
if (property_exists($object, 'isRecurring')) {
$this->isRecurring = $object->isRecurring;
}
if (property_exists($object, 'locale')) {
$this->locale = $object->locale;
}
if (property_exists($object, 'paymentProductFilters')) {
if (!is_object($object->paymentProductFilters)) {
throw new UnexpectedValueException('value \'' . print_r($object->paymentProductFilters, true) . '\' is not an object');
}
$value = new PaymentProductFiltersHostedCheckout();
$this->paymentProductFilters = $value->fromObject($object->paymentProductFilters);
}
if (property_exists($object, 'returnUrl')) {
$this->returnUrl = $object->returnUrl;
}
if (property_exists($object, 'showResultPage')) {
$this->showResultPage = $object->showResultPage;
}
if (property_exists($object, 'tokens')) {
$this->tokens = $object->tokens;
}
if (property_exists($object, 'variant')) {
$this->variant = $object->variant;
}
return $this;
}
示例6: createEvent
public function createEvent(Request $request, $payload)
{
$newEvent = json_decode(urldecode($payload));
if (!property_exists($newEvent, 'alert')) {
return false;
}
$alert = $newEvent->alert;
$event = new RawEvent();
$event->setType('monitis');
$system = str_replace('http://', '', $alert->url);
$system = str_replace(' ', '', $system);
$event->setSystem($system);
if ($alert->alertType === self::STATUS_PROBLEM) {
$event->setStatus(Event::STATUS_FAILURE);
if (property_exists($alert, "errorString")) {
$event->setMessage($alert->errorString);
} else {
$event->setMessage('Monitis found an error for ' . $alert->name . '.');
}
} else {
$event->setStatus(Event::STATUS_SUCCESS);
$event->setMessage("");
}
$event->setIdentifier("monitis_" . $system . "_" . $alert->type);
$event->setUnique(false);
$event->setUrl('http://dashboard.monitis.com/');
if (property_exists($alert, 'stepDuration')) {
$event->setValue($alert->stepDuration);
}
return $event;
}
示例7: fromObject
/**
* @param object $object
* @return $this
* @throws UnexpectedValueException
*/
public function fromObject($object)
{
parent::fromObject($object);
if (property_exists($object, 'isRecurring')) {
$this->isRecurring = $object->isRecurring;
}
if (property_exists($object, 'paymentProduct809SpecificInput')) {
if (!is_object($object->paymentProduct809SpecificInput)) {
throw new UnexpectedValueException('value \'' . print_r($object->paymentProduct809SpecificInput, true) . '\' is not an object');
}
$value = new RedirectPaymentProduct809SpecificInput();
$this->paymentProduct809SpecificInput = $value->fromObject($object->paymentProduct809SpecificInput);
}
if (property_exists($object, 'paymentProduct816SpecificInput')) {
if (!is_object($object->paymentProduct816SpecificInput)) {
throw new UnexpectedValueException('value \'' . print_r($object->paymentProduct816SpecificInput, true) . '\' is not an object');
}
$value = new RedirectPaymentProduct816SpecificInput();
$this->paymentProduct816SpecificInput = $value->fromObject($object->paymentProduct816SpecificInput);
}
if (property_exists($object, 'paymentProduct882SpecificInput')) {
if (!is_object($object->paymentProduct882SpecificInput)) {
throw new UnexpectedValueException('value \'' . print_r($object->paymentProduct882SpecificInput, true) . '\' is not an object');
}
$value = new RedirectPaymentProduct882SpecificInput();
$this->paymentProduct882SpecificInput = $value->fromObject($object->paymentProduct882SpecificInput);
}
if (property_exists($object, 'returnUrl')) {
$this->returnUrl = $object->returnUrl;
}
return $this;
}
示例8: GetValue
/**
* Gets the value of an OGNL expression in the given context.
*
* @param $expression the OGNL expression to evaluate
* @param $context the context in which to evaluate the expression
*
* @return the value of the expression or null if the expression is invalid
*/
public static function GetValue($expression, $context)
{
if (!isset($expression) || !isset($context)) {
return null;
}
while (strlen($expression) > 0) {
$matches = array();
if (preg_match(self::$OGNL_TOKEN_REGEX, $expression, $matches)) {
$token = array_shift($matches);
$expression = substr($expression, strlen($token));
// Remove empty matches.
$matches = array_filter($matches, 'strlen');
foreach ($matches as $field) {
if (is_object($context) && property_exists($context, $field)) {
$context = $context->{$field};
} else {
if (is_array($context) && array_key_exists($field, $context)) {
$context = $context[$field];
} else {
// Field doesn't evaluate in the context.
return null;
}
}
}
} else {
// Invalid expression.
return null;
}
}
return $context;
}
示例9: __set
/**
* @param string $property
* @param mixed $value
*/
public function __set($property, $value)
{
if (!property_exists($this, $property)) {
//$this->unknownProperties[$property] = $value;
$this->{$property} = $value;
}
}
示例10: escape
public static function escape($value)
{
if (is_array($value)) {
foreach ($value as &$ele) {
self::escape($ele);
}
unset($ele);
return $value;
}
if (is_object($value)) {
$class_vars = get_class_vars(get_class($value));
foreach ($class_vars as $name => $var) {
if (!property_exists($value, $name) or !isset($value->{$name})) {
continue;
}
$value->{$name} = self::escape($value->{$name});
}
return $value;
}
$value = str_replace(array('javascript:'), '', $value);
/*
$value = str_replace(';', ";", $value);
$value = str_replace('\\', "\", $value);
$value = str_replace('/', "/", $value);
$value = str_replace('=', "=", $value);
*/
$value = htmlentities($value, ENT_QUOTES, 'UTF-8');
return $value;
}
示例11: get
/**
* Function to get the value of a given property
* @param <String> $propertyName
* @return <Object>
* @throws Exception
*/
public function get($propertyName)
{
if (property_exists($this, $propertyName)) {
return $this->{$propertyName};
}
return null;
}
示例12: extractProperty
protected static function extractProperty($element, $property)
{
if (!is_a($element, get_called_class()) || !property_exists($element, $property)) {
throw new \InvalidArgumentException('property ' . $property . ' does not exists in class: ' . get_called_class());
}
return $element->{$property};
}
示例13: getStatusText
/**
* Get status text.
*
* @return string
*/
public function getStatusText()
{
if (property_exists($this, 'statusText')) {
return $this->{'statusText'};
}
return null;
}
示例14: __get
public function __get($prop)
{
if (property_exists($this, $prop)) {
return $this->{$prop};
}
throw new Exception\UpgradeException(sprintf('Property "%s" does not exist for the class "%s".', $prop, get_class($this)));
}
示例15: updateAttribute
/**
* Update object attribute
*
* @param string $attribute
* @param string|boolean|integer $value
*
* @return object
*/
private function updateAttribute($attribute, $value)
{
if (property_exists($this, $attribute)) {
$this->{$attribute} = $value;
}
return $this;
}