public static function fromReflection(Zend_Reflection_Method $reflectionMethod) { $method = new self(); $method->setSourceContent($reflectionMethod->getContents(false)); $method->setSourceDirty(false); if ($reflectionMethod->getDocComment() != '') { $method->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionMethod->getDocblock())); } $method->setFinal($reflectionMethod->isFinal()); if ($reflectionMethod->isPrivate()) { $method->setVisibility(self::VISIBILITY_PRIVATE); } elseif ($reflectionMethod->isProtected()) { $method->setVisibility(self::VISIBILITY_PROTECTED); } else { $method->setVisibility(self::VISIBILITY_PUBLIC); } $method->setStatic($reflectionMethod->isStatic()); $method->setName($reflectionMethod->getName()); foreach ($reflectionMethod->getParameters() as $reflectionParameter) { $method->setParameter(Zend_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter)); } $body = $reflectionMethod->getBody(); $body2 = str_replace("\n\n", "\n", $body); $body2 = preg_replace("|^\n\\s{4}|muU", "\n", $body2); $body2 = preg_replace("|^\\s{4}|muU", "", $body2); // $body2 = str_replace(' ', '.', $body2); //dmDebug::kill($body, "\n".$body2); $method->setBody($body2); return $method; }
/** * fromReflection() * * @param Zend_Reflection_Method $reflectionMethod * @return Zend_CodeGenerator_Php_Method */ public static function fromReflection(Zend_Reflection_Method $reflectionMethod) { $method = new self(); $method->setSourceContent($reflectionMethod->getContents(false)); $method->setSourceDirty(false); if ($reflectionMethod->getDocComment() != '') { $method->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionMethod->getDocblock())); } $method->setFinal($reflectionMethod->isFinal()); if ($reflectionMethod->isPrivate()) { $method->setVisibility(self::VISIBILITY_PRIVATE); } elseif ($reflectionMethod->isProtected()) { $method->setVisibility(self::VISIBILITY_PROTECTED); } else { $method->setVisibility(self::VISIBILITY_PUBLIC); } $method->setStatic($reflectionMethod->isStatic()); $method->setName($reflectionMethod->getName()); foreach ($reflectionMethod->getParameters() as $reflectionParameter) { $method->setParameter(Zend_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter)); } $method->setBody($reflectionMethod->getBody()); $method->_reflection = true; return $method; }
/** * fromReflection() * * @param Zend_Reflection_Property $reflectionProperty * @return Zend_CodeGenerator_Php_Property */ public static function fromReflection(Zend_Reflection_Property $reflectionProperty) { $property = new self(); $property->setName($reflectionProperty->getName()); $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties(); $property->setDefaultValue($allDefaultProperties[$reflectionProperty->getName()]); if ($reflectionProperty->getDocComment() != '') { $property->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionProperty->getDocComment())); } if ($reflectionProperty->isStatic()) { $property->setStatic(true); } if ($reflectionProperty->isPrivate()) { $property->setVisibility(self::VISIBILITY_PRIVATE); } elseif ($reflectionProperty->isProtected()) { $property->setVisibility(self::VISIBILITY_PROTECTED); } else { $property->setVisibility(self::VISIBILITY_PUBLIC); } $property->setSourceDirty(false); return $property; }
/** * @param SimpleXMLElement $xml * * @return DeliveryMethod */ public static function createFromXML(SimpleXMLElement $xml) { /* <characteristic displayValue="Basic (0-500 EUR)" value="1" name="Insurance range code"/> */ $attributes = $xml->attributes(); $children = $xml->children(); $deliveryMethod = new self(); $deliveryMethod->setName($attributes['name']); $deliveryMethod->setVisibility($attributes['visiblity']); if (isset($children->product)) { foreach ($children->product as $productXml) { $deliveryMethod->addProduct(Product::createFromXML($productXml)); } } return $deliveryMethod; }
/** * @param SimpleXMLElement $xml * * @return Option */ public static function createFromXML(SimpleXMLElement $xml) { /* <option visiblity="NOT_VISIBLE_BY_CONSUMER_OPTIONAL" price="0" name="Cash on delivery"/> */ $attributes = $xml->attributes(); $children = $xml->children(); $option = new self(); $option->setVisibility($attributes['visiblity']); $option->setPrice($attributes['price']); $option->setName($attributes['name']); if (isset($children->chracteristic)) { foreach ($children->chracteristic as $characteristicXml) { $option->addCharacteristic(Characteristic::createFromXML($characteristicXml)); } } return $option; }
/** * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement) * @return CultureFeed_Cdb_Item_Page */ public static function parseFromCdbXml(SimpleXMLElement $xmlElement) { if (empty($xmlElement->uid)) { throw new CultureFeed_Cdb_ParseException('Uid missing for page element'); } if (empty($xmlElement->name)) { throw new CultureFeed_Cdb_ParseException('Name missing for page element'); } $page = new self(); // Set ID + name. $page->setId((string) $xmlElement->uid); $page->setName((string) $xmlElement->name); $page->setOfficialPage(filter_var((string) $xmlElement->officialPage, FILTER_VALIDATE_BOOLEAN)); // Set categories $categories = array(); if (!empty($xmlElement->categoryIds->categoryId)) { foreach ($xmlElement->categoryIds->categoryId as $category) { $categories[] = (string) $category; } } $page->setCategories($categories); // Set keywords $keywords = array(); if (!empty($xmlElement->keywords->keyword)) { foreach ($xmlElement->keywords->keyword as $keyword) { $keywords[] = (string) $keyword; } } $page->setKeywords($keywords); // Set description. if (!empty($xmlElement->description)) { $page->setDescription((string) $xmlElement->description); } // Set the image. if (!empty($xmlElement->image)) { $page->setImage((string) $xmlElement->image); } // Set the cover. if (!empty($xmlElement->cover)) { $page->setCover((string) $xmlElement->cover); } // Set the visibility. if (!empty($xmlElement->visible)) { $page->setVisibility((string) $xmlElement->visible); } // Set address. $address = new CultureFeed_Cdb_Data_Address_PhysicalAddress(); $addressElement = $xmlElement->address; $has_address = FALSE; if (!empty($addressElement->city)) { $address->setCity((string) $addressElement->city); $has_address = TRUE; } if (!empty($addressElement->street)) { $address->setStreet((string) $addressElement->street); $has_address = TRUE; } if (!empty($addressElement->zip)) { $address->setZip((string) $addressElement->zip); $has_address = TRUE; } if (!empty($addressElement->country)) { $address->setCountry((string) $addressElement->country); $has_address = TRUE; } if (!empty($addressElement->lat) && !empty($addressElement->lon)) { $coordinates = $addressElement->lat . '-' . $addressElement->lon; if ($coordinates != '0.0-0.0') { $address->setGeoInformation(new CultureFeed_Cdb_Data_Address_GeoInformation((string) $addressElement->lon, (string) $addressElement->lat)); $has_address = TRUE; } } if ($has_address) { $page->setAddress($address); } // Set contact info. if (!empty($xmlElement->contactInfo->email)) { $page->setEmail((string) $xmlElement->contactInfo->email); } if (!empty($xmlElement->contactInfo->telephone)) { $page->setTelephone((string) $xmlElement->contactInfo->telephone); } // Set links. $links = array(); if (!empty($xmlElement->links)) { foreach ($xmlElement->links->children() as $link) { $url = (string) $link; if (empty($url)) { continue; } // Make sure http is in front of the url. if (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) { $url = 'http://' . $url; } $links[$link->getName()] = $url; } } $page->setLinks($links); // Set the permissions. $page->setPermissions(CultureFeed_Cdb_Data_PagePermissions::parseFromCdbXml($xmlElement->permissions)); // Set tagline. $page->setTagline((string) $xmlElement->tagline); return $page; }