本文整理汇总了PHP中Utility::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Utility::getAttributes方法的具体用法?PHP Utility::getAttributes怎么用?PHP Utility::getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utility
的用法示例。
在下文中一共展示了Utility::getAttributes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FromStdObject_Base
/**
*
* @param string $type
* @param StdObject $stdObject
* @return ssrs Object
*/
protected function FromStdObject_Base($type, $stdObject)
{
$object;
if ($type != 'self') {
$class = new ReflectionClass($type);
$object = $class->newInstance();
} else {
$type = get_class($this);
$class = new ReflectionClass($type);
$object = $this;
}
$properties = $class->getProperties();
foreach ($properties as $rawProperty) {
$propertyName = $rawProperty->name;
$property = new ReflectionProperty($object, $propertyName);
$attributes = Utility::getAttributes($property);
$value = null;
switch (SSRSTypeFactory::GetType($attributes['type'])) {
case 'basic':
$value = self::EnumerateBasicObject($stdObject, $propertyName, $attributes);
break;
case 'ssrs':
$value = self::EnumerateSSRSObject($stdObject, $propertyName, $attributes);
break;
case 'unknown':
throw new PReportException("", "Exception: Unknown_Type:" . $attributes['type']);
break;
}
$property->setValue($object, $value);
}
$object->Initialize();
return $object;
}
示例2: GetDevInfoXML_Base
protected function GetDevInfoXML_Base($object)
{
$retXML = '<DeviceInfo>';
$className = get_class($object);
$class = new ReflectionClass($className);
$properties = $class->getProperties();
foreach ($properties as $rawProperty) {
$propertyName = $rawProperty->name;
$property = new ReflectionProperty($object, $propertyName);
$attributes = Utility::getAttributes($property);
if (array_key_exists('xml', $attributes) && null != ($value = $property->getValue($object))) {
$retXML = $retXML . '<' . $attributes['xml'] . '>' . $value . '</' . $attributes['xml'] . '>';
}
}
$retXML = $retXML . '</DeviceInfo>';
return $retXML;
}
示例3: displayEntityData
/**
* Fucntion to display result of query.
*/
protected function displayEntityData()
{
$this->_query = str_replace("\\'", "'", $this->_query);
$queryToRun = $this->_query;
$pagingSection = '<table border="0" align="center" CELLSPACING="15">';
$nextSkip = null;
$canPage = false;
if ($this->_enablePaging && (isset($_REQUEST['pagingAllowed']) && $_REQUEST['pagingAllowed'] == 'true')) {
$canPage = true;
$skip = 0;
if (isset($_REQUEST['skip'])) {
$skip = $_REQUEST['skip'];
}
$parts = parse_url($queryToRun);
if (isset($parts['query'])) {
$queryToRun .= '&$top=' . $this->_pageSize . '&$skip=' . $skip;
} else {
$queryToRun .= '?$top=' . $this->_pageSize . '&$skip=' . $skip;
}
$nextSkip = $skip + $this->_pageSize;
if ($nextSkip != $this->_pageSize) {
$prev = $skip - $this->_pageSize;
$pagingSection .= "<td><a href=\"" . $this->_containerScriptName . "?query=" . $this->_query . "&serviceUri=" . $this->_uri . '&skip=' . $prev . '&pagingAllowed=true' . "\">Prev</a></td>";
}
}
$response = $this->_proxyObject->Execute($queryToRun);
$resultSet = $response->Result;
echo "<br><br><table style=\"border: thin solid #C0C0C0;\" border=\"1\">";
if (count($resultSet) > 0) {
$propertyArray = WCFDataServicesEntity::getProperties($resultSet[0]);
$this->displayHeader($propertyArray, $resultSet[0]);
foreach ($resultSet as $result) {
echo "<tr style=\"font-family: Calibri; " . "background-color: #CCFFFF\">";
WCFDataServicesEntity::getDetailButtonText($result);
foreach ($propertyArray as $property) {
$prop = new ReflectionProperty($result, $property);
$propertyAttributes = Utility::getAttributes($prop);
if ($propertyAttributes['Type'] == 'NavigationProperty') {
$pagingAllowed = 'pagingAllowed=true';
$relationShip = $this->_proxyObject->GetRelationShip($propertyAttributes["Relationship"], $propertyAttributes["ToRole"]);
if ($relationShip != '*') {
$pagingAllowed = 'pagingAllowed=false';
}
$skip = null;
if (isset($_REQUEST['skip'])) {
$skip = '&skip=' . $_REQUEST['skip'];
}
$pagingAllowedWhileAttaching = null;
if (isset($_GET['pagingAllowed'])) {
$pagingAllowedWhileAttaching = '&pagingAllowed=' . $_GET['pagingAllowed'];
}
echo "<td>";
$relatedLinks = $result->getRelatedLinks();
$finalQuery = $relatedLinks[$property];
$finalQuery = str_replace("%20", '', $finalQuery);
echo "<a href=\"" . $this->_containerScriptName . "?query=" . $finalQuery . '&' . $pagingAllowed . $skip . "&serviceUri=" . $this->_uri . "\">" . $property . "</a>";
echo "<br><a href=\"" . $this->_containerScriptName . "?query=" . $this->_query . $pagingAllowedWhileAttaching . $skip . "&serviceUri=" . $this->_uri . "&Type=" . $property . "&AttachTo=" . $finalQuery . "\"> Add Link </a>";
echo "</td>";
} else {
$propertyAttributes = Utility::getAttributes($prop);
if (isset($propertyAttributes['EdmType']) && ($index = strpos($propertyAttributes['EdmType'], 'Edm.')) !== 0) {
$value = $prop->getValue($result);
$type = ClientType::Create(get_class($value));
$nonEpmProperties = $type->getRawNonEPMProperties(true);
echo '<td><table style="border: thin solid #C0C0C0;" border="1">';
foreach ($nonEpmProperties as $nonEpmProperty) {
$propertyName = $nonEpmProperty->getName();
$refProperty = new ReflectionProperty($value, $propertyName);
$propertyValue = $refProperty->getValue($value);
echo '<tr><td>';
echo $propertyValue;
echo '</td></tr>';
}
echo '</table></td>';
} else {
if (Utility::ContainAttribute($prop->getDocComment(), 'Binary')) {
// TODO: Display image in the cell
echo "<td>Image</td>";
} else {
$value = $prop->getValue($result);
if ($value == '') {
$value = 'null';
}
echo "<td>" . $value . "</td>";
}
}
}
}
echo "</tr>";
}
if ($canPage) {
$pagingSection .= "<td><a href=\"" . $this->_containerScriptName . "?query=" . $this->_query . "&serviceUri=" . $this->_uri . '&skip=' . $nextSkip . '&pagingAllowed=true' . "\">Next</a></td><tr/></table>";
}
}
if ($canPage) {
echo $pagingSection;
}
//.........这里部分代码省略.........
示例4: ClientType
/**
*
* @param <string> $type
* Constructor
*/
public function ClientType($type)
{
$this->_attributes = array();
$this->_properties = array();
$this->_navigationProperties = array();
$this->_sortedEPMProperties = array();
$targetPathToCount = array();
try {
$rClass = new ReflectionClass($type);
$this->_hasEPM = false;
$this->_attributes = Utility::getAttributes($rClass);
$sourceProperty = null;
if (array_key_exists('FC_SourcePath', $this->_attributes)) {
$this->_hasEPM = true;
$sourceProperty = $this->_attributes['FC_SourcePath'];
}
$properties = $rClass->getProperties();
foreach ($properties as $property) {
if ($property->isPublic()) {
$attributes = Utility::getAttributes($property);
$propertyName = $property->name;
if ($sourceProperty != null && $sourceProperty == $propertyName) {
ValidateEPMAttributes($this->_attributes, $attributes, $sourceProperty, false);
}
if (isset($attributes['Type']) && $attributes['Type'] == 'EntityProperty') {
$propertyObj = new Property($propertyName, $attributes);
$this->_properties[$propertyName] = $propertyObj;
if ($propertyObj->hasEPM($syn)) {
$this->_hasEPM = true;
$attrs = $propertyObj->getAttributes();
if ($syn) {
$targetPath = SyndicationItemProperty::GetSyndicationItemPathNoNS($attrs['FC_TargetPath']);
} else {
$targetPath = $attrs['FC_TargetPathNS'];
if (isset($attrs['NodeAttribute'])) {
$targetPath .= '/@' . $attrs['NodeAttribute'];
}
}
$targetPathToCount[$targetPath] = substr_count($targetPath, "/");
}
} else {
if (isset($attributes['Type']) && $attributes['Type'] == 'NavigationProperty') {
$this->_navigationProperties[$propertyName] = new Property($propertyName, $attributes);
}
}
}
}
asort($targetPathToCount);
$properties = $this->_properties;
foreach ($targetPathToCount as $key => $value) {
foreach ($properties as $property) {
$syn = false;
$targetPath = null;
if ($property->hasEPM($syn)) {
$attrs = $property->getAttributes();
if ($syn) {
$targetPath = SyndicationItemProperty::GetSyndicationItemPathNoNS($attrs['FC_TargetPath']);
} else {
$targetPath = $attrs['FC_TargetPathNS'];
if (isset($attrs['NodeAttribute'])) {
$targetPath .= '/@' . $attrs['NodeAttribute'];
}
}
if ($key == $targetPath) {
$this->_sortedEPMProperties[] = $property;
}
}
}
}
} catch (ReflectionException $exception) {
throw new InvalidOperation('ReflectionException in ClientType constructor');
}
}
示例5: GetBindingHttpMethod
/**
* To get HTTP Verb to be used for a binding based on the state of the
* RelatedEnd object holding the relationship.
*
* @param RelatedEnd $binding
* @return HttpVerb
*/
public function GetBindingHttpMethod($binding)
{
$property = new ReflectionProperty($binding->GetSourceResource(), $binding->GetSourceProperty());
$attributes = Utility::getAttributes($property);
$relationShip = $this->_context->GetRelationShip($attributes["Relationship"], $attributes["ToRole"]);
//SetLink
if ($relationShip == '0..1' || $relationShip == '1') {
//SetLink with target null
if ($binding->GetTargetResource() == null) {
return HttpVerb::DELETE;
}
return HttpVerb::PUT;
}
//DeleteLink
if (EntityStates::Deleted == $binding->State) {
return HttpVerb::DELETE;
}
//AddLink
return HttpVerb::POST;
}
示例6: ValidateDeleteLink
/**
* To check whether deleteing a link between $relatedEnd::SourceResource and
* $relatedEnd::TargetResource is valid based their current states.
* [Note: Do not call this function from your application, it is used internally]
*
* @param $relatedEnd The RelatedEnd
* @throws InvalidOperation
*/
protected function ValidateDeleteLink($relatedEnd)
{
$sourceObject = $relatedEnd->GetSourceResource();
$sourceProperty = $relatedEnd->GetSourceProperty();
$targetObject = $relatedEnd->GetTargetResource();
$sourceResourceBox = null;
if (!$this->ObjectToResource->TryGetValue($sourceObject, $sourceResourceBox)) {
throw new InvalidOperation(Resource::EntityNotContained, Resource::EntityNotContained_Details);
}
$targetResourceBox = null;
if (!$this->ObjectToResource->TryGetValue($targetObject, $targetResourceBox)) {
throw new InvalidOperation(Resource::EntityNotContained, Resource::EntityNotContained_Details);
}
try {
$property = new ReflectionProperty($sourceObject, $sourceProperty);
} catch (ReflectionException $ex) {
throw new InvalidOperation(Resource::NoPropertyForTargetObject, sprintf(Resource::NoPropertyForTargetObject_Details, $sourceProperty));
}
$attributes = Utility::getAttributes($property);
if (!isset($attributes["Relationship"]) || !isset($attributes["ToRole"]) || !isset($attributes["FromRole"]) || !isset($attributes["Type"])) {
throw new InvalidOperation(Resource::NoRelationBetweenObjects, null);
}
if ($attributes["Type"] != "NavigationProperty") {
throw new InvalidOperation(Resource::RelationNotRefOrCollection, sprintf(Resource::RelationNotRefOrCollection_Details, $sourceProperty));
}
$relationShip = $this->GetRelationShip($attributes["Relationship"], $attributes["ToRole"]);
if ($relationShip != '*') {
throw new InvalidOperation(sprintf(Resource::AddLinkCollectionOnly, $sourceProperty), Resource::AddLinkCollectionOnly_Details);
}
}