aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggPluginManifestParser.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-30 03:56:34 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-30 03:56:34 +0000
commit8173f672f06ad2783d3d0112e7b285d2240f488b (patch)
tree283496b227e083fb18ee628f9a6b8b40a0b24edb /engine/classes/ElggPluginManifestParser.php
parentcaef932790b72de1efa5b8ef2065dd3ca3b9eb5a (diff)
downloadelgg-8173f672f06ad2783d3d0112e7b285d2240f488b.tar.gz
elgg-8173f672f06ad2783d3d0112e7b285d2240f488b.tar.bz2
Refs #1986 #2170 #2225 Added ElggPluginManifest, ElggPluginManifestParser, and its parser classes for 1.7 and 1.8 style manifests. Changed load_plugin_manifest() to use new parser. Added initial unit tests.
git-svn-id: http://code.elgg.org/elgg/trunk@7481 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/classes/ElggPluginManifestParser.php')
-rw-r--r--engine/classes/ElggPluginManifestParser.php91
1 files changed, 91 insertions, 0 deletions
diff --git a/engine/classes/ElggPluginManifestParser.php b/engine/classes/ElggPluginManifestParser.php
new file mode 100644
index 000000000..0ce3e3024
--- /dev/null
+++ b/engine/classes/ElggPluginManifestParser.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * Parent class for manifest parsers.
+ *
+ * @package Elgg.Core
+ * @subpackage Plugins
+ *
+ */
+abstract class ElggPluginManifestParser {
+ /**
+ * The XmlElement object
+ *
+ * @var XmlElement
+ */
+ protected $manifestObject;
+
+ /**
+ * The manifest array
+ *
+ * @var array
+ */
+ protected $manifest;
+
+ /**
+ * All valid manifest attributes with default values.
+ *
+ * @var array
+ */
+ protected $validAttributes;
+
+ /**
+ * The object we're doing parsing for.
+ *
+ * @var object
+ */
+ protected $caller;
+
+ /**
+ * Loads the manifest XML to be parsed.
+ *
+ * @param XmlElement $xml The Manifest XML to be parsed
+ * @param object $caller The object calling this parser.
+ */
+ public function __construct(XmlElement $xml, $caller) {
+ $this->manifestObject = $xml;
+ $this->caller = $caller;
+ }
+
+ /**
+ * Returns the manifest XML object
+ *
+ * @return XmlElement
+ */
+ public function getManifestObject() {
+ return $this->manifestObject;
+ }
+
+ /**
+ * Return the parsed manifest array
+ *
+ * @return array
+ */
+ public function getManifest() {
+ return $this->manifest;
+ }
+
+ /**
+ * Return an attribute in the manifest.
+ *
+ * @param string $name Attribute name
+ * @return mixed
+ */
+ public function getAttribute($name) {
+ if (array_key_exists($name, $this->validAttributes)) {
+ if (isset($this->manifest[$name])) {
+ return $this->manifest[$name];
+ } else {
+ return $this->validAttributes[$name];
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Parse the XML object into an array
+ *
+ * @return bool
+ */
+ abstract public function parse();
+} \ No newline at end of file