本文整理汇总了PHP中kXml::getAttributesAsArray方法的典型用法代码示例。如果您正苦于以下问题:PHP kXml::getAttributesAsArray方法的具体用法?PHP kXml::getAttributesAsArray怎么用?PHP kXml::getAttributesAsArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kXml
的用法示例。
在下文中一共展示了kXml::getAttributesAsArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromSourceXML
/**
* sets the KalturaDataGeneratorConfigFile object from simpleXMLElement (the source xml of the data)
* @param SimpleXMLElement $simpleXMLElement
*
* @return None, sets the given object
*/
public function fromSourceXML(SimpleXMLElement $simpleXMLElement)
{
//For each test file
foreach ($simpleXMLElement->TestDataFile as $xmlTestDataFile) {
//Create new test file obejct
$testDataFile = new KalturaUnitTestDataFile();
//For each UnitTest data (in this file)
foreach ($xmlTestDataFile->UnitTestsData->UnitTestData as $xmlUnitTestData) {
//Create new unit test data
$unitTestData = new KalturaUnitTestData();
//For each input create the needed Kaltura object identifier
foreach ($xmlUnitTestData->Inputs->Input as $input) {
$additionalData = kXml::getAttributesAsArray($input);
$unitTestDataObjectIdentifier = new KalturaUnitTestDataObject((string) $input["type"], $additionalData);
$unitTestData->input[] = $unitTestDataObjectIdentifier;
}
//And for each output reference create the needed kaltura object identifier
foreach ($xmlUnitTestData->OutputReferences->OutputReference as $outputReference) {
$additionalData = kXml::getAttributesAsArray($outputReference);
$unitTestDataObjectIdentifier = new KalturaUnitTestDataObject((string) $outputReference["type"], $additionalData);
$unitTestData->outputReference[] = $unitTestDataObjectIdentifier;
}
//Add the new unit test into the tests array.
$testDataFile->unitTestsData[] = $unitTestData;
}
$testDataFile->fileName = trim((string) $xmlTestDataFile->FileName);
$this->testFiles[] = $testDataFile;
}
}
示例2: fromXml
/**
*
* Generates a new testCaseFailure object from a given simpleXmlElement (failure file xml)
* @param SimpleXMlElement $unitTestFailureXml
*/
public function fromXml(SimpleXMlElement $unitTestFailureXml)
{
//Sets the inputs as key => value byt the xml attributes
foreach ($unitTestFailureXml->Inputs->Input as $inputXml) {
$this->testCaseInput[] = kXml::getAttributesAsArray($inputXml);
}
foreach ($unitTestFailureXml->Failures->Failure as $failureXml) {
$this->testCaseFailures[] = KalturaFailure::generateFromXml($failureXml);
}
}
示例3: fromSourceXML
/**
* sets the KalturaTestDataSourceFile object from simpleXMLElement (the source xml of the data)
* @param SimpleXMLElement $simpleXMLElement
*
* @return None, sets the given object
*/
public function fromSourceXML(SimpleXMLElement $simpleXMLElement)
{
//For each test file
foreach ($simpleXMLElement->TestCaseData as $xmlTestDataFile) {
//Create new test file obejct
$testDataFile = new KalturaTestCaseDataFile(trim((string) $xmlTestDataFile["testCaseName"]));
foreach ($xmlTestDataFile->TestProcedureData as $xmlTestProcedureData) {
$testProcedureData = new KalturaTestProcedureData();
if (isset($xmlTestProcedureData["testProcedureName"])) {
$testProcedureData->setProcedureName($xmlTestProcedureData["testProcedureName"]);
}
//TODO: maybe get this from procedure / test case instance config
$testCaseNum = 0;
//For each test data (in this file)
foreach ($xmlTestProcedureData->TestCaseData as $xmlTestCaseData) {
$testCaseName = $testProcedureData->getProcedureName() . " with data set #{$testCaseNum}";
$testCaseNum++;
//User defined test cases name
if (isset($xmlTestCaseData["testCaseInstanceName"])) {
$testCaseName = $xmlTestCaseData["testCaseInstanceName"];
$testCaseNum--;
}
//Create new unit test data
$testCaseData = new KalturaTestCaseInstanceData($testCaseName);
//For each input create the needed Kaltura object identifier
foreach ($xmlTestCaseData->Input as $input) {
$additionalData = kXml::getAttributesAsArray($input);
$testInputDataObjectIdentifier = new KalturaTestDataObject((string) $input["type"], $additionalData);
$testCaseData->addInput($testInputDataObjectIdentifier);
}
//And for each output reference create the needed kaltura object identifier
foreach ($xmlTestCaseData->OutputReference as $outputReference) {
$additionalData = kXml::getAttributesAsArray($outputReference);
$testOutputReferenceDataObjectIdentifier = new KalturaTestDataObject((string) $outputReference["type"], $additionalData);
$testCaseData->addOutputReference($testOutputReferenceDataObjectIdentifier);
}
//Add the new test case data into the test procedure data.
$testProcedureData->addTestCaseInstance($testCaseData);
}
//Add the new procedure test data into the test file.
$testDataFile->addTestProcedureData($testProcedureData);
}
$this->testFiles[] = $testDataFile;
}
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:51,代码来源:KalturaTestDataSourceFile.php
示例4: fromXml
/**
*
* Generates a new testCaseFailure object from a given simpleXmlElement (failure file xml)
* @param SimpleXMlElement $unitTestFailureXml
*/
public function fromXml(SimpleXMlElement $testCaseInstanceFailureXml)
{
$this->testCaseInstanceName = (string) $testCaseInstanceFailureXml["testCaseInstanceName"];
//Sets the inputs as key => value byt the xml attributes
foreach ($testCaseInstanceFailureXml->Inputs->Input as $inputXml) {
$this->testCaseInput[] = kXml::getAttributesAsArray($inputXml);
}
foreach ($testCaseInstanceFailureXml->Failures->Failure as $failureXml) {
$this->failures[] = KalturaFailure::generateFromXml($failureXml);
}
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:16,代码来源:KalturaTestCaseInstanceFailure.php
示例5: fromXml
/**
* Gets a xml based data and returns a new unit test data object with those values
* @param SimpleXMLElement $xml
* @return KalturaTestDataObject the new unit test data object with the given data
*/
public function fromXml($xml)
{
$this->type = (string) $xml['type'];
$this->dataObject = KalturaTestDataObject::getObjectInstance($this->type);
$this->additionalData = kXml::getAttributesAsArray($xml);
if (class_exists($this->type)) {
foreach ($xml->children() as $child) {
$childKey = $child->getName();
//if dbValue exists
if (isset($child["dbValue"])) {
$commentValue = $child['dbValue'];
$this->comments[$childKey] = "{$commentValue}";
}
if (strlen($child) != 0) {
$childValue = (string) $child;
} else {
$childValue = null;
}
$childValueType = (string) $child["type"];
try {
//TODO: Handle fields which are arrays (currently handled hard coded)
if ($childKey == "array" || $childKey == "Array") {
$arrayValue = array();
$arrayKey = $childValue;
foreach ($child->children() as $singleElementKey => $singleElementValue) {
if (isset($singleElementValue["key"])) {
$key = (string) $singleElementValue["key"];
$arrayValue[$key] = (string) $singleElementValue;
}
$arrayKey = $singleElementKey;
//if dbValue exists
if (isset($singleElementValue["dbValue"])) {
$singleElementComment = $singleElementValue["dbValue"];
$this->comments[$singleElementKey][$key] = "{$singleElementComment}";
}
}
if (count($arrayValue) > 0) {
KalturaTestDataObject::setPropertyValue($this->dataObject, $arrayKey, $arrayValue, $childValueType);
} else {
KalturaTestDataObject::setPropertyValue($this->dataObject, $arrayKey, $arrayValue, 'Array');
}
} else {
KalturaTestDataObject::setPropertyValue($this->dataObject, $childKey, $childValue, $childValueType);
}
} catch (Exception $e) {
throw new Exception("Error can't set by name: " . $childValue . $e, $e->getCode());
}
}
} else {
//Handle no classes objects like string and int
$child = $xml->children();
if ($this->type == 'fileHandler') {
KalturaTestDataObject::setPropertyValue($this->value, "value", file_get_contents(getcwd() . (string) $xml['key']), null);
} else {
if (count($child) == 0) {
KalturaTestDataObject::setPropertyValue($this->value, "value", trim($xml), null);
} else {
KalturaTestDataObject::setPropertyValue($this->value, "value", $child->saveXML(), null);
}
}
}
}
示例6: fromXml
/**
* Gets a xml based data and returns a new unit test data object with those values
* @param SimpleXMLElement $xml
* @return KalturaUnitTestDataObject the new unit test data object with the given data
*/
public static function fromXml($xml)
{
$objectInstace = new KalturaUnitTestDataObject();
$objectInstace->type = (string) $xml['type'];
$objectInstace->dataObject = KalturaUnitTestDataObject::getObjectInstance($objectInstace->type);
$objectInstace->additionalData = kXml::getAttributesAsArray($xml);
if (class_exists($objectInstace->type)) {
foreach ($xml->children() as $child) {
$childKey = $child->getName();
//if dbValue exists
if (isset($child["dbValue"])) {
$objectInstace->comments[$childKey] = (string) $child["dbValue"];
}
if (strlen($child) != 0) {
$childValue = (string) $child;
} else {
$childValue = null;
}
$childValueType = (string) $child["type"];
try {
//TODO: Handle fields which are arrays (currently handled hard coded)
if ($childKey == "array" || $childKey == "Array") {
$arrayValue = array();
foreach ($child->children() as $singleElementKey => $singleElementValue) {
$key = (string) $singleElementValue["key"];
$arrayValue[$key] = (string) $singleElementValue;
$arrayKey = $singleElementKey;
//if dbValue exists
if (isset($singleElementValue["dbValue"])) {
$objectInstace->comments[$singleElementKey][$key] = (string) $singleElementValue["dbValue"];
}
}
KalturaUnitTestDataObject::setPropertyValue(&$objectInstace->dataObject, $arrayKey, $arrayValue, $childValueType);
} else {
KalturaUnitTestDataObject::setPropertyValue(&$objectInstace->dataObject, $childKey, $childValue, $childValueType);
}
} catch (Exception $e) {
throw new Exception("Error can't set by name" . $childValue . $e, $e->getCode());
}
}
} else {
//Handle no classes objects like string and int
//TODO: add support for file... here or there...
}
// pass back propel object
return $objectInstace;
}