本文整理汇总了PHP中object::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP object::getAttribute方法的具体用法?PHP object::getAttribute怎么用?PHP object::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform
/**
* Processes the request.
*
* @param object $page CRM_Core_Form the current form-page
* @param string $actionName Current action name, as one Action object can serve multiple actions
*
* @return void
* @access public
*/
function perform(&$page, $actionName)
{
$pageName = $page->getAttribute('id');
// If the original action was 'display' and we have values in container then we load them
// BTW, if the page was invalid, we should later call validate() to get the errors
list(, $oldName) = $page->controller->getActionName();
if ('display' == $oldName) {
// If the controller is "modal" we should not allow direct access to a page
// unless all previous pages are valid (see also bug #2323)
if ($page->controller->isModal() && !$page->controller->isValid($page->getAttribute('id'))) {
$target =& $page->controller->getPage($page->controller->findInvalid());
return $target->handle('jump');
}
$data =& $page->controller->container();
if (!empty($data['values'][$pageName])) {
$page->loadValues($data['values'][$pageName]);
$validate = FALSE === $data['valid'][$pageName];
}
}
// set "common" defaults and constants
$page->controller->applyDefaults($pageName);
$page->isFormBuilt() or $page->buildForm();
// if we had errors we should show them again
if (isset($validate) && $validate) {
$page->validate();
}
//will this work generally as TRUE (i.e., return output)
//was default, i.e., FALSE
return $this->renderForm($page);
}
示例2: checkPdoDriver
/**
* Check the PDO driver
*
* @param string $name
* @param bool $exception
*
* @return bool
*/
protected function checkPdoDriver($name = false, $exception = false)
{
if ($name === false) {
$name = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
}
if (array_search($name, $this->pdo->getAvailableDrivers()) === false) {
if ($exception) {
throw new PDOException("PDO does not support any driver.");
}
return false;
}
return true;
}
示例3: reWriteURL
/**
* reWriteURL - can using the config option 'url_rewrite'
* format "from:to,from:to"
* only handle left rewrite.
* so
* "/images:/myroot/images"
* would change
* /images/xyz.gif to /myroot/images/xyz.gif
* /images/stylesheet/imagestyles.css to /myroot/images/stylesheet/imagestyles.css
* note /imagestyles did not get altered.
* will only work on strings (forget about doing /images/{someimage}
*
*
* @param string attribute to rewrite
* @return none
* @access public
*/
function reWriteURL($which)
{
global $_HTML_TEMPLATE_FLEXY;
if (!is_string($original = $this->element->getAttribute($which))) {
return;
}
if ($original == '') {
return;
}
if (empty($_HTML_TEMPLATE_FLEXY['currentOptions']['url_rewrite'])) {
return;
}
$bits = explode(",", $_HTML_TEMPLATE_FLEXY['currentOptions']['url_rewrite']);
$new = $original;
foreach ($bits as $bit) {
if (!strlen(trim($bit))) {
continue;
}
$parts = explode(':', $bit);
if (!isset($parts[1])) {
return HTML_Template_Flexy::staticRaiseError('HTML_Template_Flexy: url_rewrite syntax incorrect' . print_r(array($bits, $bits), true), null, HTML_TEMPLATE_FLEXY_ERROR_DIE);
}
$new = preg_replace('#^' . $parts[0] . '#', $parts[1], $new);
}
if ($original == $new) {
return;
}
$this->element->ucAttributes[$which] = '"' . $new . '"';
}
示例4: __construct
/**
* Construct
*
* @param string $type the crud type
* @param object $db the sql object
*/
public function __construct($type, $db)
{
$this->db = $db;
//get a new factory
$factory = new QueryFactory($db->getAttribute(PDO::ATTR_DRIVER_NAME));
$this->query = call_user_func([$factory, 'new' . ucfirst($type)]);
}
示例5: onQuickFormEvent
/**
* Called by HTML_QuickForm whenever form event is made on this element
*
* @param string $event Name of event
* @param mixed $arg event arguments
* @param object $caller calling object
* @since 1.0
* @access public
* @return void
*/
function onQuickFormEvent($event, $arg, &$caller)
{
switch ($event) {
case 'createElement':
$this->_formid = $caller->getAttribute('id');
break;
}
return parent::onQuickFormEvent($event, $arg, $caller);
}
示例6: perform
/**
* Processes the request.
*
* @param object $page CRM_Core_Form the current form-page
* @param string $actionName Current action name, as one Action object can serve multiple actions
*
* @return void
* @access public
*/
function perform(&$page, $actionName)
{
// save the form values and validation status to the session
$page->isFormBuilt() or $page->buildForm();
$pageName = $page->getAttribute('name');
$data =& $page->controller->container();
$data['values'][$pageName] = $page->exportValues();
return $page->handle('display');
}
示例7: normalize
/**
* Normalizes an object into a set of arrays/scalars
*
* @param object $object object to normalize
* @param string $format format the normalization result will be encoded as
* @param array $context Context options for the normalizer
*
* @return array|scalar
*/
public function normalize($object, $format = null, array $context = [])
{
$attributeCode = strtolower($context['attributeCodeMapping']->getTarget($object->getAttribute()->getCode()));
if ($this->isValueNormalizable($object, $context['identifier'], $attributeCode, $context['scopeCode'], $context['localeCode'], $context['onlyLocalized'])) {
return $this->getNormalizedValue($object, $attributeCode, $context['magentoAttributes'], $context['magentoAttributesOptions'], $context['attributeCodeMapping'], $context['currencyCode']);
} else {
return null;
}
}
示例8: validate
/**
* @param object $attributeOption
* @param Constraint $constraint
*/
public function validate($attributeOption, Constraint $constraint)
{
/** @var AttributeOptionInterface */
if ($attributeOption instanceof AttributeOptionInterface) {
$attribute = $attributeOption->getAttribute();
$authorizedTypes = [AttributeTypes::OPTION_SIMPLE_SELECT, AttributeTypes::OPTION_MULTI_SELECT];
if (!in_array($attribute->getAttributeType(), $authorizedTypes)) {
$this->addInvalidAttributeViolation($constraint, $attributeOption);
}
}
}
示例9: showServerInfo
/**
* Method to display details about the target server's database connected
*
* @access public static
* @param void
* @return void
*/
public static function showServerInfo()
{
try {
if (self::$instance instanceof \PDO) {
$driver = self::getDriver();
$info = $driver == 'sqlite' || $driver == 'mssql' ? 'not available' : self::$instance->getAttribute(\PDO::ATTR_SERVER_INFO);
echo '<h7>Server Information - ', is_array($info) ? implode(', ', $info) : $info, '</h7>';
} else {
throw new \PDOException(self::$exception['no-instance']);
}
} catch (\PDOException $e) {
self::stackTrace($e);
}
}
示例10: __construct
/**
* 构造方法
*
* 用于初始化运行环境,或对基本变量进行赋值
*
* @access public
*
* @param array $params 数据库连接参数,如主机名,数据库用户名,密码等
*
* @return boolean
*/
public function __construct($params = array())
{
//参数分析
if (!$params['dsn']) {
Controller::halt('database config params error!', 'Normal');
}
$params += $this->_defaultConfig;
//数据库连接
try {
$flags = array(PDO::ATTR_PERSISTENT => $params['persistency'], PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
//实例化数据库连接
$this->_dbLink = new PDO($params['dsn'], $params['username'], $params['password'], $flags);
} catch (PDOException $exception) {
//当调试模式关闭时
if (DOIT_DEBUG === false) {
//记录错误日志
Log::write("Database server connect error! Error Code:{$exception->getCode()} Error Message:{$exception->getMessage()}", 'Warning');
//提示错误信息
Controller::showMsg('数据库连接失败!');
}
//抛出异常信息
throw new DoitException('Database connect error!<br/>' . $exception->getMessage(), $exception->getCode());
}
//设置数据编码
$driverName = $this->_dbLink->getAttribute(PDO::ATTR_DRIVER_NAME);
switch ($driverName) {
case 'mysql':
case 'pgsql':
$this->_dbLink->exec("SET NAMES {$params['charset']}");
break;
case 'sqlsrv':
$this->_dbLink->setAttribute(PDO::SQLSRV_ATTR_ENCODING, $params['charset']);
break;
}
return true;
}
示例11: validate
/**
* @param object $productValue
* @param Constraint $constraint
*/
public function validate($productValue, Constraint $constraint)
{
/** @var ProductValueInterface */
if ($productValue instanceof ProductValueInterface) {
$isLocalizable = $productValue->getAttribute()->isLocalizable();
$localeCode = $productValue->getLocale();
if ($isLocalizable && null === $localeCode) {
$this->addExpectedLocaleViolation($constraint, $productValue);
} elseif ($isLocalizable && !$this->doesLocaleExist($localeCode)) {
$this->addUnexistingLocaleViolation($constraint, $productValue, $localeCode);
} elseif (!$isLocalizable && null !== $localeCode) {
$this->addUnexpectedLocaleViolation($constraint, $productValue);
}
}
}
示例12: perform
/**
* Processes the request.
*
* @param object $page CRM_Core_Form the current form-page
* @param string $actionName Current action name, as one Action object can serve multiple actions
*
* @return void
* @access public
*/
function perform(&$page, $actionName)
{
$page->isFormBuilt() or $page->buildForm();
$pageName = $page->getAttribute('name');
$data =& $page->controller->container();
$data['values'][$pageName] = $page->exportValues();
$data['valid'][$pageName] = $page->validate();
// Modal form and page is invalid: don't go further
if ($page->controller->isModal() && !$data['valid'][$pageName]) {
return $page->handle('display');
}
// the page is valid, process it before we jump to the next state
$page->mainProcess();
return $page->handle('display');
}
示例13: validate
/**
* @param object $productValue
* @param Constraint $constraint
*/
public function validate($productValue, Constraint $constraint)
{
/** @var ProductValueInterface */
if ($productValue instanceof ProductValueInterface) {
$isScopable = $productValue->getAttribute()->isScopable();
$channelCode = $productValue->getScope();
if ($isScopable && null === $channelCode) {
$this->addExpectedScopeViolation($constraint, $productValue);
} elseif ($isScopable && !$this->doesChannelExist($channelCode)) {
$this->addUnexistingScopeViolation($constraint, $productValue, $channelCode);
} elseif (!$isScopable && null !== $channelCode) {
$this->addUnexpectedScopeViolation($constraint, $productValue);
}
}
}
示例14: perform
/**
* Processes the request.
* this is basically a self submit, so validate the page
* and if success, call post process
* when done processing pop to user context
*
* @param object $page CRM_Core_Form the current form-page
* @param string $actionName Current action name, as one Action object can serve multiple actions
*
* @return void
* @access public
*/
function perform(&$page, $actionName)
{
$page->isFormBuilt() or $page->buildForm();
$pageName = $page->getAttribute('name');
$data =& $page->controller->container();
$data['values'][$pageName] = $page->exportValues();
$data['valid'][$pageName] = $page->validate();
// Modal form and page is invalid: don't go further
if ($page->controller->isModal() && !$data['valid'][$pageName]) {
return $page->handle('display');
}
// the page is valid, process it before we jump to the next state
$page->mainProcess();
// ok so we are done now, pop stack and jump back to where we came from
// we do not reset the context because u can achieve that affect using next
// use Done when u want to pop back to the same context without a reset
$this->popUserContext();
}
示例15: perform
/**
* Processes the request.
*
* @param object $page CRM_Core_Form the current form-page
* @param string $actionName Current action name, as one Action object can serve multiple actions
*
* @return void
* @access public
*/
function perform(&$page, $actionName)
{
// check whether the page is valid before trying to go to it
if ($page->controller->isModal()) {
// we check whether *all* pages up to current are valid
// if there is an invalid page we go to it, instead of the
// requested one
$pageName = $page->getAttribute('id');
if (!$page->controller->isValid($pageName)) {
$pageName = $page->controller->findInvalid();
}
$current =& $page->controller->getPage($pageName);
} else {
$current =& $page;
}
// generate the URL for the page 'display' event and redirect to it
$action = $current->getAttribute('action');
$url = $action . (FALSE === strpos($action, '?') ? '?' : '&') . $current->getButtonName('display') . '=true' . '&qfKey=' . $page->get('qfKey');
CRM_Utils_System::redirect($url);
}