diff --git a/.dev/Bootstrap.php b/.dev/Bootstrap.php
index d1b4d3a..65daaf6 100644
--- a/.dev/Bootstrap.php
+++ b/.dev/Bootstrap.php
@@ -1,9 +1,10 @@
0) {
+ $temp_array = array();
+ foreach ($temp as $key => $value) {
+ $temp_array[$key] = $value;
+ }
+ }
+
+ return $temp_array;
+}
diff --git a/.dev/Reflection.php b/.dev/Reflection.php
new file mode 100644
index 0000000..abb3fc7
--- /dev/null
+++ b/.dev/Reflection.php
@@ -0,0 +1,6 @@
+getMethods();
+foreach ($methods as $method) {
+ echo ' * @covers ' . $method->class . '::' . $method->name . PHP_EOL;
+}
diff --git a/.dev/Tests/ClassMapTest.php b/.dev/Tests/ClassMapTest.php
new file mode 100644
index 0000000..722d10a
--- /dev/null
+++ b/.dev/Tests/ClassMapTest.php
@@ -0,0 +1,50 @@
+resource_adapter = new $class (
+ // Input
+ $base_path,
+ $exclude_folders_array,
+ // Output
+ $classmap_filename,
+ $resource_map_filename
+ );
+
+ return $this;
+ }
+
+ /**
+ * Set Namespace
+ *
+ * @covers Molajo\Resource\ResourceMap::setNamespace
+ * @covers Molajo\Resource\ResourceMap::createMap
+ * @covers Molajo\Resource\ResourceMap::saveOutput
+ * @covers Molajo\Resource\ResourceMap::getResourceMap
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespacePrefixes
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespaceFolders
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processFilePathObjects
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testFileForNamespaceRules
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setBase
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setFileInclusion
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testPHPClassExceptions
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testExcludeFolders
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setPath
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setQNS
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setNamespaceObject
+ * @covers Molajo\Resource\ResourceMap\Prefixes::useFilesWithNamespace
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setClassfileArrayEntry
+ * @covers Molajo\Resource\ResourceMap\Prefixes::mergeFQNSPaths
+ * @covers Molajo\Resource\ResourceMap\Prefixes::mergeExistingFQNSPath
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setClassfileArrayEntry
+ * @covers Molajo\Resource\ResourceMap\Folders::setMultipleNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Folders::appendNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Folders::prependNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Base::__construct
+ * @covers Molajo\Resource\ResourceMap\Base::getReflectionObject
+ * @covers Molajo\Resource\ResourceMap\Base::addSlash
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ public function setNamespace()
+ {
+ $this->resource_adapter->setNamespace('Molajo\\A\\', 'Source/A/');
+ $this->resource_adapter->setNamespace('Molajo\\B\\', 'Source/B/');
+ $this->resource_adapter->setNamespace('Molajo\\C\\', 'Source/C/');
+
+ return $this;
+ }
+
+ /**
+ * Set Namespace
+ *
+ * @covers Molajo\Resource\ResourceMap::setNamespace
+ * @covers Molajo\Resource\ResourceMap::createMap
+ * @covers Molajo\Resource\ResourceMap::saveOutput
+ * @covers Molajo\Resource\ResourceMap::getResourceMap
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespacePrefixes
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespaceFolders
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processFilePathObjects
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testFileForNamespaceRules
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setBase
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setFileInclusion
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testPHPClassExceptions
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testExcludeFolders
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setPath
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setQNS
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setNamespaceObject
+ * @covers Molajo\Resource\ResourceMap\Prefixes::useFilesWithNamespace
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setClassfileArrayEntry
+ * @covers Molajo\Resource\ResourceMap\Prefixes::mergeFQNSPaths
+ * @covers Molajo\Resource\ResourceMap\Prefixes::mergeExistingFQNSPath
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setClassfileArrayEntry
+ * @covers Molajo\Resource\ResourceMap\Folders::setMultipleNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Folders::appendNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Folders::prependNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Base::__construct
+ * @covers Molajo\Resource\ResourceMap\Base::getReflectionObject
+ * @covers Molajo\Resource\ResourceMap\Base::addSlash
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ public function createMap()
+ {
+ $this->resource_adapter->createMap();
+
+ return $this;
+ }
+
+ /**
+ * @covers Molajo\Resource\ResourceMap::setNamespace
+ * @covers Molajo\Resource\ResourceMap::createMap
+ * @covers Molajo\Resource\ResourceMap::saveOutput
+ * @covers Molajo\Resource\ResourceMap::getResourceMap
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespacePrefixes
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespaceFolders
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processFilePathObjects
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testFileForNamespaceRules
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setBase
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setFileInclusion
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testPHPClassExceptions
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testExcludeFolders
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setPath
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setQNS
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setNamespaceObject
+ * @covers Molajo\Resource\ResourceMap\Prefixes::useFilesWithNamespace
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setClassfileArrayEntry
+ * @covers Molajo\Resource\ResourceMap\Prefixes::mergeFQNSPaths
+ * @covers Molajo\Resource\ResourceMap\Prefixes::mergeExistingFQNSPath
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setClassfileArrayEntry
+ * @covers Molajo\Resource\ResourceMap\Folders::setMultipleNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Folders::appendNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Folders::prependNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Base::__construct
+ * @covers Molajo\Resource\ResourceMap\Base::getReflectionObject
+ * @covers Molajo\Resource\ResourceMap\Base::addSlash
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ public function testSetNamespace()
+ {
+ $this->resource_adapter->setNamespace('Molajo\\A\\', 'Source/A/');
+ $this->resource_adapter->setNamespace('Molajo\\B\\', 'Source/B/');
+ $this->resource_adapter->setNamespace('Molajo\\C\\', 'Source/C/');
+
+ $expected = array();
+ $expected['Molajo\\A\\'] = array('Source/A/');
+ $expected['Molajo\\B\\'] = array('Source/B/');
+ $expected['Molajo\\C\\'] = array('Source/C/');
+
+ $this->assertEquals($expected, $this->resource_adapter->get('namespace_prefixes'));
+
+ return $this;
+ }
+
+ /**
+ * @covers Molajo\Resource\ResourceMap::setNamespace
+ * @covers Molajo\Resource\ResourceMap::createMap
+ * @covers Molajo\Resource\ResourceMap::saveOutput
+ * @covers Molajo\Resource\ResourceMap::getResourceMap
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespacePrefixes
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespaceFolders
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processFilePathObjects
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testFileForNamespaceRules
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setBase
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setFileInclusion
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testPHPClassExceptions
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testExcludeFolders
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setPath
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setQNS
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setNamespaceObject
+ * @covers Molajo\Resource\ResourceMap\Prefixes::useFilesWithNamespace
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setClassfileArrayEntry
+ * @covers Molajo\Resource\ResourceMap\Prefixes::mergeFQNSPaths
+ * @covers Molajo\Resource\ResourceMap\Prefixes::mergeExistingFQNSPath
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setClassfileArrayEntry
+ * @covers Molajo\Resource\ResourceMap\Folders::setMultipleNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Folders::appendNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Folders::prependNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Base::__construct
+ * @covers Molajo\Resource\ResourceMap\Base::getReflectionObject
+ * @covers Molajo\Resource\ResourceMap\Base::addSlash
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ public function testClassFiles()
+ {
+ $this->setNamespace();
+ $this->resource_adapter->createMap();
+
+ $class_files = array();
+
+ /** Row 1 */
+ $row = new stdClass();
+
+ $row->file_name = 'Cat.php';
+ $row->base_name = 'Cat';
+ $row->path = 'Source/A/Cat.php';
+ $row->file_name = 'Cat.php';
+ $row->qns = 'Molajo\\A\\Cat';
+
+ $class_files[$row->path] = $row;
+
+ /** Row 2 */
+ $row = new stdClass();
+
+ $row->file_name = 'Dog.php';
+ $row->base_name = 'Dog';
+ $row->path = 'Source/A/Dog.php';
+ $row->file_name = 'Dog.php';
+ $row->qns = 'Molajo\\A\\Dog';
+
+ $class_files[$row->path] = $row;
+
+ /** Row 3 */
+ $row = new stdClass();
+
+ $row->file_name = 'Mouse.php';
+ $row->base_name = 'Mouse';
+ $row->path = 'Source/A/Mouse.php';
+ $row->file_name = 'Mouse.php';
+ $row->qns = 'Molajo\\A\\Mouse';
+
+ $class_files[$row->path] = $row;
+
+ /** Row 4 */
+ $row = new stdClass();
+
+ $row->file_name = 'Zebra.php';
+ $row->base_name = 'Zebra';
+ $row->path = 'Source/A/Z/Zebra.php';
+ $row->file_name = 'Zebra.php';
+ $row->qns = 'Molajo\\A\\Z\\Zebra';
+
+ $class_files[$row->path] = $row;
+
+ /** Row 5 */
+ $row = new stdClass();
+
+ $row->file_name = 'Banana.php';
+ $row->base_name = 'Banana';
+ $row->path = 'Source/B/Banana.php';
+ $row->file_name = 'Banana.php';
+ $row->qns = 'Molajo\\B\\Banana';
+
+ $class_files[$row->path] = $row;
+
+ /** Row 6 */
+ $row = new stdClass();
+
+ $row->file_name = 'Bat.php';
+ $row->base_name = 'Bat';
+ $row->path = 'Source/B/Bat.php';
+ $row->file_name = 'Bat.php';
+ $row->qns = 'Molajo\\B\\Bat';
+
+ $class_files[$row->path] = $row;
+
+ /** Row 7 */
+ $row = new stdClass();
+
+ $row->file_name = 'Candy.php';
+ $row->base_name = 'Candy';
+ $row->path = 'Source/C/Candy.php';
+ $row->file_name = 'Candy.php';
+ $row->qns = 'Molajo\\C\\Candy';
+
+ $class_files[$row->path] = $row;
+
+ $this->assertEquals($class_files, $this->resource_adapter->get('class_files'));
+
+ return $this;
+ }
+
+
+ /**
+ * @covers Molajo\Resource\ResourceMap::setNamespace
+ * @covers Molajo\Resource\ResourceMap::createMap
+ * @covers Molajo\Resource\ResourceMap::saveOutput
+ * @covers Molajo\Resource\ResourceMap::getResourceMap
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespacePrefixes
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespaceFolders
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Prefixes::processFilePathObjects
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testFileForNamespaceRules
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setBase
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setFileInclusion
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testPHPClassExceptions
+ * @covers Molajo\Resource\ResourceMap\Prefixes::testExcludeFolders
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setPath
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setQNS
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setNamespaceObject
+ * @covers Molajo\Resource\ResourceMap\Prefixes::useFilesWithNamespace
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setClassfileArrayEntry
+ * @covers Molajo\Resource\ResourceMap\Prefixes::mergeFQNSPaths
+ * @covers Molajo\Resource\ResourceMap\Prefixes::mergeExistingFQNSPath
+ * @covers Molajo\Resource\ResourceMap\Prefixes::setClassfileArrayEntry
+ * @covers Molajo\Resource\ResourceMap\Folders::setMultipleNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Folders::appendNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Folders::prependNamespaceFolder
+ * @covers Molajo\Resource\ResourceMap\Base::__construct
+ * @covers Molajo\Resource\ResourceMap\Base::getReflectionObject
+ * @covers Molajo\Resource\ResourceMap\Base::addSlash
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ public function testResourceFiles()
+ {
+ $base = __DIR__ . '/';
+
+ $this->setNamespace();
+
+ $this->resource_adapter->createMap();
+
+ $resource_files = array();
+ $resource_files['molajo\\a\\'] = array($base . 'Source/A/');
+ $resource_files['molajo\\a\\cat'] = array($base . 'Source/A/Cat.php');
+ $resource_files['molajo\\a\\dog'] = array($base . 'Source/A/Dog.php');
+ $resource_files['molajo\\a\\mouse'] = array($base . 'Source/A/Mouse.php');
+ $resource_files['molajo\\a\\z'] = array($base . 'Source/A/Z');
+ $resource_files['molajo\\a\\z\\stripes.txt'] = array($base . 'Source/A/Z/Stripes.txt');
+ $resource_files['molajo\\a\\z\\zebra'] = array($base . 'Source/A/Z/Zebra.php');
+ $resource_files['molajo\\b\\'] = array($base . 'Source/B/');
+ $resource_files['molajo\\b\\100x100.gif'] = array($base . 'Source/B/100x100.gif');
+ $resource_files['molajo\\b\\150x150.gif'] = array($base . 'Source/B/150x150.gif');
+ $resource_files['molajo\\b\\50x50.gif'] = array($base . 'Source/B/50x50.gif');
+ $resource_files['molajo\\b\\banana'] = array($base . 'Source/B/Banana.php');
+ $resource_files['molajo\\b\\bat'] = array($base . 'Source/B/Bat.php');
+ $resource_files['molajo\\c\\'] = array($base . 'Source/C/');
+ $resource_files['molajo\\c\\candy'] = array($base . 'Source/C/Candy.php');
+ $resource_files['molajo\\c\\content.xml'] = array($base . 'Source/C/Content.xml');
+ $resource_files['molajo\\c\\customize.css'] = array($base . 'Source/C/Customize.css');
+ $resource_files['molajo\\c\\js'] = array($base . 'Source/C/Js');
+ $resource_files['molajo\\c\\js\\foundation.min.js'] = array($base . 'Source/C/Js/foundation.min.js');
+
+ $resource_output = $this->resource_adapter->getResourceMap();
+
+ foreach ($resource_output as $key => $row) {
+ $this->assertEquals($row, $resource_files[$key]);
+ }
+
+ return $this;
+ }
+}
+
+class MockResourceMap extends ResourceMap
+{
+ public function get($key)
+ {
+ return $this->$key;
+ }
+}
diff --git a/.dev/Tests/ResourceTest.php b/.dev/Tests/ResourceTest.php
deleted file mode 100644
index 1a92244..0000000
--- a/.dev/Tests/ResourceTest.php
+++ /dev/null
@@ -1,98 +0,0 @@
-render($file, $data);
- $this->assertEquals('stuff', $stuff);
-
- return $this;
- }
-
- /**
- * Test Mustache Renderer
- *
- * @return $this
- * @since 1.0
- */
- public function testMustache()
- {
- $instance = new Driver(new Mustache(new MockRender));
-
- $file = __DIR__ . '/RenderTest.php';
- $data = array();
- $stuff = $instance->render($file, $data);
- $this->assertEquals('stuff', $stuff);
-
- return $this;
- }
-
- /**
- * Test Twig Renderer
- *
- * @return $this
- * @since 1.0
- */
- public function testTwig()
- {
- $instance = new Driver(new Twig(new MockRender));
-
- $file = __DIR__ . '/RenderTest.php';
- $data = array();
- $stuff = $instance->render($file, $data);
- $this->assertEquals('stuff', $stuff);
-
- return $this;
- }
-}
-
-class MockRender implements RenderInterface
-{
- /**
- * Render output for specified file and data
- *
- * @param string $include_file
- * @param array $data
- *
- * @return string
- * @since 1.0
- */
- public function render($include_file, array $data = array())
- {
- return 'stuff';
- }
-}
diff --git a/.dev/Tests/Source/A/Cat.php b/.dev/Tests/Source/A/Cat.php
new file mode 100644
index 0000000..2db6b97
--- /dev/null
+++ b/.dev/Tests/Source/A/Cat.php
@@ -0,0 +1,22 @@
+
+
';
- var_dump($segments);
- throw new RuntimeException
- (
- 'Resource XmlHandler Failure namespace must have at least 3 segments: ' . $options['namespace']
- );
- }
-
- if (count($segments) === 3) {
- $model_type = ucfirst(strtolower($segments[1]));
- $model_name = ucfirst(strtolower($segments[2]));
- } else {
- $model_type = ucfirst(strtolower($segments[2]));
- $model_name = ucfirst(strtolower($segments[3]));
- }
-
- if (substr($model_name, strlen($model_name) - 4, 4) === '.xml') {
- $model_name = substr($model_name, 0, strlen($model_name) - 4); //remove .xml
- }
-
- if (file_exists($located_path)) {
- } else {
- throw new RuntimeException
- (
- 'Resource XmlHandler located_path not found: ' . $this->resource_namespace
- );
- }
-
- try {
- $contents = file_get_contents($located_path);
-
- $scheme = strtolower(trim($scheme));
- $model_type = ucfirst(strtolower(trim($model_type)));
-
- if ($scheme === 'query') {
- $xml = simplexml_load_string($contents);
- return $this->model_handler->getConfiguration($model_type, $model_name, $xml);
- } elseif ($model_type === 'Application') {
- $xml = simplexml_load_string($contents);
- return $xml;
- } elseif ($model_type === 'Fields' || $model_type === 'Include') {
- return $contents;
- } elseif ($model_type === 'Dataobject') {
- $xml = simplexml_load_string($contents);
- return $this->dataobject_handler->getConfiguration($model_type, $model_name, $xml);
- } else {
- $xml = simplexml_load_string($contents);
- return $this->model_handler->getConfiguration($model_type, $model_name, $xml);
- }
- } catch (Exception $e) {
-
- throw new RuntimeException
- (
- 'Resource XmlHandler Failure: ' . $located_path . ' ' . $e->getMessage()
- );
- }
- }
-
- /**
- * Retrieve a collection of a specific handler
- *
- * @param string $scheme
- * @param array $options
- *
- * @return mixed
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function getCollection($scheme, array $options = array())
- {
- return null;
- }
-}
diff --git a/Source/Api/ConfigurationDataInterface.php b/Source/Api/ConfigurationDataInterface.php
deleted file mode 100644
index c3295a8..0000000
--- a/Source/Api/ConfigurationDataInterface.php
+++ /dev/null
@@ -1,42 +0,0 @@
-registry->exists('Namespace');
- * $this->registry->exists('Namespace', 'NamespaceElement');
- *
- * @param string $namespace
- * @param null|string $key
- *
- * @return bool
- * @since 1.0
- */
- public function exists($namespace, $key = null);
-
- /**
- * Lock registry from update
- *
- * Usage:
- * $this->registry->lock('Namespace');
- *
- * @param string $namespace
- *
- * @return bool
- * @since 1.0
- */
- public function lock($namespace);
-
- /**
- * Returns true if the registry is locked
- * Returns false if there is no registry and if the registry is locked
- *
- * Usage:
- * $this->registry->checkLock('Namespace');
- *
- * @param string $namespace
- *
- * @return bool
- * @since 1.0
- */
- public function checkLock($namespace);
-
- /**
- * Create a registry for the specified namespace
- *
- * Notes:
- * - All namespaces are set to lowercase to remove case sensitivity
- * - Throws exception if namespace is reserved
- * - Returns namespace if already existing (Note: Use 'exists' to verify prior to creation)
- * - Called automatically when needed by a set for a namespace or for the member of a namespace
- *
- * Usage:
- * $this->registry->createRegistry('Namespace');
- *
- * @param string $namespace
- *
- * @return mixed|bool|array
- * @since 1.0
- */
- public function createRegistry($namespace);
-
- /**
- * Returns Registry Data
- *
- * Notes:
- * - Creates registry member using default if not existing and default provided
- * - Creates registry if not existing (whether or not a member was created)
- *
- * Usage:
- * $this->registry->get('Namespace', 'key value');
- *
- * List names of existing registry namespaces:
- * echo $this->registry->get('*');
- *
- * ... include a formatted dump of namespace contents
- * echo $this->registry->get('*', '*');
- *
- * List all entries in the specified registry namespace
- * $array = $this->registry->get('Name space');
- *
- * List only those namespace entries beginning with the wildcard value:
- * echo $this->registry->get('Name space', 'theme*');
- *
- * @param string $namespace
- * @param string $key
- * @param mixed $default
- *
- * @return array|bool|mixed
- * @since 1.0
- */
- public function get($namespace = null, $key = null, $default = null);
-
- /**
- * Sets the value for a specific namespace item
- *
- * Use $match to ensure member exists prior to setting value
- *
- * Usage:
- * $this->registry->set('Namespace', 'key_name', $value);
- *
- * @param string $namespace
- * @param string $key
- * @param mixed $value
- * @param boolean $match
- *
- * @return void|bool|RegistryInterface
- * @since 1.0
- */
- public function set($namespace, $key, $value = null, $match = false);
-
- /**
- * Copy key values from one namespace registry into another, overwriting existing values in the other registry
- *
- * Note:
- * If target_registry already exists, source_registry values replace existing values for matching keys
- * Key pairs on target registry remain unchanged if there are no matching pairs. Use Delete first, if desired.
- * Use merge when target registry values should remain -- not be overwritten.
- *
- * Usage:
- * $this->registry->copy('namespace-x', 'to-namespace-y');
- *
- * To copy only certain values:
- * $this->registry->copy('namespace-x', 'to-namespace-y', 'wildcard*');
- *
- * @param string $source_registry
- * @param string $target_registry
- * @param null $filter
- *
- * @return void|$this
- * @since 1.0
- */
- public function copy($source_registry, $target_registry, $filter = null);
-
- /**
- * Merge one Namespace into another
- *
- * - When keys match, target value is retained
- * - When key does not exist on the target, it is copied in
- * In either of the above cases, when "remove_from_source" is 1, the source entry is removed
- * - If no entries remain in the source after the merge, the empty source registry is deleted
- *
- * Usage:
- * $this->registry->merge('namespace-x', 'to-namespace-y');
- *
- * Merge a subset of source using wildcard:
- * $this->registry->merge('namespace-x', 'to-namespace-y', 'Only These*');
- *
- * Merge a subset of source using wildcard, and then delete the source merged in:
- * $this->registry->merge('namespace-x', 'to-namespace-y', 'Only These*', 1);
- *
- * @param string $source_registry
- * @param string $target_registry
- * @param bool $filter - merge for matching keys
- * @param int $remove_from_source
- *
- * @return array|bool
- * @since 1.0
- */
- public function merge($source_registry, $target_registry, $filter = false, $remove_from_source = 0);
-
- /**
- * Sort Namespace
- *
- * Usage:
- * $this->registry->sort('namespace');
- *
- * @param string $namespace
- *
- * @return $this
- * @since 1.0
- */
- public function sort($namespace);
-
- /**
- * Deletes a registry or registry entry
- *
- * Usage:
- * $this->registry->delete('Namespace', 'key_name');
- *
- * @param string $namespace
- * @param string $key
- *
- * @return \Molajo\Resource\Configuration\Registry
- * @return \Molajo\Resource\Configuration\Registry
- * @since 1.0
- */
- public function delete($namespace, $key = null);
-
- /**
- * Rename a namespace (deletes existing, creates new)
- *
- * Usage:
- * $this->registry->rename($namespace);
- *
- * @param $namespace
- * @param $new_namespace
- *
- * @return $this
- * @since 1.0
- */
- public function rename($namespace, $new_namespace);
-
- /**
- * Returns an array containing key and name pairs for a namespace registry
- *
- * Usage:
- * $this->registry->getArray('Namespace');
- *
- * To retrieve only the key field names, not the values:
- * $this->registry->getArray('Namespace', true);
- *
- * @param string $namespace
- * @param boolean $key_only set to true to retrieve key names
- *
- * @return array
- * @since 1.0
- */
- public function getArray($namespace, $key_only = false);
-
- /**
- * Populates a registry with an array of key and name pairs
- *
- * Usage:
- * $this->registry->loadArray('Namespace', $array);
- *
- * @param string $namespace name of registry to use or create
- * @param array $array key and value pairs to load
- *
- * @return $this
- * @since 1.0
- */
- public function loadArray($namespace, $array = array());
-
- /**
- * Retrieves a list of ALL namespace registries and optionally keys/values
- *
- * Specify $expand = true to return the entire list, and the member names and values in each registry
- *
- * Usage:
- * $this->registry->listRegistry();
- *
- * @param boolean $expand
- *
- * @return mixed|boolean|array
- * @since 1.0
- */
- public function listRegistry($expand = false);
-
- /**
- * getData - returns Registry (comes from $model_name) as Query Results (array of objects)
- *
- * Data can be requested as a result - provide $registry, $element and true for $single result
- *
- * Use '*' in the key to retrieve all values starting with a specific phrase (ex. 'model')
- *
- * @param string $registry Name of registry, for the MVC this is the $model_name
- * @param null|string $key Key of the named pair
- * @param null|string $query_object Result, Item, or List
- *
- * @return array|bool|mixed
- * @since 1.0
- */
- public function getData($registry, $key = null, $query_object = null);
-}
diff --git a/Source/ClassMap.php b/Source/ClassMap.php
index 117b2c3..3c1e715 100644
--- a/Source/ClassMap.php
+++ b/Source/ClassMap.php
@@ -3,7 +3,7 @@
* Class Map Driver
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Resource;
@@ -15,9 +15,9 @@
* Class Map Driver
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @since 1.0
+ * @since 1.0.0
*/
class ClassMap extends Items implements MapInterface
{
@@ -25,7 +25,7 @@ class ClassMap extends Items implements MapInterface
* Create interface to concrete references
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
public function createMap()
{
@@ -46,21 +46,13 @@ public function createMap()
* Save results of processing to files
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function saveOutput()
{
- if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
- file_put_contents($this->interface_classes_filename, json_encode($this->interfaces, JSON_PRETTY_PRINT));
- file_put_contents($this->concrete_classes_filename, json_encode($this->concretes, JSON_PRETTY_PRINT));
- file_put_contents($this->events_filename, json_encode($this->events, JSON_PRETTY_PRINT));
-
- return $this;
- }
-
- file_put_contents($this->interface_classes_filename, json_encode($this->interfaces));
- file_put_contents($this->concrete_classes_filename, json_encode($this->concretes));
- file_put_contents($this->events_filename, json_encode($this->events));
+ file_put_contents($this->interface_classes_filename, json_encode($this->interfaces, JSON_PRETTY_PRINT));
+ file_put_contents($this->concrete_classes_filename, json_encode($this->concretes, JSON_PRETTY_PRINT));
+ file_put_contents($this->events_filename, json_encode($this->events, JSON_PRETTY_PRINT));
return $this;
}
diff --git a/Source/ClassMap/Aggregate.php b/Source/ClassMap/Aggregate.php
index 5fc22a1..0d729c1 100644
--- a/Source/ClassMap/Aggregate.php
+++ b/Source/ClassMap/Aggregate.php
@@ -3,7 +3,7 @@
* Class Map Item Aggregation
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Resource\ClassMap;
@@ -12,9 +12,9 @@
* Class Map Item Aggregation
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @since 1.0
+ * @since 1.0.0
*/
abstract class Aggregate extends Events
{
@@ -22,7 +22,7 @@ abstract class Aggregate extends Events
* Determine Concrete Classes implement the Interface
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function finalizeItems()
{
@@ -37,7 +37,7 @@ protected function finalizeItems()
* Determine Concrete Classes implement the Interface
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setInterfaces()
{
@@ -68,7 +68,7 @@ protected function setInterfaces()
* @param string $qns
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setInterfaceValues($interface, $qns)
{
@@ -87,7 +87,7 @@ protected function setInterfaceValues($interface, $qns)
* Determine Concrete Classes implement the Interface
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setConcretes()
{
@@ -111,7 +111,7 @@ protected function setConcretes()
* @param object $parameter
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setConcreteConstructorValues($parameter)
{
diff --git a/Source/ClassMap/Base.php b/Source/ClassMap/Base.php
index 56597f1..b9495ca 100644
--- a/Source/ClassMap/Base.php
+++ b/Source/ClassMap/Base.php
@@ -3,7 +3,7 @@
* Class Map
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Resource\ClassMap;
@@ -15,9 +15,9 @@
* Class Map Base
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @since 1.0
+ * @since 1.0.0
*/
abstract class Base
{
@@ -25,7 +25,7 @@ abstract class Base
* Class Map Array
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $classmap_files = array();
@@ -33,7 +33,7 @@ abstract class Base
* Interfaces Filename
*
* @var string
- * @since 1.0
+ * @since 1.0.0
*/
protected $interface_classes_filename;
@@ -41,7 +41,7 @@ abstract class Base
* Class Dependencies
*
* @var string
- * @since 1.0
+ * @since 1.0.0
*/
protected $concrete_classes_filename;
@@ -49,7 +49,7 @@ abstract class Base
* Events
*
* @var string
- * @since 1.0
+ * @since 1.0.0
*/
protected $events_filename;
@@ -57,7 +57,7 @@ abstract class Base
* Interfaces
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $interfaces = array();
@@ -65,7 +65,7 @@ abstract class Base
* Interface Usage
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $interface_usage = array();
@@ -73,7 +73,7 @@ abstract class Base
* Concretes
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $concretes = array();
@@ -81,7 +81,7 @@ abstract class Base
* Events
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $events = array();
@@ -89,25 +89,26 @@ abstract class Base
* Base Path - root of the website from which paths are defined
*
* @var string
- * @since 1.0
+ * @since 1.0.0
*/
protected $base_path;
/**
* Constructor
*
- * @param array $class_maps
- * @param string $interface_classes_filename
- * @param string $concrete_classes_filename
- * @param string $events_filename
+ * @param array $classmap_files
+ * @param string $interface_classes_filename
+ * @param string $concrete_classes_filename
+ * @param string $events_filename
+ * @param string $base_path
*
- * @since 1.0
+ * @since 1.0.0
*/
public function __construct(
- array $classmap_files = array(),
- $interface_classes_filename = '',
- $concrete_classes_filename = '',
- $events_filename = '',
+ array $classmap_files,
+ $interface_classes_filename,
+ $concrete_classes_filename,
+ $events_filename,
$base_path
) {
$this->classmap_files = $classmap_files;
@@ -122,7 +123,7 @@ public function __construct(
*
* @param string $qns
*
- * @since 1.0
+ * @since 1.0.0
* @return object
*/
protected function getReflectionObject($qns)
diff --git a/Source/ClassMap/Events.php b/Source/ClassMap/Events.php
index b800412..c341032 100644
--- a/Source/ClassMap/Events.php
+++ b/Source/ClassMap/Events.php
@@ -3,7 +3,7 @@
* Class Map
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Resource\ClassMap;
@@ -14,9 +14,9 @@
* Class Map
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @since 1.0
+ * @since 1.0.0
*/
class Events extends Base
{
@@ -24,7 +24,7 @@ class Events extends Base
* Events
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $events = array();
@@ -32,7 +32,7 @@ class Events extends Base
* For each Interface, determine Concrete Classes which Implement the Interface and
* Requirements for a Concrete Class expressed by the Interface as a Type Hint in the Method Parameters
*
- * @since 1.0
+ * @since 1.0.0
* @return $this
*/
protected function setEvents()
@@ -41,30 +41,30 @@ protected function setEvents()
foreach ($this->concretes as $concrete) {
- if (count($concrete->method) > 0) {
+ if (count($concrete->method) > 0) {
- foreach ($concrete->method as $method) {
+ foreach ($concrete->method as $method) {
- if ($this->testMethodForPlugin($concrete, $method) === true) {
+ if ($this->testMethodForPlugin($concrete, $method) === true) {
- $class_instance = new \ReflectionClass($concrete->qns);
- $abstract = $class_instance->isAbstract();
+ $class_instance = new \ReflectionClass($concrete->qns);
+ $abstract = $class_instance->isAbstract();
- $reflectionMethod = new \ReflectionMethod(new $concrete->qns, $method);
- $results = $reflectionMethod->getDeclaringClass();
+ $reflectionMethod = new \ReflectionMethod(new $concrete->qns, $method);
+ $results = $reflectionMethod->getDeclaringClass();
- if ($results->name === $concrete->qns) {
- if (isset($this->events[$method])) {
- $classes = $this->events[$method];
- } else {
- $classes = array();
- }
- $classes[] = $concrete->qns;
- $this->events[$method] = array_unique($classes);
+ if ($results->name === $concrete->qns) {
+ if (isset($this->events[$method])) {
+ $classes = $this->events[$method];
+ } else {
+ $classes = array();
}
+ $classes[] = $concrete->qns;
+ $this->events[$method] = array_unique($classes);
}
}
}
+ }
}
@@ -78,7 +78,7 @@ protected function setEvents()
* @param string $method
*
* @return boolean
- * @since 1.0
+ * @since 1.0.0
*/
protected function testMethodForPlugin($concrete, $method)
{
diff --git a/Source/ClassMap/Items.php b/Source/ClassMap/Items.php
index f6cf1a1..f009126 100644
--- a/Source/ClassMap/Items.php
+++ b/Source/ClassMap/Items.php
@@ -3,7 +3,7 @@
* Class Map
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Resource\ClassMap;
@@ -15,9 +15,9 @@
* Class Map
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @since 1.0
+ * @since 1.0.0
*/
class Items extends Aggregate
{
@@ -25,7 +25,7 @@ class Items extends Aggregate
* Loop through Class Map files and process as Interfaces or Concretes
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function processItems()
{
@@ -34,6 +34,7 @@ protected function processItems()
$reflection = $this->getReflectionObject($file->qns);
if ($reflection === false) {
+
} else {
$class_object = $this->initialiseObject($file->path, $reflection);
@@ -55,8 +56,8 @@ protected function processItems()
* @param string $path
* @param object $reflection
*
- * @return $class_object
- * @since 1.0
+ * @return object
+ * @since 1.0.0
*/
protected function initialiseObject($path, $reflection)
{
@@ -86,7 +87,7 @@ protected function initialiseObject($path, $reflection)
* @param object $class_object
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setInterfaceClass($qns, $class_object)
{
@@ -103,7 +104,7 @@ protected function setInterfaceClass($qns, $class_object)
* @param object $class_object
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setConcreteClass($qns, $reflection, $class_object)
{
@@ -123,8 +124,8 @@ protected function setConcreteClass($qns, $reflection, $class_object)
* @param object $class_object
* @param string $qns
*
- * @return $this;
- * @since 1.0
+ * @return $this
+ * @since 1.0.0
*/
protected function setConcreteInterfaces($reflection, $class_object, $qns)
{
@@ -147,7 +148,7 @@ protected function setConcreteInterfaces($reflection, $class_object, $qns)
* @param string $qns
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setConcreteConstructorParameters($reflection, $class_object, $qns)
{
@@ -187,7 +188,7 @@ protected function setConcreteConstructorParameters($reflection, $class_object,
* @param object $parameter
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function processDependencies($class_method_array, $parameter)
{
@@ -221,10 +222,10 @@ protected function processDependencies($class_method_array, $parameter)
* Add to Dependency Interfaces List
*
* @param string $qns
- * @param array $concretes
+ * @param array $dependencies
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setConcreteDependencyInterfaces($qns, array $dependencies)
{
@@ -248,7 +249,7 @@ protected function setConcreteDependencyInterfaces($qns, array $dependencies)
* @param integer $type
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setConcreteInterfaceRelationship($interface, $type = 0, $qns = '')
{
diff --git a/Source/Configuration/AbstractAdapter.php b/Source/Configuration/AbstractAdapter.php
deleted file mode 100644
index bfb5644..0000000
--- a/Source/Configuration/AbstractAdapter.php
+++ /dev/null
@@ -1,575 +0,0 @@
-dataobject = $dataobject;
- $this->registry = $registry;
- $this->resource = $resource;
- }
-
- /**
- * Load registry for requested model resource, returning name of registry collection
- *
- * @param string $model_type
- * @param string $model_name
- * @param object $xml
- *
- * @return string Name of registry model
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function getConfiguration($model_type, $model_name, $xml)
- {
- throw new RuntimeException('Configuration Xml Abstract Adapter - use subclass getConfiguration');
- }
-
- /**
- * Store Configuration Data in Registry
- *
- * @param string $model_registry
- * @param object $xml
- *
- * @return array
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function setModelRegistry($model_registry, $xml)
- {
- throw new RuntimeException('Configuration Xml Abstract Adapter - use subclass setModelRegistry');
- }
-
- /**
- * Parse xml recursively, processing all include statements
- *
- * @param string $xml
- *
- * @return \SimpleXMLElement
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function getIncludeCode($xml)
- {
- $pre_string = $xml->asXML();
-
- $done = false;
-
- while ($done === false) {
- $post_string = $this->getIncludeCodeLoop($pre_string);
- if ($post_string === $pre_string) {
- $done = true;
- } else {
- $pre_string = $post_string;
- }
- }
-
- return simplexml_load_string($post_string);
- }
-
- /**
- * Parse xml recursively, processing all include statements
- *
- *
- * @return string
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function getIncludeCodeLoop($xml_string)
- {
- $pattern = '/ /';
-
- preg_match_all($pattern, $xml_string, $matches);
-
- $replace_this_array = $matches[0];
- $type_array = $matches[1];
- $include_name_array = $matches[2];
-
- if (count($replace_this_array) === 0) {
- return $xml_string;
- }
-
- for ($i = 0; $i < count($replace_this_array); $i ++) {
-
- $replace_this = $replace_this_array[$i];
- $name = $include_name_array[$i];
-
- if (trim(strtolower($type_array[$i])) === 'field') {
- $model_name = 'xml:///Molajo//Model//Fields//' . $name . '.xml';
- $with_this = $this->resource->get($model_name);
- } else {
- $model_name = 'xml:///Molajo//Model//Include//' . $name . '.xml';
- $with_this = $this->resource->get($model_name);
- }
-
- $xml_string = str_replace($replace_this, $with_this, $xml_string);
- }
-
- return $xml_string;
- }
-
- /**
- * Define elements for Data Model to Registry
- *
- * @param string $model_registry
- * @param object $xml
- * @param string $plural
- * @param string $singular
- * @param string $valid_attributes
- *
- * @return bool
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function setElementsRegistry($model_registry, $xml, $plural, $singular, $valid_attributes)
- {
- if (isset($xml->table->$plural->$singular)) {
- } else {
- return true;
- }
-
- $set = $xml->table->$plural;
-
- $itemArray = array();
-
- if (count($set->$singular) > 0) {
-
- foreach ($set->$singular as $item) {
-
- $attributes = get_object_vars($item);
-
- $itemAttributes = ($attributes["@attributes"]);
- $itemAttributesArray = array();
-
- if (count($itemAttributes) > 0) {
-
- foreach ($itemAttributes as $key => $value) {
-
- if (in_array($key, $valid_attributes)) {
- } else {
- throw new RuntimeException(
- 'Configuration: setElementsRegistry encountered Invalid Model Attribute '
- . $key . ' for ' . $model_registry
- );
- }
-
- $itemAttributesArray[$key] = $value;
- }
- }
-
- if ($plural === 'plugins') {
- if (count($itemAttributesArray) > 0) {
- foreach ($itemAttributesArray as $plugin) {
- $itemArray[] = $plugin;
- }
- }
- } else {
- $itemArray[] = $itemAttributesArray;
- }
- }
- }
-
- if ($plural === 'joins') {
- $joins = array();
- $selects = array();
-
- for ($i = 0; $i < count($itemArray); $i ++) {
- $temp = $this->setJoinFields($itemArray[$i]);
- $joins[] = $temp[0];
- $selects[] = $temp[1];
- }
-
- $this->registry->set($model_registry, $plural, $joins);
-
- $this->registry->set($model_registry, 'JoinFields', $selects);
- } elseif ($plural === 'values') {
-
- $valuesArray = array();
-
- if (count($itemArray) > 0) {
-
- foreach ($itemArray as $value) {
-
- if (is_array($value)) {
- $temp_row = $value;
- } else {
- $valueVars = get_object_vars($value);
- $temp_row = ($valueVars["@attributes"]);
- }
-
- $temp = new stdClass();
-
- $temp->id = $temp_row['id'];
- $temp->value = $temp_row['value'];
-
- $valuesArray[] = $temp;
- }
-
- $this->registry->set($model_registry, 'values', $valuesArray);
- }
- } else {
- $this->registry->set($model_registry, $plural, $itemArray);
- }
-
- return true;
- }
-
- /**
- * Process join field definitions for registry
- *
- * @param array $modelJoinArray
- *
- * @return array
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function setJoinFields($modelJoinArray)
- {
- $joinArray = array();
- $joinSelectArray = array();
-
- $joinModel = ucfirst(strtolower($modelJoinArray['model']));
- $joinRegistry = $joinModel . 'Datasource';
-
- if ($this->registry->exists($joinRegistry) === false) {
- ;
- $this->resource->get('xml:///Molajo//Model//Datasource//' . $joinModel . '.xml');
- }
-
- $fields = $this->registry->get($joinRegistry, 'Fields');
-
- $table = $this->registry->get($joinRegistry, 'table_name');
-
- $joinArray['table_name'] = $table;
-
- $alias = (string)$modelJoinArray['alias'];
- if (trim($alias) === '') {
- $alias = substr($table, 3, strlen($table));
- }
- $joinArray['alias'] = trim($alias);
-
- $select = (string)$modelJoinArray['select'];
- $joinArray['select'] = $select;
-
- $selectArray = explode(',', $select);
-
- if ((int)count($selectArray) > 0) {
-
- foreach ($selectArray as $s) {
-
- foreach ($fields as $joinSelectArray) {
- if ($joinSelectArray['name'] === $s) {
- $joinSelectArray['as_name'] = trim($alias) . '_' . trim($s);
- $joinSelectArray['alias'] = $alias;
- $joinSelectArray['table_name'] = $table;
- }
- }
- }
- }
-
- $joinArray['jointo'] = (string)$modelJoinArray['jointo'];
- $joinArray['joinwith'] = (string)$modelJoinArray['joinwith'];
-
- return array($joinArray, $joinSelectArray);
- }
-
- /**
- * getCustomFields extracts field information for all customfield groups
- *
- * @param string $model_registry
- * @param object $xml
- *
- * @return object
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function getCustomFields($model_registry, $xml)
- {
- $customFieldsArray = array();
-
- if (count($xml->customfields->customfield) > 0) {
-
- foreach ($xml->customfields->customfield as $custom_field) {
-
- $name = (string)$custom_field['name'];
- $results = $this->getCustomFieldsSpecificGroup($model_registry, $custom_field);
- if ($results === false) {
- } else {
-
- $fieldArray = $results[0];
- $fieldNames = $results[1];
-
- $this->inheritCustomFieldsSpecificGroup(
- $model_registry,
- $name,
- $fieldArray,
- $fieldNames
- );
-
- $customFieldsArray[] = $name;
- }
- }
- }
-
- /** Include Inherited Groups not matching existing groups */
- $exists = $this->registry->exists($model_registry, 'Customfieldgroups');
-
- if ($exists === true) {
- $inherited = $this->registry->get($model_registry, 'Customfieldgroups');
-
- if (is_array($inherited) && count($inherited) > 0) {
- foreach ($inherited as $name) {
-
- if (in_array($name, $customFieldsArray)) {
- } else {
- $results = $this->inheritCustomFieldsSpecificGroup($model_registry, $name);
- if ($results === false) {
- } else {
- $customFieldsArray[] = $name;
- }
- }
- }
- }
- }
-
- $this->registry->set($model_registry, 'Customfieldgroups', array_unique($customFieldsArray));
-
- return;
- }
-
- /**
- * Load Custom Fields for a specific Group -- this is called once for each custom field type for a Model
- *
- * @param string $model_registry
- * @param $customfield
- *
- * @return array|bool
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function getCustomFieldsSpecificGroup($model_registry, $customfield)
- {
- $fieldArray = array();
- $fieldNames = array();
-
- if (count($customfield) > 0) {
-
- foreach ($customfield as $key1 => $value1) {
-
- $attributes = get_object_vars($value1);
- $fieldAttributes = ($attributes["@attributes"]);
- $fieldAttributesArray = array();
-
- if (count($fieldAttributes) > 0) {
- foreach ($fieldAttributes as $key2 => $value2) {
-
- if ($key2 === 'fieldset') {
- } elseif (in_array($key2, $this->dataobject->get('valid_field_attributes'))) {
- } else {
- throw new RuntimeException(
- 'Configuration: getCustomFieldsSpecificGroup Invalid Field attribute '
- . $key2 . ':' . $value2 . ' for ' . $model_registry
- );
- }
-
- if ($key2 === 'name') {
- } else {
- $fieldNames[] = $value2;
- }
-
- $fieldAttributesArray[$key2] = $value2;
- }
- }
-
- $fieldAttributesArray['field_inherited'] = 0;
-
- $fieldArray[] = $fieldAttributesArray;
- }
- }
-
- if (is_array($fieldArray) && count($fieldArray) > 0) {
- } else {
- return false;
- }
-
- return array($fieldArray, $fieldNames);
- }
-
- /**
- * Inherited fields are merged in with those specifically defined in model
- *
- * @param string $model_registry
- * @param $name
- * @param $fieldArray
- * @param $fieldNames
- *
- * @return array
- * @since 1.0
- */
- protected function inheritCustomFieldsSpecificGroup(
- $model_registry,
- $name,
- $fieldArray = array(),
- $fieldNames = array()
- ) {
- $available = $this->registry->get($model_registry, $name, array());
-
- if (count($available) > 0) {
-
- foreach ($available as $temp_row) {
-
- foreach ($temp_row as $field => $fieldvalue) {
-
- if ($field === 'name') {
-
- if (in_array($fieldvalue, $fieldNames)) {
- } else {
- $temp_row['field_inherited'] = 1;
- $fieldArray[] = $temp_row;
- $fieldNames[] = $fieldvalue;
- }
- }
- }
- }
- }
-
- if (is_array($fieldArray) && count($fieldArray) === 0) {
- $this->registry->set($model_registry, $name, array());
-
- return false;
- }
-
- $this->registry->set($model_registry, $name, $fieldArray);
-
- return $name;
- }
-
- /**
- * Inheritance checking and setup
- *
- * @param string $model_registry
- * @param $xml
- *
- * @return $this
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function inheritDefinition($model_registry, $xml)
- {
-//echo 'MODELREGISTRY ' . $model_registry . '
';
-//echo '';
-//var_dump($xml);
-
- $extends = false;
-
- if (count($xml->attributes()) > 0) {
- foreach ($xml->attributes() as $key => $value) {
- if ($key === 'extends') {
- $extends = (string)$value;
- }
- }
- }
- if ($extends === false) {
- return $this;
- }
-
- $modelArray = $this->dataobject->get('valid_model_types');
-
- $extends_model_name = '';
- $extends_model_type = '';
- if (count($modelArray) > 0) {
-
- foreach ($modelArray as $modeltype) {
- if (ucfirst(
- strtolower(substr($extends, strlen($extends) - strlen($modeltype), strlen($modeltype)))
- ) === $modeltype
- ) {
- $extends_model_name = ucfirst(
- strtolower(substr($extends, 0, strlen($extends) - strlen($modeltype)))
- );
- $extends_model_type = $modeltype;
- break;
- }
- }
- }
-
- if ($extends_model_name === '') {
- $extends_model_name = ucfirst(strtolower($extends));
- $extends_model_type = 'Datasource';
- }
-
- $inheritModelRegistry = $extends_model_name . $extends_model_type;
-
- if ($this->registry->exists($inheritModelRegistry) === true) {
- } else {
- if ($extends_model_type === 'Datasource') {
- $this->resource->get('xml:///Molajo//Model//Datasource//' . $extends_model_name . '.xml');
- } else {
- $this->resource->get('xml:///Molajo//' . $extends_model_name . '//Configuration.xml');
- }
- }
-
- $this->registry->copy($inheritModelRegistry, $model_registry);
-
- return $this;
- }
-}
diff --git a/Source/Configuration/Data.php b/Source/Configuration/Data.php
deleted file mode 100644
index 5732c8c..0000000
--- a/Source/Configuration/Data.php
+++ /dev/null
@@ -1,268 +0,0 @@
-valid_dataobject_types = $valid_dataobject_types;
- $this->valid_dataobject_attributes = $valid_dataobject_attributes;
- $this->valid_model_types = $valid_model_types;
- $this->valid_model_attributes = $valid_model_attributes;
- $this->valid_data_types = $valid_data_types;
- $this->valid_queryelements_attributes = $valid_queryelements_attributes;
- $this->valid_field_attributes = $valid_field_attributes;
- $this->valid_join_attributes = $valid_join_attributes;
- $this->valid_foreignkey_attributes = $valid_foreignkey_attributes;
- $this->valid_criteria_attributes = $valid_criteria_attributes;
- $this->valid_children_attributes = $valid_children_attributes;
- $this->valid_plugin_attributes = $valid_plugin_attributes;
- $this->valid_value_attributes = $valid_value_attributes;
- $this->valid_field_attributes_default = $valid_field_attributes_default;
- $this->valid_datalists = $valid_datalists;
- }
-
- /**
- * Set the value of a specified key
- *
- * @param string $key
- * @param mixed $value
- *
- * @return mixed
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function set($key, $value = null)
- {
- $key = strtolower($key);
-
- if (in_array($key, $this->property_array)) {
- } else {
- throw new RuntimeException('Configuration Data Object: Set invalid key: ' . $key);
- }
-
- $this->$key = $value;
-
- return;
- }
-
- /**
- * Get the current value (or default) of the specified key
- *
- * @param string $key
- * @param mixed $default
- *
- * @return mixed
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function get($key, $default = null)
- {
- $key = strtolower($key);
-
- if (in_array($key, $this->property_array)) {
- } else {
- throw new RuntimeException('Configuration Data Object: Set invalid key: ' . $key);
- }
-
- if ($this->$key === null) {
- $this->$key = $default;
- }
-
- return $this->$key;
- }
-}
diff --git a/Source/Configuration/Dataobject.php b/Source/Configuration/Dataobject.php
deleted file mode 100644
index f568047..0000000
--- a/Source/Configuration/Dataobject.php
+++ /dev/null
@@ -1,114 +0,0 @@
-getIncludeCode($xml);
- if ($xml === false) {
- throw new RuntimeException(
- 'Configuration: getDataobject cannot process XML file for Model Type: '
- . $model_type . ' Model Name: ' . $model_name
- );
- }
-
- if (isset($xml->model)) {
- $xml = $xml->model;
- }
-
- $this->registry->createRegistry($model_registry);
-
- $this->setModelRegistry($model_registry, $xml);
-
- $this->registry->sort($model_registry);
-
- return $this->registry->getArray($model_registry);
- }
-
- /**
- * Store Configuration Data in Registry
- *
- * @param string $model_registry
- * @param object $xml
- *
- * @return $this
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function setModelRegistry($model_registry, $xml)
- {
- $doArray = $this->dataobject->get('valid_dataobject_attributes');
-
- foreach ($xml->attributes() as $key => $value) {
- if (in_array((string)$key, $doArray)) {
- $this->registry->set($model_registry, $key, (string)$value);
- } else {
- throw new RuntimeException(
- 'Configuration: setDataobjectRegistry encountered Invalid Dataobject Attributes ' . $key
- );
- }
- }
-
- $this->registry->set($model_registry, 'data_object', 'Dataobject');
- $this->registry->set($model_registry, 'model_type', 'Dataobject');
- $this->registry->set(
- $model_registry,
- 'model_name',
- $this->registry->get($model_registry, 'name')
- );
-
- return $this;
- }
-}
diff --git a/Source/Configuration/Model.php b/Source/Configuration/Model.php
deleted file mode 100644
index 187e6de..0000000
--- a/Source/Configuration/Model.php
+++ /dev/null
@@ -1,201 +0,0 @@
-getIncludeCode($xml);
- if ($xml === false) {
- throw new RuntimeException(
- 'Configuration: getDataobject cannot process XML file for Model Type: '
- . $model_type . ' Model Name: ' . $model_name
- );
- }
-
- if (isset($xml->model)) {
- $xml = $xml->model;
- }
-
- $this->registry->createRegistry($model_registry);
-
- $this->inheritDefinition($model_registry, $xml);
-
- $this->setModelRegistry($model_registry, $xml);
-
- $this->registry->set($model_registry, 'model_name', $model_name);
- $this->registry->set($model_registry, 'model_type', $model_type);
- $this->registry->set($model_registry, 'model_registry_name', $model_registry);
-
- $data_object = $this->registry->get($model_registry, 'data_object', '');
-
- if ($data_object === '') {
- $data_object = 'Database';
- $this->registry->set($model_registry, 'data_object', $data_object);
- }
-
- $dataObjectRegistry = ucfirst(strtolower($data_object)) . 'Dataobject';
-
- if ($this->registry->exists($dataObjectRegistry)) {
- } else {
- $this->resource->get('xml:///Molajo//Model//Dataobject//' . ucfirst(strtolower($data_object)) . '.xml');
- }
-
- foreach ($this->registry->get($dataObjectRegistry) as $key => $value) {
- $this->registry->set($model_registry, 'data_object_' . $key, (string)$value);
- }
-
- $this->setElementsRegistry(
- $model_registry,
- $xml,
- 'fields',
- 'field',
- $this->dataobject->get('valid_field_attributes')
- );
-
- $this->setElementsRegistry(
- $model_registry,
- $xml,
- 'joins',
- 'join',
- $this->dataobject->get('valid_join_attributes')
- );
-
- $this->setElementsRegistry(
- $model_registry,
- $xml,
- 'foreignkeys',
- 'foreignkey',
- $this->dataobject->get('valid_foreignkey_attributes')
- );
-
- $this->setElementsRegistry(
- $model_registry,
- $xml,
- 'criteria',
- 'where',
- $this->dataobject->get('valid_criteria_attributes')
- );
-
- $this->setElementsRegistry(
- $model_registry,
- $xml,
- 'children',
- 'child',
- $this->dataobject->get('valid_children_attributes')
- );
-
- $this->setElementsRegistry(
- $model_registry,
- $xml,
- 'plugins',
- 'plugin',
- $this->dataobject->get('valid_plugin_attributes')
- );
-
- $this->setElementsRegistry(
- $model_registry,
- $xml,
- 'values',
- 'value',
- $this->dataobject->get('valid_value_attributes')
- );
-
- $this->getCustomFields($model_registry, $xml);
-
- return $this->registry->getArray($model_registry);
- }
-
- /**
- * Store Configuration Data in Registry
- *
- * @param string $model_registry
- * @param object $xml
- *
- * @return null|Model
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function setModelRegistry($model_registry, $xml)
- {
- $modelArray = $this->dataobject->get('valid_model_attributes');
-
- foreach ($xml->attributes() as $key => $value) {
-
- if (in_array($key, $modelArray)) {
- $this->registry->set($model_registry, $key, (string)$value);
- } else {
- echo '';
- var_dump($key);
-
- echo '';
- var_dump($xml);
-
- echo 'Going to throw Exception in ModelHandler setModelRegistry';
- die;
- throw new RuntimeException(
- 'Configuration: setModelRegistry encountered Invalid Model Attribute ' . $key
- );
- }
- }
-
- $this->registry->set(
- $model_registry,
- 'model_name',
- $this->registry->get($model_registry, 'name')
- );
-
- return $this;
- }
-}
diff --git a/Source/Configuration/Registry.php b/Source/Configuration/Registry.php
deleted file mode 100644
index 007aa95..0000000
--- a/Source/Configuration/Registry.php
+++ /dev/null
@@ -1,1010 +0,0 @@
-registry->exists('Namespace', 'Optional member');
- *
- * @param string $namespace
- * @param null|string $key (optional)
- *
- * @return bool
- * @since 1.0
- */
- public function exists($namespace, $key = null)
- {
- $namespace = $this->editNamespace($namespace);
-
- $namespaces = $this->registryKeys;
- if (is_array($namespaces)) {
- } else {
- return false;
- }
-
- if (in_array($namespace, $namespaces)) {
- } else {
- return false;
- }
-
- if ($key === null) {
- return true;
- }
-
- $thisNamespace = $this->registry[$namespace];
- if (count($thisNamespace) === 0) {
- return false;
- }
-
- $key = strtolower($key);
- if (isset($thisNamespace[$key])) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Lock registry from update.
- *
- * Usage:
- * $this->registry->lock('Namespace');
- *
- * @param string $namespace
- *
- * @return bool
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function lock($namespace)
- {
- $namespace = $this->editNamespace($namespace);
-
- if ($this->exists($namespace)) {
- } else {
- throw new RuntimeException(
- 'Registry: Namespace in Lock Request does not exist.'
- );
- }
-
- $this->registryLocks[$namespace] = true;
-
- return true;
- }
-
- /**
- * Check to see if a registry is locked
- *
- * Usage:
- * $this->registry->checkLock('Namespace');
- *
- * @param string $namespace
- *
- * @return bool true - lock is on
- * false - there is no lock (and possibly no registry, either)
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function checkLock($namespace)
- {
- $namespace = $this->editNamespace($namespace);
- if ($this->exists($namespace)) {
- } else {
- return false;
- }
-
- if (isset($this->registryLocks[$namespace])) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Create a registry for the specified namespace
- *
- * Notes:
- * - All namespaces are set to lowercase to remove case sensitivity
- * - Throws exception if Registry Namespace is reserved
- * - Returns Namespace if already existing (use 'exists' if verification is needed prior to createRegistry)
- * - Called automatically when needed by a Set Request
- *
- * Usage:
- * $this->registry->createRegistry('Name Space');
- *
- * @param string $namespace
- *
- * @return mixed|bool|array
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function createRegistry($namespace)
- {
- $namespace = $this->editNamespace($namespace);
-
- if ($this->exists($namespace)) {
-
- if (isset($this->registryKeys[$namespace])) {
- throw new RuntimeException(
- 'Registry: Cannot create Namespace ' . $namespace . ' because it already exists.'
- );
- } else {
- return $this->registry[$namespace];
- }
- }
-
- if ($namespace === 'db' || $namespace === '*') {
- throw new RuntimeException(
- 'Registry: Namespace ' . $namespace . ' is a reserved word.'
- );
- }
-
- if (isset($this->registryKeys[$namespace])) {
- return $this->registry[$namespace];
- }
-
- $this->registryKeys[] = $namespace;
-
- $this->registry[$namespace] = array();
-
- /** Returns new registry */
- return $this->registry[$namespace];
- }
-
- /**
- * Returns Registry Data
- *
- * Notes:
- * - Creates registry member using default if not existing and default provided
- * - Creates registry if not existing (whether or not a member was created)
- *
- * Usage:
- * $this->registry->get('Name Space', 'key value');
- *
- * List names of existing registry namespaces:
- * echo $this->registry->get('*');
- *
- * ... include a formatted dump of namespace contents
- * echo $this->registry->get('*', '*');
- *
- * List all entries in the specified registry namespace
- * $array = $this->registry->get('Name space');
- *
- * List only those namespace entries beginning with the wildcard value:
- * echo $this->registry->get('Name space', 'theme*');
- *
- * @param string $namespace
- * @param string $key
- * @param mixed $default
- *
- * @return array|bool|mixed
- * @since 1.0
- */
- public function get($namespace = null, $key = null, $default = null)
- {
- $namespace = $this->editNamespace($namespace);
- $key = $this->editNamespaceKey($namespace, $key);
-
- if ($this->exists($namespace) === true) {
- } else {
- if ($namespace === '*') {
- } else {
- return false;
- }
- }
-
- if ($namespace === '*') {
- if ($key === null) {
- return $this->listRegistry(false);
- } else {
- return $this->listRegistry(true);
- }
- } elseif ($key === null) {
- return $this->getRegistry($namespace);
- } elseif ($key === '*' || strrpos($key, '*')) {
- $sort = $this->getRegistry($namespace);
-
- if ($key === '*') {
- $selected = $sort;
- } else {
- //@todo - combine all the wildcard logic
- if (substr($key, 0, 1) === '*') {
- $selected = array();
- $searchfor = substr($key, 1, (strrpos($key, '*') - 1));
- foreach ($sort as $key => $value) {
- if ($key === $searchfor) {
- $match = true;
- } else {
- $match = strpos($key, $searchfor);
- }
- if ($match) {
- $selected[$key] = $value;
- }
- }
- } else {
- $selected = array();
-
- $searchfor = substr($key, 0, strrpos($key, '*'));
-
- foreach ($sort as $key => $value) {
- $match = substr($key, 0, strlen($searchfor));
- if (strtolower($match) === strtolower($searchfor)) {
- $selected[$key] = $value;
- }
- }
- }
- }
-
- if ($key === '*') {
- echo '';
- var_dump($selected);
- echo '
';
- } else {
- return $selected;
- }
-
- return true;
- }
-
- if (in_array($namespace, $this->registryKeys)) {
- $array = $this->registry[$namespace];
- $namespace_exists = true;
- } else {
- $array = array();
- $namespace_exists = false;
- }
-
- /** Existing named pair returned */
- if (isset($array[$key])) {
- return $array[$key];
- }
-
- /** Not found and no create member requested */
- if ($default === null) {
- return false;
- }
-
- /** Create Registry and Member if needed and member default provided */
- if ($namespace_exists) {
- } else {
- $this->createRegistry($namespace);
- }
-
- $array[$key] = $default;
- $this->registry[$namespace] = $array;
-
- return $array[$key];
- }
-
- /**
- * Sets the value for a specific namespace item
- *
- * Usage:
- * $this->registry->set('Name Space', 'key_name', $value);
- *
- * @param string $namespace
- * @param string $key
- * @param mixed $value
- * @param boolean $match - used as a security precaution to ensure only named parameters
- * are updated via statement overrides
- *
- * @return void|bool|Registry
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function set($namespace, $key, $value = null, $match = false)
- {
- $namespace = $this->editNamespace($namespace);
-
- if ($this->checkLock($namespace)) {
- throw new RuntimeException(
- 'Registry: Namespace is locked. Updates are not allowed.'
- );
- }
-
- $key = $this->editNamespaceKey($namespace, $key);
-
- if ($namespace === '') {
- throw new RuntimeException(
- 'Registry: Namespace is required for Set.'
- );
- }
-
- if ($key === '') {
- throw new RuntimeException(
- 'Registry: Key is required for Set. Namespace: ' . $namespace
- );
- }
-
- /** Match requirement for security to ensure only named parameters are updated */
- if ($match === true) {
- $exists = $this->exists($namespace, $key);
- if ($exists === false) {
- return false;
- }
- }
-
- $array = $this->getRegistry($namespace);
-
- $array[$key] = $value;
-
- $this->registry[$namespace] = $array;
-
- return $this;
- }
-
- /**
- * Copy key values from one namespace registry into another, overwriting existing values
- *
- * Note:
- * If target_registry already exists, source_registry values replace existing values for matching keys
- * Key pairs on target registry remain unchanged if there are no matching pairs. Use Delete first, if desired.
- * Use merge when target registry values should remain -- not be overwritten.
- *
- * Usage:
- * $this->registry->copy('namespace-x', 'to-namespace-y');
- *
- * To copy only certain values:
- * $this->registry->copy('namespace-x', 'to-namespace-y', 'wildcard*');
- *
- * @param string $source_registry
- * @param string $target_registry
- * @param null $filter
- *
- * @return Registry
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function copy($source_registry, $target_registry, $filter = null)
- {
- $source_registry = $this->editNamespace($source_registry);
- $target_registry = $this->editNamespace($target_registry);
-
- if ($this->checkLock($target_registry)) {
- throw new RuntimeException(
- 'Registry: Target Namespace: ' . $target_registry . ' is locked. May not copy into it.'
- );
- }
-
- if ($this->exists($source_registry)) {
- } else {
- throw new RuntimeException
- (
- 'Registry: Namespace ' . $source_registry . ' requested as source of copy does not exist.'
- );
- }
-
- $copy = $this->getRegistry($source_registry);
-
- if ($filter === null || $filter === '*') {
- if (count($copy) > 0) {
- foreach ($copy as $key => $value) {
- $this->set($target_registry, $key, $value);
- }
- }
-
- return $this;
- }
-
- if (strpos($filter, '*')) {
- $searchfor = substr($filter, 0, strrpos($filter, '*'));
- $exactMatch = false;
- } else {
- $searchfor = $filter;
- $exactMatch = true;
- }
-
- if (count($copy) > 0) {
-
- foreach ($copy as $key => $value) {
- $use = false;
- $test = substr($key, 0, strlen($searchfor));
- if (strtolower($test) === strtolower($searchfor)) {
- if ($exactMatch === true) {
- if (strtolower($key) === strtolower($searchfor)) {
- $use = true;
- }
- } else {
- $use = true;
- }
- }
- if ($use === true) {
- $this->set($target_registry, $key, $value);
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Merge one Namespace into another.
- *
- * - When keys match, target value is retained
- * - When key does not exist on the target, it is copied in
- * In either of the above cases, when "remove_from_source" is 1, the source entry is removed
- * - If no entries remain in the source after the merge, the registry is removed, too
- *
- * Usage:
- * $this->registry->merge('namespace-x', 'to-namespace-y');
- *
- * Merge a subset of source using wildcard:
- * $this->registry->merge('namespace-x', 'to-namespace-y', 'Only These*');
- *
- * Merge a subset of source using wildcard, and then delete the source merged in:
- * $this->registry->merge('namespace-x', 'to-namespace-y', 'Only These*', 1);
- *
- * @param string $source_registry
- * @param string $target_registry
- * @param bool $filter - merge for matching keys
- * @param int $remove_from_source
- *
- * @return array|bool
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function merge($source_registry, $target_registry, $filter = false, $remove_from_source = 0)
- {
- $source_registry = $this->editNamespace($source_registry);
- $target_registry = $this->editNamespace($target_registry);
-
- if ($this->exists($source_registry)) {
- } else {
- throw new RuntimeException
- (
- 'Registry: Namespace ' . $source_registry . ' requested as a source for merging does not exist.'
- );
- }
-
- if ($this->exists($target_registry)) {
- } else {
- throw new RuntimeException
- (
- 'Registry: Namespace ' . $target_registry . ' does not exist, was requested as target of merge.'
- );
- }
-
- if ($remove_from_source === 1) {
- if ($this->checkLock($source_registry)) {
- throw new RuntimeException
- (
- 'Registry: Source Namespace: ' . $target_registry . ' for Merge is locked. May not remove entries.'
- );
- }
- }
-
- $target_registry = $this->editNamespace($target_registry);
- if ($this->checkLock($target_registry)) {
- throw new RuntimeException
- (
- 'Registry: Target Namespace: ' . $target_registry . ' for Merge is locked. May not add entries.'
- );
- }
-
- $searchfor = '';
- if ($filter === null || trim($filter) === '' || $filter === '*') {
- } else {
- $searchfor = substr($filter, 0, strrpos($filter, '*'));
- $searchfor = strtolower(trim($searchfor));
- }
-
- $target = $this->getRegistry($target_registry);
- $source = $this->getRegistry($source_registry);
- foreach ($source as $key => $value) {
-
- $match = 0;
-
- if (is_null($value)) {
- //skip it.
- } elseif ($searchfor === '') {
- $match = 1;
- } elseif (trim(substr(strtolower($key), 0, strlen(strtolower($searchfor)))) === trim($searchfor)) {
- $match = 1;
- }
-
- if ($match === 1) {
- if (isset($target[$key])) {
- if ($target[$key] === null) {
- $this->set($target_registry, $key, $value);
- }
- } else {
- $this->set($target_registry, $key, $value);
- }
- }
-
- if ($remove_from_source === 1) {
- $this->delete($source_registry, $key);
- }
- }
-
- if (count($this->getRegistry($source_registry)) > 0) {
- } else {
- return $this->deleteRegistry($source_registry);
- }
-
- return true;
- }
-
- /**
- * Sort Namespace
- *
- * Usage:
- * $this->registry->sort('namespace');
- *
- * @param string $namespace
- *
- * @return Registry
- * @throws \CommonApi\Exception\RuntimeException
- * @since 1.0
- */
- public function sort($namespace)
- {
- $namespace = $this->editNamespace($namespace);
-
- if ($this->exists($namespace)) {
- } else {
- throw new RuntimeException
- (
- 'Registry: Cannot sort Namespace ' . $namespace . ' since it does not exist.'
- );
- }
-
- $sort = $this->getRegistry($namespace);
- ksort($sort);
- $this->registry[$namespace] = $sort;
-
- return $this;
- }
-
- /**
- * Deletes a registry or registry entry
- *
- * Usage:
- * $this->registry->delete('Name Space', 'key_name');
- *
- * @param string $namespace
- * @param string $key
- *
- * @return Registry
- * @return Registry
- * @throws \CommonApi\Exception\RuntimeException
- * @since 1.0
- */
- public function delete($namespace, $key = null)
- {
- $namespace = $this->editNamespace($namespace);
-
- if ($this->exists($namespace)) {
- } else {
- return $this;
- }
-
- if ($this->checkLock($namespace)) {
- throw new RuntimeException
- (
- 'Registry: Cannot delete an entry from Namespace: ' . $namespace . ' since it has been locked.'
- );
- }
-
- $key = strtolower($key);
- if ($key === '') {
- return $this->deleteRegistry($namespace);
- }
-
- $searchfor = '';
- if ($key === null || trim($key) === '' || $key === '*') {
- } else {
- $searchfor = substr($key, 0, strrpos($key, '*'));
- $searchfor = strtolower(trim($searchfor));
- }
-
- $copy = $this->getRegistry($namespace);
- if (count($copy) > 0) {
- } else {
- return $this; //nothing to delete
- }
-
- $new = array();
- foreach ($copy as $key => $value) {
-
- $match = 0;
-
- if ($searchfor === '') {
- $match = 1;
- } elseif (trim(substr(strtolower($key), 0, strlen(strtolower($searchfor)))) === trim($searchfor)) {
- $match = 1;
- }
-
- if ($match === 1) {
- } else {
- $new[$key] = $value;
- }
- }
-
- $this->deleteRegistry($namespace);
-
- if (count($new) > 0) {
- } else {
- return $this;
- }
-
- $this->createRegistry($namespace);
- $this->registry[$namespace] = $new;
-
- return $this;
- }
-
- /**
- * Rename a namespace (deletes existing, creates new)
- *
- * Usage:
- * $this->registry->rename($namespace);
- *
- * @param $namespace
- * @param $new_namespace
- *
- * @return $this
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function rename($namespace, $new_namespace)
- {
- $namespace = $this->editNamespace($namespace);
-
- if ($this->exists($namespace)) {
- } else {
- throw new RuntimeException
- (
- 'Registry: Cannot rename Namespace ' . $namespace . ' since it does not exist.'
- );
- }
-
- if ($this->checkLock($namespace)) {
- throw new RuntimeException
- (
- 'Registry: Cannot rename Namespace: ' . $namespace . ' since it has been locked.'
- );
- }
-
- if ($this->exists($new_namespace)) {
- } else {
- throw new RuntimeException
- (
- 'Registry: Cannot rename ' . $namespace . ' to an existing registry ' . $new_namespace
- );
- }
-
- $existing = $this->getRegistry($namespace);
- ksort($existing);
- $this->deleteRegistry($namespace);
- $this->createRegistry($new_namespace);
- $this->registry[$new_namespace] = $existing;
-
- return $this;
- }
-
- /**
- * Returns an array containing key and name pairs for a namespace registry
- *
- * Usage:
- * $this->registry->getArray('Name Space');
- *
- * To retrieve only the key field names, not the values:
- * $this->registry->getArray('Name Space', true);
- *
- * @param string $namespace
- * @param boolean $key_only set to true to retrieve key names
- *
- * @return array
- * @since 1.0
- */
- public function getArray($namespace, $key_only = false)
- {
- $namespace = $this->editNamespace($namespace);
-
- if ($this->exists($namespace)) {
- } else {
- return array();
- }
-
- $array = $this->getRegistry($namespace);
-
- if ($key_only === false) {
- return $array;
- }
-
- $keyArray = array();
- foreach ($array as $key => $value) {
- $keyArray[] = $key;
- }
-
- return $keyArray;
- }
-
- /**
- * Populates a registry with an array of key and name pairs
- *
- * Usage:
- * $this->registry->loadArray('Namespace', $array);
- *
- * @param string $namespace name of registry to use or create
- * @param array $array key and value pairs to load
- *
- * @return Registry
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function loadArray($namespace, $array = array())
- {
- if (is_array($array) && count($array) > 0) {
- } else {
- throw new RuntimeException
- (
- 'Registry: Empty or missing input array provided to loadArray.'
- );
- }
-
- $namespace = $this->editNamespace($namespace);
-
- //if ($this->exists($namespace)) {
- // throw new RuntimeException
- // ('Registry: Namespace ' . $namespace . ' already exists. Cannot use existing namespace with loadArray.');
- // }
-
- $this->getRegistry($namespace);
-
- $this->registry[$namespace] = $array;
-
- return $this;
- }
-
- /**
- * Retrieves a list of ALL namespace registries and optionally keys/values
- *
- * Usage:
- * $this->registry->listRegistry();
- *
- * @param boolean $expand true - returns the entire list and each registry
- * false - returns a list of registry names, only
- *
- * @return mixed|boolean or array
- * @since 1.0
- */
- public function listRegistry($expand = false)
- {
- if ($expand === false) {
- echo '';
- var_dump($this->registryKeys);
- echo '
';
-
- return;
- }
-
- echo '';
- var_dump($this->registry);
- echo '
';
-
- return;
- }
-
- /**
- * getData - returns Registry (comes from $model_name) as Query Results (array of objects)
- *
- * Data can be requested as a result - provide $registry, $element and true for $single result
- *
- * Use '*' in the key to retrieve all values starting with a specific phrase (ex. 'model')
- *
- * @param string $registry Name of registry, for the MVC this is the $model_name
- * @param null|string $key Key of the named pair
- * @param null|string $query_object Result, Item, or List
- *
- * @return array|bool|mixed
- * @since 1.0
- */
- public function getData($registry, $key = null, $query_object = null)
- {
- $registry = strtolower($registry);
-
- $key = strtolower($key);
- $query_results = array();
-
- if ($key === null || $key === '*') {
- $results = $this->get($registry);
- } elseif ($query_object === 'result') {
- return $this->get($registry, $key);
- } else {
- $results = $this->get($registry, $key);
- }
-
- if (is_array($results)) {
- if (isset($results[0])) {
- if (is_object($results[0])) {
- return $results;
- }
- }
- }
-
- $temp_row = new \stdClass();
- if (count($results) > 0) {
- foreach ($results as $key => $value) {
- $temp_row->$key = $value;
- }
- }
- $query_results[] = $temp_row;
-
- return $query_results;
- }
-
- /**
- * Returns the registry as an array for the specified namespace
- *
- * This is a private method used within the registry class, use get to retrieve Registry
- *
- * $this->registry->get('Name Space');
- *
- * @param string $namespace
- *
- * @return array
- * @since 1.0
- */
- protected function getRegistry($namespace)
- {
- $namespace = $this->editNamespace($namespace);
-
- if ($this->exists($namespace)) {
- } else {
- $this->createRegistry($namespace);
- }
-
- return $this->registry[$namespace];
- }
-
- /**
- * Delete a Registry for specified Namespace
- *
- * @param string $namespace
- *
- * @return Registry
- * @since 1.0
- */
- protected function deleteRegistry($namespace)
- {
- $namespace = $this->editNamespace($namespace);
-
- if ($this->exists($namespace)) {
- } else {
- return $this;
- }
-
- $namespace = strtolower($namespace);
-
- $existing = $this->registryKeys;
- $keep = array();
- $deleted = false;
- foreach ($existing as $key => $value) {
-
- if ($value === $namespace) {
- $deleted = true;
- } else {
- $keep[] = $value;
- }
- }
-
- if ($deleted === false) {
- return $this;
- }
-
- sort($keep);
-
- $tempRegistry = $this->registry;
-
- $this->registry = array();
- $this->registryKeys = array();
-
- foreach ($keep as $key => $value) {
- $this->registryKeys[] = $value;
- $this->registry[$value] = $tempRegistry[$value];
- }
-
- return $this;
- }
-
- /**
- * Used internally for data validation of namespace element
- *
- * @param string $namespace
- *
- * @return string
- * @throws \CommonApi\Exception\RuntimeException
- */
- private function editNamespace($namespace)
- {
- if ($namespace === null) {
- $namespace = '*';
- } elseif (is_string($namespace) || is_numeric($namespace)) {
- $namespace = strtolower($namespace);
- $namespace = trim($namespace);
- } else {
- throw new RuntimeException
- (
- 'Registry: Namespace: is not a string.'
- );
- }
-
- return $namespace;
- }
-
- /**
- * Used internally for data validation of namespace key element
- *
- * @param string $namespace
- * @param string $key
- *
- * @return string
- * @throws \CommonApi\Exception\RuntimeException
- */
- private function editNamespaceKey($namespace, $key = null)
- {
- if ($key === null) {
- } elseif (is_string($key) || is_numeric($key)) {
- $key = strtolower($key);
- $key = trim($key);
- } else {
- echo '';
- var_dump($key);
- echo '
';
- throw new RuntimeException
- (
- 'Registry: Key associated with Namespace: ' . $namespace . ' is not a string.'
- );
- }
-
- return $key;
- }
-}
diff --git a/Source/Driver.php b/Source/Driver.php
deleted file mode 100644
index f87530a..0000000
--- a/Source/Driver.php
+++ /dev/null
@@ -1,433 +0,0 @@
-scheme = $scheme;
- $this->adapter_instance_array = array();
-
- foreach ($adapter_instance_array as $key => $value) {
- $this->setAdapterInstance($key, $value);
- }
-
- $this->register();
- }
-
- /**
- * Map a namespace prefix to a filesystem path
- *
- * @param string $namespace_prefix
- * @param string $base_directory
- * @param boolean $prepend
- *
- * @return $this
- * @since 1.0
- */
- public function setNamespace($namespace_prefix, $base_directory, $prepend = true)
- {
- foreach ($this->adapter_instance_array as $key => $value) {
- $this->adapter_instance_array[$key]->setNamespace(
- $namespace_prefix,
- $base_directory,
- $prepend
- );
- }
-
- return $this;
- }
-
- /**
- * Pass in the Adapter Instance for a Scheme Adapter
- * => For class construction or adding a new scheme/adapter after instantiation
- *
- * @param string $adapter
- * @param object $adapter_instance
- *
- * @return $this
- * @since 1.0
- */
- public function setAdapterInstance($adapter = 'File', $adapter_instance)
- {
- if ($adapter_instance instanceof AdapterInterface) {
- $this->adapter_instance_array[$adapter] = $adapter_instance;
- }
-
- return $this;
- }
-
- /**
- * Registers Class Autoloader
- *
- * @param boolean $prepend
- *
- * @return $this
- * @since 1.0
- */
- public function register($prepend = true)
- {
- spl_autoload_register(array($this, 'locateNamespace'), true, $prepend);
-
- return $this;
- }
-
- /**
- * Unregister Class Autoloader
- *
- * @return $this
- * @since 1.0
- */
- public function unregister()
- {
- spl_autoload_unregister(array($this, 'locateNamespace'));
-
- return $this;
- }
-
- /**
- * Get Scheme (or all schemes)
- *
- * @param string $scheme
- *
- * @return object|array
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function getScheme($scheme = '')
- {
- if ($scheme == '') {
- return $this->scheme->getScheme();
- }
-
- $scheme = ucfirst(strtolower($scheme));
-
- $this->scheme_value = $scheme;
-
- $this->scheme_properties = $this->scheme->getScheme($this->scheme_value);
-
- if ($this->scheme_properties === false) {
- throw new RuntimeException('Resource getScheme Scheme not found: ' . $this->scheme_value);
- }
-
- $this->adapter_value = $this->scheme_properties->adapter;
-
- if (isset($this->adapter_instance_array[$this->adapter_value])) {
- } else {
- echo 'in Resource Adapter ' . $this->adapter_value . '
';
- echo '';
- foreach ($this->adapter_instance_array as $key => $value) {
- echo $key . '
';
- }
- die;
- var_dump($this->adapter_instance_array);
- echo '';
- throw new RuntimeException('Resource getScheme Adapter not found: ' . $this->adapter_value);
- }
-
- return $this->scheme_properties;
- }
-
- /**
- * Define Scheme, associated Adapter and allowable file extensions (empty array means any extension allowed)
- *
- * @param string $scheme_name
- * @param string $adapter
- * @param array $extensions
- * @param bool $replace
- *
- * @return $this
- * @since 1.0
- */
- public function setScheme($scheme_name, $adapter = 'File', array $extensions = array(), $replace = false)
- {
- $this->scheme->setScheme($scheme_name, $adapter, $extensions, $replace);
-
- return $this;
- }
-
- /**
- * Verify if the resource namespace has been defined or not
- *
- * @param string $uri_namespace
- *
- * @return boolean
- * @since 1.0
- */
- public function exists($uri_namespace)
- {
- try {
- $this->parseUri($uri_namespace);
- $this->scheme_value = 'file';
- $this->getScheme($this->scheme_value);
-
- $located_path = $this->adapter_instance_array[$this->adapter_value]->get($uri_namespace);
- if ($located_path === false) {
- return false;
- }
-
- return true;
- } catch (Exception $e) {
- return false;
- }
- }
-
- /**
- * Locates folder/file associated with URI Namespace for Resource
- *
- * @param string $uri_namespace
- * @param array $options
- *
- * @return void|mixed
- * @since 1.0
- */
- public function get($uri_namespace, array $options = array())
- {
- $this->parseUri($uri_namespace);
-
- return $this->locateNamespace(str_replace('\\', '/', $this->path), $this->scheme_value, $options);
- }
-
- /**
- * Locates a resource using only the namespace
- *
- * @param string $namespace
- * @param string $scheme
- * @param array $options
- *
- * @return void|mixed
- * @since 1.0
- */
- public function locateNamespace($namespace, $scheme = 'ClassLoader', array $options = array())
- {
- $this->getScheme($scheme);
-
- $multiple = false;
-
- if (isset($options['multiple']) && $options['multiple'] === true) {
- $multiple = true;
- }
-
- $located_path = $this->adapter_instance_array[$this->adapter_value]->get($namespace, $multiple);
-
- $options['namespace'] = $namespace;
-
- return $this->handlePath($this->scheme_value, $located_path, $options);
- }
-
- /**
- * Handle located folder/file associated with URI Namespace for Resource
- *
- * @param string $scheme_value
- * @param string $located_path
- * @param array $options
- *
- * @return void|mixed
- * @since 1.0
- */
- public function handlePath($scheme_value, $located_path, array $options = array())
- {
- $this->getScheme($scheme_value);
-
- if (strtolower($scheme_value) == 'query') {
- $xml = $this->adapter_instance_array['Xml']->handlePath(
- $scheme_value,
- $located_path,
- $options
- );
- $options['xml'] = $xml;
-
- $this->adapter_value = 'Query';
- }
-
- return $this->adapter_instance_array[$this->adapter_value]->handlePath($scheme_value, $located_path, $options);
- }
-
- /**
- * Retrieve a collection of a specific adapter
- *
- * @param string $scheme_value
- * @param array $options
- *
- * @return mixed
- * @since 1.0
- */
- public function getCollection($scheme_value, array $options = array())
- {
- $this->getScheme($scheme_value);
-
- return $this->adapter_instance_array[$this->adapter_value]->getCollection($scheme_value, $options);
- }
-
- /**
- * Parse the URL
- *
- * @param string $uri
- *
- * @return $this
- * @since 1.0
- */
- protected function parseUri($uri)
- {
- $scheme = parse_url($uri, PHP_URL_SCHEME);
-
- if ($scheme === false) {
- if (strpos($uri, ':///') === false) {
- } else {
- $scheme = substr($uri, 0, strpos($uri, ':///'));
- $uri = substr($uri, strpos($uri, ':///') + 4, 9999);
- }
- }
-
- if ($scheme === false) {
- if (strpos($uri, ':/') === false) {
- } else {
- $scheme = substr($uri, 0, strpos($uri, ':/'));
- $uri = substr($uri, strpos($uri, ':/') + 2, 9999);
- }
- }
-
- $this->getScheme($scheme);
-
- $this->host = parse_url($uri, PHP_URL_HOST);
- $this->user = parse_url($uri, PHP_URL_USER);
- $this->password = parse_url($uri, PHP_URL_PASS);
- $this->path = parse_url($uri, PHP_URL_PATH);
- $this->query = array();
- $query = parse_url($uri, PHP_URL_QUERY);
- if ($query === null || $query === false) {
- $query = '';
- }
- $temp = explode(',', $query);
- if (count($temp) > 0) {
- foreach ($temp as $item) {
- $pair = explode('=', $item);
- if (count($pair) == 2) {
- $this->query[$pair[0]] = $pair[1];
- }
- }
- }
- $this->fragment = parse_url($uri, PHP_URL_FRAGMENT);
-
- return $this;
- }
-}
diff --git a/Source/ExtensionMap.php b/Source/ExtensionMap.php
deleted file mode 100644
index 82f76fe..0000000
--- a/Source/ExtensionMap.php
+++ /dev/null
@@ -1,555 +0,0 @@
-resource = $resource;
- $this->runtime_data = $runtime_data;
- $this->extensions_filename = $extensions_filename;
- }
-
- /**
- * Catalog Types
- *
- * @return stdClass
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function createMap()
- {
- $map = $this->getCatalogTypes();
-
- if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
- $x = json_encode($map, JSON_PRETTY_PRINT);
- } else {
- $x = json_encode($map);
- }
-
- file_put_contents($this->extensions_filename, $x);
-
- return $map;
- }
-
- /**
- * Get Catalog Types
- *
- * @return stdClass
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function getCatalogTypes()
- {
- $catalog_types = $this->resource->get(
- 'query:///Molajo//Model//Datasource//CatalogTypes.xml',
- array('Parameters' => $this->runtime_data)
- );
-
- $catalog_types->setModelRegistry('check_view_level_access', 0);
- $catalog_types->setModelRegistry('process_events', 0);
- $catalog_types->setModelRegistry('query_object', 'list');
- $catalog_types->setModelRegistry('use_pagination', 0);
- $catalog_types->setModelRegistry('process_events', 0);
-
- $prefix = $catalog_types->getModelRegistry('prefix', 'a');
-
- try {
- $catalog_types->select('*');
- $catalog_types->from('#__catalog_types', 'a');
- $catalog_types->where(
- 'column',
- $prefix . '.id',
- 'IN',
- 'integer',
- (int)$this->runtime_data->reference_data->catalog_type_plugin_id . ', '
- . (int)$this->runtime_data->reference_data->catalog_type_theme_id . ', '
- . (int)$this->runtime_data->reference_data->catalog_type_page_view_id . ', '
- . (int)$this->runtime_data->reference_data->catalog_type_template_view_id . ', '
- . (int)$this->runtime_data->reference_data->catalog_type_wrap_view_id . ', '
- . (int)$this->runtime_data->reference_data->catalog_type_menuitem_id . ', '
- . (int)$this->runtime_data->reference_data->catalog_type_resource_id,
- 'OR'
- );
- $catalog_types->where(
- 'column',
- $prefix . '.model_type',
- '=',
- 'string',
- 'Resource',
- 'OR'
- );
-
- $results = $catalog_types->getData();
- } catch (Exception $e) {
- throw new RuntimeException(
- 'ExtensionMap:getCatalogTypes Query Failed' . $e->getMessage()
- );
- }
-
- $names = array();
- $ids = array();
- $model_names = array();
- $extensions = array();
-
- foreach ($results as $catalog_item) {
-
- $ids[$catalog_item->id] = $catalog_item->title;
- $names[$catalog_item->title] = $catalog_item->id;
- $model_names[$catalog_item->id] = $catalog_item->model_name;
-
- $id = $catalog_item->id;
- $model = $model_names[$id];
-
- $extensions[$id] = $this->getCatalogExtensions($id, $model, $catalog_item->model_type);
- }
-
- unset($catalog_types);
-
- $catalog_type = new stdClass();
- $catalog_type->ids = $ids;
- $catalog_type->names = $names;
- $catalog_type->extensions = $extensions;
-
- return $catalog_type;
- }
-
- /**
- * Retrieve Extensions for a specific Catalog Type
- *
- * @param int $catalog_type_id
- * @param string $catalog_type_model_name
- * @param string $model_type
- *
- * @return array|stdClass
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function getCatalogExtensions($catalog_type_id, $catalog_type_model_name, $model_type)
- {
- $items = $this->getCatalogSystemExtensions($catalog_type_id);
-
- if (is_array($items) && count($items) > 0) {
- } else {
- return array();
- }
-
- $ids = array();
- $names = array();
- $extensions = array();
- $menus = array();
- $pagetypes = array();
-
- foreach ($items as $item) {
-
- if ($catalog_type_id == $this->runtime_data->reference_data->catalog_type_menuitem_id) {
-
- $menus[] = $item->menu;
-
- if ($item->path === '') {
- $name = $item->alias;
- } else {
- $name = $item->path . '/' . $item->alias;
- }
-
- $pagetypes[$item->id] = $item->page_type;
- } else {
- $name = $item->alias;
- }
-
- $ids[$item->id] = $name;
-
- $names[$name] = $item->id;
- }
-
- $x = array_unique($menus);
- $menus = $x;
- ksort($ids);
-
- $catalog_type_model_name = ucfirst(strtolower($catalog_type_model_name));
-
- if ($catalog_type_model_name === 'Views//pages') {
- $catalog_type_model_name = 'Views//Pages';
- } elseif ($catalog_type_model_name === 'Views//templates') {
- $catalog_type_model_name = 'Views//Templates';
- } elseif ($catalog_type_model_name === 'Views//wraps') {
- $catalog_type_model_name = 'Views//Wraps';
- }
-
- foreach ($ids as $id => $alias) {
- $alias = ucfirst(strtolower($alias));
-
- if ($catalog_type_model_name === 'Resources' || $catalog_type_model_name === 'System') {
-
- $model_name = 'Molajo//' . $alias . '//Extension.xml';
- $resource_indicator = true;
-
- if ($alias === 'Groups') {
- $extensions[$id] = array();
- } else {
- $extensions[$id] = $this->getExtension($id, $model_name, $resource_indicator);
- }
- } else {
-
- if ($catalog_type_id == $this->runtime_data->reference_data->catalog_type_menuitem_id) {
- $pagetype = $pagetypes[$id];
- $pagetype = ucfirst(strtolower($pagetype));
- $model_name = 'Molajo//Model//Menuitem//' . $pagetype . '//Configuration.xml';
- } else {
- $model_name = 'Molajo//' . $catalog_type_model_name . '//' . $alias . '//Configuration.xml';
- }
-
- $resource_indicator = false;
-
- $extensions[$id] = $this->getExtension($id, $model_name, $resource_indicator);
- }
- }
-
- $temp = new stdClass();
- $temp->ids = $ids;
- $temp->names = $names;
- $temp->extensions = $extensions;
- $temp->menus = $menus;
-
- return $temp;
- }
-
- /**
- * Retrieve Resource Extensions for a specific Catalog Type
- *
- * @param int $catalog_type_id
- *
- * @return array|stdClass
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function getCatalogResourceExtensions($catalog_type_id)
- {
- $extensions_controller
- = $this->resource->get(
- 'query:///Molajo//Model//Datasource//ExtensionInstances.xml',
- array('Runtimedata' => $this->runtime_data)
- );
-
- $extensions_controller->setModelRegistry('check_view_level_access', 0);
- $extensions_controller->setModelRegistry('process_events', 0);
- $extensions_controller->setModelRegistry('get_customfields', 0);
- $extensions_controller->setModelRegistry('use_special_joins', 0);
- $extensions_controller->setModelRegistry('query_object', 'list');
- $extensions_controller->setModelRegistry('use_pagination', 0);
-
- $extensions_controller->select(
- $extensions_controller->getModelRegistry('primary_prefix', 'a')
- . '.'
- . 'id'
- );
-
- $extensions_controller->select(
- $extensions_controller->getModelRegistry('primary_prefix', 'a')
- . '.'
- . 'alias'
- );
-
- $extensions_controller->where(
- 'column',
- $extensions_controller->getModelRegistry('primary_prefix', 'a') . '.' . 'id',
- ' = ',
- 'integer',
- (int)$catalog_type_id
- );
-
- $extensions_controller->where(
- $extensions_controller->getModelRegistry('primary_prefix', 'a') . '.' . 'status',
- ' > ',
- 'integer',
- ' 0 '
- );
-
- $extensions_controller->order(
- $extensions_controller->getModelRegistry('primary_prefix', 'a') . '.' . 'alias',
- 'ASC'
- );
-
- try {
- return $extensions_controller->getData();
- } catch (Exception $e) {
- throw new RuntimeException($e->getMessage());
- }
- }
-
- /**
- * Retrieve System Extensions for a specific Catalog Type
- *
- * @param int $catalog_type_id
- *
- * @return array|stdClass
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function getCatalogSystemExtensions($catalog_type_id)
- {
- $extensions_controller
- = $this->resource->get(
- 'query:///Molajo//Model//Datasource//ExtensionInstances.xml',
- array('Runtimedata' => $this->runtime_data)
- );
-
- $application_id = $this->runtime_data->application->id;
- $extensions_controller->setModelRegistry('application_id', $application_id);
- $site_id = $this->runtime_data->site->id;
- $extensions_controller->setModelRegistry('site_id', $site_id);
-
- $extensions_controller->setModelRegistry('check_view_level_access', 0);
- $extensions_controller->setModelRegistry('process_events', 0);
- $extensions_controller->setModelRegistry('get_customfields', 0);
- $extensions_controller->setModelRegistry('use_special_joins', 1);
- $extensions_controller->setModelRegistry('query_object', 'list');
- $extensions_controller->setModelRegistry('use_pagination', 0);
-
- $extensions_controller->select(
- $extensions_controller->getModelRegistry('primary_prefix', 'a')
- . '.'
- . 'id'
- );
-
- $extensions_controller->select(
- $extensions_controller->getModelRegistry('primary_prefix', 'a')
- . '.'
- . 'alias'
- );
-
- $extensions_controller->select(
- $extensions_controller->getModelRegistry('primary_prefix', 'a')
- . '.'
- . 'menu'
- );
-
- $extensions_controller->select(
- $extensions_controller->getModelRegistry('primary_prefix', 'a')
- . '.'
- . 'path'
- );
-
- $extensions_controller->select(
- $extensions_controller->getModelRegistry('primary_prefix', 'a')
- . '.'
- . 'page_type'
- );
-
- $extensions_controller->where(
- 'column',
- $extensions_controller->getModelRegistry('primary_prefix', 'a') . '.' . 'catalog_type_id',
- '=',
- 'integer',
- (int)$catalog_type_id
- );
-
- $extensions_controller->where(
- 'column',
- $extensions_controller->getModelRegistry('primary_prefix', 'a') . '.' . 'id',
- '<>',
- 'column',
- $extensions_controller->getModelRegistry('primary_prefix', 'a') . '.' . 'catalog_type_id'
- );
-
- $extensions_controller->where(
- 'column',
- $extensions_controller->getModelRegistry('primary_prefix', 'a') . '.' . 'status',
- '>',
- 'integer',
- ' 0 '
- );
-
- $extensions_controller->orderBy(
- $extensions_controller->getModelRegistry('primary_prefix', 'a')
- . '.'
- . 'alias'
- );
-
- try {
- return $extensions_controller->getData();
- } catch (Exception $e) {
- throw new RuntimeException($e->getMessage());
- }
- }
-
- /**
- * Retrieve specific Extension Information
- *
- * @param int $id
- * @param string $model_name
- * @param bool $resource_indicator
- *
- * @return object
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- protected function getExtension($id, $model_name, $resource_indicator = false)
- {
- $item_resource = $this->resource->get(
- 'query:///' . $model_name,
- array('Runtimedata' => $this->runtime_data)
- );
-
- $item_resource->setModelRegistry('check_view_level_access', 0);
- $item_resource->setModelRegistry('process_events', 0);
- $item_resource->setModelRegistry('get_customfields', 1);
- $item_resource->setModelRegistry('primary_key_value', $id);
- $item_resource->setModelRegistry('query_object', 'item');
-
- $application_id = $this->runtime_data->application->id;
- $item_resource->setModelRegistry('application_id', $application_id);
- $site_id = $this->runtime_data->site->id;
- $item_resource->setModelRegistry('site_id', $site_id);
-
- $item_resource->where(
- 'column',
- $item_resource->getModelRegistry('primary_prefix', 'a') . '.' . 'id',
- '=',
- 'integer',
- (int)$id
- );
-
- try {
- $data = $item_resource->getData();
- } catch (Exception $e) {
- throw new RuntimeException($e->getMessage());
- }
-
- $model_registry = $item_resource->getModelRegistry('*');
-
- $custom_field_types = $model_registry['customfieldgroups'];
-
- if (is_array($custom_field_types)) {
- } else {
- $custom_field_types = array();
- }
-
- if (count($custom_field_types) > 0) {
- if (is_array($custom_field_types) && count($custom_field_types) > 0) {
- foreach ($custom_field_types as $group) {
- $data->$group = $this->processCustomfieldGroup($group, $data, $model_registry);
- }
- }
- }
-
- return $data;
- }
-
- /**
- * Process Customfield Group
- *
- * @param string $group
- * @param object $data
- * @param object $model_registry
- *
- * @return stdClass
- * @since 1.0
- */
- protected function processCustomfieldGroup($group, $data, $model_registry)
- {
- if (isset($data->$group)) {
- $group_data = json_decode($data->$group);
- } else {
- $group_data = new stdClass();
- }
-
- if (isset($this->runtime_data->application->id)) {
- $application_id = $this->runtime_data->application->id;
- if (isset($group_data->$application_id)) {
- $group_data = $group_data->$application_id;
- }
- }
-
- $temp = array();
-
- foreach ($model_registry[$group] as $customfields) {
-
- $key = $customfields['name'];
-
- $value = null;
-
- if (isset($group_data->$key)) {
- $value = $group_data->$key;
- }
-
- if ($value === null || $value === '' || $value === ' ') {
-
- if (isset($customfields['default'])) {
- $default = $customfields['default'];
- } else {
- $default = false;
- }
-
- $value = $default;
- }
-
- $temp[$key] = $value;
- }
-
- ksort($temp);
-
- $group_name = new stdClass();
- foreach ($temp as $key => $value) {
- $group_name->$key = $value;
- }
-
- return $group_name;
- }
-}
diff --git a/Source/Factory/ReadControllerFactory.php b/Source/Factory/ReadControllerFactory.php
deleted file mode 100644
index c9f936a..0000000
--- a/Source/Factory/ReadControllerFactory.php
+++ /dev/null
@@ -1,138 +0,0 @@
-query = $query;
- $this->model = $model;
- $this->model_registry = $model_registry;
- $this->runtime_data = $runtime_data;
- $this->schedule_event = $schedule_event;
- $this->sql = $sql;
-
- $this->query->clearQuery();
- }
-
- /**
- * Instantiate Class, load the Model Registry and SQL
- *
- * @return object
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function instantiateClass()
- {
- $class = 'Molajo\\Controller\\ReadController';
-
- try {
- $instance = new $class (
- $this->model,
- $this->runtime_data,
- $this->schedule_event,
- $this->query
- );
- } catch (Exception $e) {
- throw new RuntimeException(
- 'Resource Factory ReadControllerFactory failed in instantiateClass Method.' . $e->getMessage()
- );
- }
-
- $instance->setModelRegistry('*', $this->model_registry);
-
- if (trim($this->sql) === '') {
- } else {
- $instance->set('sql', $this->sql);
- }
-
- return $instance;
- }
-}
diff --git a/Source/Factory/ReadModelFactory.php b/Source/Factory/ReadModelFactory.php
deleted file mode 100644
index 031b246..0000000
--- a/Source/Factory/ReadModelFactory.php
+++ /dev/null
@@ -1,68 +0,0 @@
-database = $database;
- }
-
- /**
- * Create Model Instance
- *
- * @return object
- * @since 1.0
- * @throws \CommonApi\Exception\RuntimeException
- */
- public function instantiateClass()
- {
- $class = 'Molajo\\Model\\ReadModel';
-
- try {
- return new $class (
- $this->database
- );
- } catch (Exception $e) {
- throw new RuntimeException(
- 'Resource Query Handler Failed Instantiating Model: '
- . $e->getMessage()
- );
- }
- }
-}
diff --git a/Source/Proxy.php b/Source/Proxy.php
new file mode 100644
index 0000000..1c4897f
--- /dev/null
+++ b/Source/Proxy.php
@@ -0,0 +1,96 @@
+adapter_instance_array as $key => $value) {
+
+ $this->adapter_instance_array[$key]->setNamespace(
+ $namespace_prefix,
+ $base_directory,
+ $prepend
+ );
+ }
+
+ return $this;
+ }
+
+ /**
+ * Verify if the resource namespace has been defined
+ *
+ * @param string $uri_namespace
+ *
+ * @return boolean
+ * @since 1.0.0
+ */
+ public function exists($uri_namespace)
+ {
+ $located_path = $this->getUriPath($uri_namespace);
+
+ if ($located_path === false) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Locates folder/file associated with URI Namespace for Resource
+ *
+ * @param string $uri_namespace
+ * @param array $options
+ *
+ * @return void|mixed
+ * @since 1.0.0
+ */
+ public function get($uri_namespace, array $options = array())
+ {
+ return $this->getUriResource($uri_namespace, $options);
+ }
+
+ /**
+ * Retrieve a collection of a specific adapter
+ *
+ * @param string $scheme_value
+ * @param array $options
+ *
+ * @return mixed
+ * @since 1.0.0
+ */
+ public function getCollection($scheme_value, array $options = array())
+ {
+ $this->getScheme($scheme_value);
+
+ return $this->adapter_instance_array[$this->adapter_value]->getCollection($scheme_value, $options);
+ }
+}
diff --git a/Source/Proxy/Base.php b/Source/Proxy/Base.php
new file mode 100644
index 0000000..fefe01d
--- /dev/null
+++ b/Source/Proxy/Base.php
@@ -0,0 +1,148 @@
+scheme = $scheme;
+
+ foreach ($adapter_instance_array as $adapter => $adapter_instance) {
+ $this->setAdapterInstance($adapter, $adapter_instance);
+ }
+ }
+
+ /**
+ * Set Adapter Instance
+ *
+ * @param string $adapter_name
+ * @param object ResourceInterface
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ public function setAdapterInstance($adapter_name, ResourceInterface $adapter_instance)
+ {
+ if ($adapter_instance instanceof ResourceInterface) {
+ $this->adapter_instance_array[$adapter_name] = $adapter_instance;
+ }
+
+ return $this;
+ }
+}
diff --git a/Source/Proxy/ClassLoader.php b/Source/Proxy/ClassLoader.php
new file mode 100644
index 0000000..e97365a
--- /dev/null
+++ b/Source/Proxy/ClassLoader.php
@@ -0,0 +1,69 @@
+register(true);
+ }
+
+ /**
+ * Registers Class Autoloader
+ *
+ * @param boolean $prepend
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ public function register($prepend = true)
+ {
+ spl_autoload_register(array('Molajo\Resource\Proxy\Uri', 'locateNamespace'), true, $prepend);
+
+ return $this;
+ }
+
+ /**
+ * Unregister Class Autoloader
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ public function unregister()
+ {
+ spl_autoload_unregister(array('Molajo\Resource\Proxy\Uri', 'locateNamespace'));
+
+ return $this;
+ }
+}
diff --git a/Source/Proxy/Scheme.php b/Source/Proxy/Scheme.php
new file mode 100644
index 0000000..49cfedc
--- /dev/null
+++ b/Source/Proxy/Scheme.php
@@ -0,0 +1,81 @@
+scheme->setScheme($scheme_name, $adapter_name, $extensions, $replace);
+
+ return $this;
+ }
+
+ /**
+ * Get Scheme (or all schemes)
+ *
+ * @param string $scheme
+ *
+ * @return object|array
+ * @since 1.0.0
+ * @throws \CommonApi\Exception\RuntimeException
+ */
+ public function getScheme($scheme = '')
+ {
+ if ($scheme == '') {
+ return $this->scheme->getScheme();
+ }
+
+ $scheme = ucfirst(strtolower($scheme));
+
+ $this->scheme_value = $scheme;
+
+ $this->scheme_properties = $this->scheme->getScheme($this->scheme_value);
+
+ if ($this->scheme_properties === false) {
+ throw new RuntimeException('Resource getScheme Scheme not found: ' . $this->scheme_value);
+ }
+
+ $this->adapter_value = $this->scheme_properties->adapter;
+
+ if (isset($this->adapter_instance_array[$this->adapter_value])) {
+ } else {
+ echo 'in Resource Adapter ' . $this->adapter_value . '
';
+ echo '';
+ foreach ($this->adapter_instance_array as $key => $value) {
+ echo $key . '
';
+ }
+ throw new RuntimeException('Resource getScheme Adapter not found: ' . $this->adapter_value);
+ }
+
+ return $this->scheme_properties;
+ }
+}
diff --git a/Source/Proxy/Uri.php b/Source/Proxy/Uri.php
new file mode 100644
index 0000000..7b33289
--- /dev/null
+++ b/Source/Proxy/Uri.php
@@ -0,0 +1,275 @@
+getUriPath($uri_namespace);
+
+ if ($this->scheme_value === 'Field') {
+ return $this->adapter_instance_array[$this->adapter_value]->get(substr($uri_namespace, 9, 999));
+ }
+
+ return $this->locateNamespace(str_replace('\\', '/', $this->path), $this->scheme_value, $options);
+ }
+
+ /**
+ * Get Path for URI
+ *
+ * @param string $uri_namespace
+ *
+ * @return string
+ * @since 1.0.0
+ */
+ protected function getUriPath($uri_namespace)
+ {
+ $this->parseUri($uri_namespace);
+
+ $this->scheme_value = 'file';
+
+ $this->getScheme($this->scheme_value);
+
+ return $this->adapter_instance_array[$this->adapter_value]->get($uri_namespace);
+ }
+
+ /**
+ * Locates a resource using only the namespace
+ *
+ * @param string $namespace
+ * @param string $scheme
+ * @param array $options
+ *
+ * @return void|mixed
+ * @since 1.0.0
+ */
+ protected function locateNamespace($namespace, $scheme = 'ClassLoader', array $options = array())
+ {
+ $this->getScheme($scheme);
+
+ $multiple = false;
+
+ if (isset($options['multiple']) && $options['multiple'] === true) {
+ $multiple = true;
+ }
+
+ $located_path = $this->adapter_instance_array[$this->adapter_value]->get($namespace, $multiple);
+
+ $options['namespace'] = $namespace;
+
+ return $this->handlePath($this->scheme_value, $located_path, $options);
+ }
+
+ /**
+ * Handle located folder/file associated with URI Namespace for Resource
+ *
+ * @param string $scheme_value
+ * @param string $located_path
+ * @param array $options
+ *
+ * @return void|mixed
+ * @since 1.0.0
+ */
+ protected function handlePath($scheme_value, $located_path, array $options = array())
+ {
+ $this->getScheme($scheme_value);
+
+ if (strtolower($scheme_value) == 'query') {
+ $xml = $this->adapter_instance_array['Xml']->handlePath(
+ $scheme_value,
+ $located_path,
+ $options
+ );
+ $options['xml'] = $xml;
+
+ $this->adapter_value = 'Query';
+ }
+
+ return $this->adapter_instance_array[$this->adapter_value]->handlePath($scheme_value, $located_path, $options);
+ }
+
+ /**
+ * Parse the URL
+ *
+ * @param string $uri
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ protected function parseUri($uri)
+ {
+ $uri = $this->setUriScheme($uri);
+
+ $this->setUriHost($uri);
+ $this->setUriUser($uri);
+ $this->setUriPassword($uri);
+ $this->setUriPath($uri);
+ $this->setUriQuery($uri);
+ $this->setUriFragment($uri);
+
+ return $this;
+ }
+
+ /**
+ * Set Uri Scheme
+ *
+ * @param string $uri
+ *
+ * @return string
+ * @since 1.0.0
+ */
+ protected function setUriScheme($uri)
+ {
+ $scheme = parse_url($uri, PHP_URL_SCHEME);
+
+ if ($scheme === false) {
+ if (strpos($uri, ':///') === false) {
+ } else {
+ $scheme = substr($uri, 0, strpos($uri, ':///'));
+ $uri = substr($uri, strpos($uri, ':///') + 4, 9999);
+ }
+ }
+
+ if ($scheme === false) {
+ if (strpos($uri, ':/') === false) {
+ } else {
+ $scheme = substr($uri, 0, strpos($uri, ':/'));
+ $uri = substr($uri, strpos($uri, ':/') + 2, 9999);
+ }
+ }
+
+ $this->getScheme($scheme);
+
+ return $uri;
+ }
+
+ /**
+ * Set Uri Host
+ *
+ * @param string $uri
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ protected function setUriHost($uri)
+ {
+ $this->host = parse_url($uri, PHP_URL_HOST);
+
+ return $this;
+ }
+
+ /**
+ * Set Uri User
+ *
+ * @param string $uri
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ protected function setUriUser($uri)
+ {
+ $this->user = parse_url($uri, PHP_URL_USER);
+
+ return $this;
+ }
+
+ /**
+ * Set Uri Password
+ *
+ * @param string $uri
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ protected function setUriPassword($uri)
+ {
+ $this->password = parse_url($uri, PHP_URL_PASS);
+
+ return $this;
+ }
+
+ /**
+ * Set Uri Path
+ *
+ * @param string $uri
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ protected function setUriPath($uri)
+ {
+ $this->path = parse_url($uri, PHP_URL_PATH);
+
+ return $this;
+ }
+
+ /**
+ * Set Uri Query
+ *
+ * @param string $uri
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ protected function setUriQuery($uri)
+ {
+ $this->query = array();
+
+ $query = parse_url($uri, PHP_URL_QUERY);
+ if ($query === null || $query === false) {
+ $query = '';
+ }
+
+ $temp = explode(',', $query);
+
+ if (count($temp) > 0) {
+ foreach ($temp as $item) {
+ $pair = explode('=', $item);
+ if (count($pair) == 2) {
+ $this->query[$pair[0]] = $pair[1];
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set Uri Fragment
+ *
+ * @param string $uri
+ *
+ * @return $this
+ * @since 1.0.0
+ */
+ protected function setUriFragment($uri)
+ {
+ $this->fragment = parse_url($uri, PHP_URL_FRAGMENT);
+
+ return $this;
+ }
+}
diff --git a/Source/ResourceMap.php b/Source/ResourceMap.php
index 2e2b88c..1b8ba9d 100644
--- a/Source/ResourceMap.php
+++ b/Source/ResourceMap.php
@@ -3,7 +3,7 @@
* Resource Map
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Resource;
@@ -15,9 +15,9 @@
* Resource Map
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @since 1.0
+ * @since 1.0.0
*/
class ResourceMap extends Prefixes implements MapInterface
{
@@ -29,7 +29,7 @@ class ResourceMap extends Prefixes implements MapInterface
* @param boolean $prepend
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
public function setNamespace($namespace_prefix, $namespace_base_directory, $prepend = false)
{
@@ -48,7 +48,7 @@ public function setNamespace($namespace_prefix, $namespace_base_directory, $prep
* Create resource map of folder/file locations and Qualified Namespaces
*
* @return object
- * @since 1.0
+ * @since 1.0.0
*/
public function createMap()
{
@@ -65,22 +65,15 @@ public function createMap()
* Save output to json file
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function saveOutput()
{
ksort($this->resource_map);
ksort($this->class_files);
- if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
- file_put_contents($this->resource_map_filename, json_encode($this->resource_map, JSON_PRETTY_PRINT));
- file_put_contents($this->classmap_filename, json_encode($this->class_files, JSON_PRETTY_PRINT));
-
- return $this;
- }
-
- file_put_contents($this->resource_map_filename, json_encode($this->resource_map));
- file_put_contents($this->classmap_filename, json_encode($this->class_files));
+ file_put_contents($this->resource_map_filename, json_encode($this->resource_map, JSON_PRETTY_PRINT));
+ file_put_contents($this->classmap_filename, json_encode($this->class_files, JSON_PRETTY_PRINT));
return $this;
}
@@ -89,7 +82,7 @@ protected function saveOutput()
* Return Resource Map Data
*
* @return object
- * @since 1.0
+ * @since 1.0.0
*/
public function getResourceMap()
{
diff --git a/Source/ResourceMap/Base.php b/Source/ResourceMap/Base.php
index 4bc61ec..b5972ca 100644
--- a/Source/ResourceMap/Base.php
+++ b/Source/ResourceMap/Base.php
@@ -3,7 +3,7 @@
* Create Resource Map
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Resource\ResourceMap;
@@ -15,9 +15,9 @@
* Resource Map Base
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @since 1.0
+ * @since 1.0.0
*/
abstract class Base
{
@@ -25,7 +25,7 @@ abstract class Base
* Resource Map Filename
*
* @var string
- * @since 1.0
+ * @since 1.0.0
*/
protected $resource_map_filename;
@@ -33,7 +33,7 @@ abstract class Base
* Interface Map Filename
*
* @var string
- * @since 1.0
+ * @since 1.0.0
*/
protected $classmap_filename;
@@ -41,7 +41,7 @@ abstract class Base
* Base Path - root of the website from which paths are defined
*
* @var string
- * @since 1.0
+ * @since 1.0.0
*/
protected $base_path;
@@ -49,7 +49,7 @@ abstract class Base
* Namespace Prefixes + Path
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $namespace_prefixes = array();
@@ -57,19 +57,19 @@ abstract class Base
* List of folders to exclude from resource mapping
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $exclude_folders = array();
/**
* Constructor
*
- * @param string $base_path
- * @param array $exclude_folders
- * @param string $classmap_filename
- * @param string $resource_map_filename
+ * @param string $base_path
+ * @param array $exclude_folders
+ * @param string $classmap_filename
+ * @param string $resource_map_filename
*
- * @since 1.0
+ * @since 1.0.0
*/
public function __construct(
$base_path,
@@ -92,12 +92,13 @@ public function __construct(
$this->resource_map_filename = $resource_map_filename;
}
}
+
/**
* Get Reflection Object from PHP
*
* @param string $qns
*
- * @since 1.0
+ * @since 1.0.0
* @return object
*/
protected function getReflectionObject($qns)
@@ -112,14 +113,14 @@ protected function getReflectionObject($qns)
/**
* Set a namespace prefix by mapping to the filesystem path
*
- * @param string $namespace
+ * @param string $namespace
*
* @return string
- * @since 1.0
+ * @since 1.0.0
*/
protected function addSlash($namespace)
{
- if (substr($namespace, - 1) === '\\') {
+ if (substr($namespace, -1) === '\\') {
} else {
$namespace = $namespace . '\\';
}
diff --git a/Source/ResourceMap/Folders.php b/Source/ResourceMap/Folders.php
index 67c81c1..82d01b2 100644
--- a/Source/ResourceMap/Folders.php
+++ b/Source/ResourceMap/Folders.php
@@ -3,7 +3,7 @@
* Resource Namespace Mapping
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Resource\ResourceMap;
@@ -12,9 +12,9 @@
* Resource Namespace
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @since 1.0
+ * @since 1.0.0
*/
abstract class Folders extends Base
{
@@ -22,7 +22,7 @@ abstract class Folders extends Base
* Base Name
*
* @var string
- * @since 1.0
+ * @since 1.0.0
*/
protected $base_name = '';
@@ -30,7 +30,7 @@ abstract class Folders extends Base
* PHP Class Indicator
*
* @var boolean
- * @since 1.0
+ * @since 1.0.0
*/
protected $php_class = false;
@@ -38,7 +38,7 @@ abstract class Folders extends Base
* Temporary Work File to accumulate Resource Map
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $resource_map = array();
@@ -46,7 +46,7 @@ abstract class Folders extends Base
* Temporary Work File to accumulate Class Files
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $class_files = array();
@@ -58,7 +58,7 @@ abstract class Folders extends Base
* @param boolean $prepend
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setMultipleNamespaceFolder($namespace_prefix, $namespace_base_directory, $prepend)
{
@@ -81,7 +81,7 @@ protected function setMultipleNamespaceFolder($namespace_prefix, $namespace_base
* @param array $hold
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function appendNamespaceFolder($namespace_prefix, $namespace_base_directory, $hold)
{
@@ -99,7 +99,7 @@ protected function appendNamespaceFolder($namespace_prefix, $namespace_base_dire
* @param array $hold
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function prependNamespaceFolder($namespace_prefix, $namespace_base_directory, $hold)
{
diff --git a/Source/ResourceMap/Prefixes.php b/Source/ResourceMap/Prefixes.php
index 8aacd6e..635939c 100644
--- a/Source/ResourceMap/Prefixes.php
+++ b/Source/ResourceMap/Prefixes.php
@@ -3,7 +3,7 @@
* Namespace Prefixes for Resource Map
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Resource\ResourceMap;
@@ -16,9 +16,9 @@
* Namespace Prefixes for Resource Map
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @since 1.0
+ * @since 1.0.0
*/
abstract class Prefixes extends Folders
{
@@ -26,7 +26,7 @@ abstract class Prefixes extends Folders
* Folders
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $folders = array();
@@ -34,7 +34,7 @@ abstract class Prefixes extends Folders
* Files
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $files = array();
@@ -42,7 +42,7 @@ abstract class Prefixes extends Folders
* Process Array of Namespaces/Folder Mapping Pairs
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function processNamespacePrefixes()
{
@@ -60,7 +60,7 @@ protected function processNamespacePrefixes()
* @param string $namespace_prefix
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function processNamespaceFolders($namespace_base_folders, $namespace_prefix)
{
@@ -85,8 +85,8 @@ protected function processNamespaceFolders($namespace_base_folders, $namespace_p
* @param string $namespace_base_folder
* @param string $namespace_prefix
*
- * @return object
- * @since 1.0
+ * @return Prefixes
+ * @since 1.0.0
*/
protected function processNamespaceFolder($namespace_base_folder, $namespace_prefix)
{
@@ -94,8 +94,7 @@ protected function processNamespaceFolder($namespace_base_folder, $namespace_pre
$paths[] = $this->base_path . '/' . $namespace_base_folder;
$this->resource_map[strtolower($namespace_prefix)] = array_unique($paths);
- $objects = new RecursiveIteratorIterator
- (
+ $objects = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($this->base_path . '/' . $namespace_base_folder),
RecursiveIteratorIterator::SELF_FIRST
);
@@ -108,12 +107,12 @@ protected function processNamespaceFolder($namespace_base_folder, $namespace_pre
/**
* Process File Objects
*
- * @param object $objects
+ * @param RecursiveIteratorIterator $objects
* @param string $namespace_prefix
* @param string $namespace_base_folder
*
- * @return object
- * @since 1.0
+ * @return Prefixes
+ * @since 1.0.0
*/
protected function processFilePathObjects($objects, $namespace_prefix, $namespace_base_folder)
{
@@ -146,8 +145,8 @@ protected function processFilePathObjects($objects, $namespace_prefix, $namespac
* @param string $file_name
* @param string $file_extension
*
- * @return int|object
- * @since 1.0
+ * @return Prefixes
+ * @since 1.0.0
*/
protected function testFileForNamespaceRules(
$namespace_prefix,
@@ -171,20 +170,14 @@ protected function testFileForNamespaceRules(
return $this;
}
- $path = $this->setPath($is_directory, $file_path, $file_name);
- $class_namespace_path = substr($path, strlen($base_directory), 9999);
- $qns = $this->setQNS($class_namespace_path, $namespace_prefix);
- $nspath = $path;
-
- if ($is_directory === true) {
- } else {
- list($qns, $nspath) = $this->setClassfileArrayEntry($file_name, $file_extension, $qns, $nspath);
- }
-
- if ($qns === false) {
- } else {
- $this->mergeFQNSPaths($nspath, $qns);
- }
+ $this->useFilesWithNamespace(
+ $namespace_prefix,
+ $base_directory,
+ $is_directory,
+ $file_path,
+ $file_name,
+ $file_extension
+ );
return $this;
}
@@ -198,7 +191,7 @@ protected function testFileForNamespaceRules(
* @param string $file_extension
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function setBase($is_directory, $file_path, $file_name, $file_extension)
{
@@ -222,8 +215,8 @@ protected function setBase($is_directory, $file_path, $file_name, $file_extensio
* @param string $file_name
* @param string $file_extension
*
- * @return boolean
- * @since 1.0
+ * @return integer
+ * @since 1.0.0
*/
protected function setFileInclusion($is_directory, $file_name, $file_extension)
{
@@ -248,8 +241,8 @@ protected function setFileInclusion($is_directory, $file_name, $file_extension)
*
* @param string $file_name
*
- * @return $this
- * @since 1.0
+ * @return boolean
+ * @since 1.0.0
*/
protected function testPHPClassExceptions($file_name)
{
@@ -270,7 +263,7 @@ protected function testPHPClassExceptions($file_name)
* @param int $skip
*
* @return int
- * @since 1.0
+ * @since 1.0.0
*/
protected function testExcludeFolders($file_path, $skip = 1)
{
@@ -311,7 +304,7 @@ protected function testExcludeFolders($file_path, $skip = 1)
* @param string $file_name
*
* @return string
- * @since 1.0
+ * @since 1.0.0
*/
protected function setPath($is_directory, $file_path, $file_name)
{
@@ -329,7 +322,7 @@ protected function setPath($is_directory, $file_path, $file_name)
* @param string $namespace_prefix
*
* @return string
- * @since 1.0
+ * @since 1.0.0
*/
protected function setQNS($class_namespace_path, $namespace_prefix)
{
@@ -342,6 +335,58 @@ protected function setQNS($class_namespace_path, $namespace_prefix)
return $namespace_prefix . str_replace('/', '\\', $class_namespace_path);
}
+ /**
+ * Set Namespace Object
+ *
+ * @param string $file_name
+ * @param string $nspath
+ * @param string $qns
+ *
+ * @return stdClass
+ * @since 1.0.0
+ */
+ protected function setNamespaceObject($file_name, $nspath, $qns)
+ {
+ $temp = new stdClass();
+ $temp->file_name = $file_name;
+ $temp->base_name = $this->base_name;
+ $temp->path = $nspath;
+ $temp->qns = $qns;
+
+ return $temp;
+ }
+
+ /**
+ * File qualifies for use with Namespace
+ *
+ * @param string $namespace_prefix
+ * @param string $base_directory
+ * @param string $is_directory
+ * @param string $file_path
+ * @param string $file_name
+ * @param string $file_extension
+ *
+ * @return Prefixes
+ * @since 1.0.0
+ */
+ protected function useFilesWithNamespace(
+ $namespace_prefix,
+ $base_directory,
+ $is_directory,
+ $file_path,
+ $file_name,
+ $file_extension
+ ) {
+ $path = $this->setPath($is_directory, $file_path, $file_name);
+ $class_namespace_path = substr($path, strlen($base_directory), 9999);
+ $qns = $this->setQNS($class_namespace_path, $namespace_prefix);
+ $nspath = $path;
+
+ $this->SetFileDirectoryNamespace($is_directory, $file_name, $file_extension, $qns, $nspath);
+
+ return $this;
+ }
+
/**
* Get Resource Map Tags
*
@@ -349,7 +394,7 @@ protected function setQNS($class_namespace_path, $namespace_prefix)
* @param string $qns
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
*/
protected function mergeFQNSPaths($nspath, $qns)
{
@@ -375,11 +420,10 @@ protected function mergeFQNSPaths($nspath, $qns)
/**
* Merge Existing FQNS Path
*
- * @param string $nspath
* @param string $qns
*
* @return array
- * @since 1.0
+ * @since 1.0.0
*/
protected function mergeExistingFQNSPath($qns)
{
@@ -390,53 +434,60 @@ protected function mergeExistingFQNSPath($qns)
$paths = $existing;
if (count($paths) === 0) {
$paths = array();
- return $paths;
}
}
+
return $paths;
}
/**
- * Set Class File Array Entry
+ * Set File Directory Namespace
*
+ * @param string $is_directory
* @param string $file_name
* @param string $file_extension
+ * @param string $qns
* @param string $nspath
*
- * @return array
- * @since 1.0
+ * @return $this
+ * @since 1.0.0
*/
- protected function setClassfileArrayEntry($file_name, $file_extension, $qns, $nspath)
+ protected function SetFileDirectoryNamespace($is_directory, $file_name, $file_extension, $qns, $nspath)
{
- $qns = $this->addSlash($qns);
- $qns = $qns . $this->base_name;
- $nspath = $nspath . '/' . $file_name;
+ if ($is_directory === true) {
+ } else {
+ list($qns, $nspath) = $this->setClassfileArrayEntry($file_name, $file_extension, $qns, $nspath);
+ }
- if ($file_extension === 'php') {
- $this->class_files[$nspath] = $this->setNamespaceObject($file_name, $nspath, $qns);
+ if ($qns === false) {
+ } else {
+ $this->mergeFQNSPaths($nspath, $qns);
}
- return array($qns, $nspath);
+ return $this;
}
/**
- * Set Namespace Object
+ * Set Class File Array Entry
*
* @param string $file_name
+ * @param string $file_extension
* @param string $nspath
- * @param string $qns
+ * @param string $qns
*
- * @return object
- * @since 1.0
+ * @return string[]
+ * @since 1.0.0
*/
- protected function setNamespaceObject($file_name, $nspath, $qns)
+ protected function setClassfileArrayEntry($file_name, $file_extension, $qns, $nspath)
{
- $temp = new stdClass();
- $temp->file_name = $file_name;
- $temp->base_name = $this->base_name;
- $temp->path = $nspath;
- $temp->qns = $qns;
+ $qns = $this->addSlash($qns);
+ $qns = $qns . $this->base_name;
+ $nspath = $nspath . '/' . $file_name;
- return $temp;
+ if ($file_extension === 'php') {
+ $this->class_files[$nspath] = $this->setNamespaceObject($file_name, $nspath, $qns);
+ }
+
+ return array($qns, $nspath);
}
}
diff --git a/Source/ResourceMap/xxxxCreate.php b/Source/ResourceMap/xxxxCreate.php
deleted file mode 100644
index c5bcfa4..0000000
--- a/Source/ResourceMap/xxxxCreate.php
+++ /dev/null
@@ -1,463 +0,0 @@
-namespace_prefixes as $namespace_prefix => $namespace_base_folders) {
- $this->processNamespaceFolders($namespace_base_folders, $namespace_prefix);
- }
-
- return $this;
- }
-
- /**
- * Process Folders for Namespace
- *
- * @param array $namespace_base_folders
- * @param string $namespace_prefix
- *
- * @return $this
- * @since 1.0
- */
- protected function processNamespaceFolders($namespace_base_folders, $namespace_prefix)
- {
- foreach ($namespace_base_folders as $namespace_base_folder) {
-
- $this->php_class = 0;
-
- if (trim($namespace_base_folder) === '') {
- } elseif (is_dir($this->base_path . '/' . $namespace_base_folder)) {
- $this->processNamespaceFolder($namespace_base_folder, $namespace_prefix);
- }
- }
-
- return $this;
- }
-
- /**
- * Process Single Directory
- *
- * @param string $namespace_base_folder
- * @param string $namespace_prefix
- *
- * @return object
- * @since 1.0
- */
- protected function processNamespaceFolder($namespace_base_folder, $namespace_prefix)
- {
- $paths = array();
- $paths[] = $this->base_path . '/' . $namespace_base_folder;
- $this->resource_map[strtolower($namespace_prefix)] = array_unique($paths);
-
- $objects = new RecursiveIteratorIterator
- (
- new RecursiveDirectoryIterator($this->base_path . '/' . $namespace_base_folder),
- RecursiveIteratorIterator::SELF_FIRST
- );
-
- if (count($objects) > 0) {
- $this->processFilePathObjects($objects, $namespace_prefix, $namespace_base_folder);
- }
-
- return $this;
- }
-
- /**
- * Process File Objects
- *
- * @param object $objects
- * @param string $namespace_prefix
- * @param string $namespace_base_folder
- *
- * @return object
- * @since 1.0
- */
- protected function processFilePathObjects($objects, $namespace_prefix, $namespace_base_folder)
- {
- foreach ($objects as $file_path => $file_object) {
-
- $file_name = $file_object->getFileName();
- $file_extension = $file_object->getExtension();
- $is_directory = $file_object->isDir();
-
- $this->testFileForNamespaceRules(
- $namespace_prefix,
- $namespace_base_folder,
- $is_directory,
- $file_path,
- $file_name,
- $file_extension
- );
- }
-
- return $this;
- }
-
- /**
- * Test Path for this Namespace Prefix
- *
- * @param string $namespace_prefix
- * @param string $base_directory
- * @param int $is_directory
- * @param string $file_path
- * @param string $file_name
- * @param string $file_extension
- *
- * @return int|object
- * @since 1.0
- */
- protected function testFileForNamespaceRules(
- $namespace_prefix,
- $base_directory,
- $is_directory,
- $file_path,
- $file_name,
- $file_extension
- ) {
- $this->setBase($is_directory, $file_path, $file_name, $file_extension);
-
- $skip = $this->setFileInclusion($is_directory, $file_name, $file_extension);
- if ($skip === 1) {
- return $this;
- }
-
- $file_path = substr($file_path, strlen($this->base_path . '/'), 9999);
-
- $skip = $this->testExcludeFolders($file_path, $this->base_name, $skip);
- if ($skip === 1) {
- return $this;
- }
-
- $path = $this->setPath($is_directory, $file_path, $file_name);
- $class_namespace_path = substr($path, strlen($base_directory), 9999);
- $qns = $this->setQNS($class_namespace_path, $namespace_prefix);
- $nspath = $path;
-
- if ($is_directory === true) {
- echo 'Folder ' . $nspath . '
';
- } else {
- list($qns, $nspath) = $this->setClassfileArrayEntry($file_name, $file_extension, $qns, $nspath);
- }
-
- if ($qns === false) {
- } else {
- $this->mergeFQNSPaths($nspath, $qns);
- }
-
- return $this;
- }
-
- /**
- * Set base for file or folder
- *
- * @param int $is_directory
- * @param string $file_path
- * @param string $file_name
- * @param string $file_extension
- *
- * @return $this
- * @since 1.0
- */
- protected function setBase($is_directory, $file_path, $file_name, $file_extension)
- {
- $this->base_name = $file_name;
-
- if ($is_directory === 1) {
- $pathinfo = pathinfo($file_path);
- $this->base_name = $pathinfo['basename'];
-
- } elseif ($file_extension === 'php') {
- $this->base_name = substr($file_name, 0, strlen($file_name) - strlen($file_extension) - 1);
- }
-
- return $this;
- }
-
- /**
- * Test to determine if the file or folder should be used
- *
- * @param int $is_directory
- * @param string $file_name
- * @param string $file_extension
- *
- * @return boolean
- * @since 1.0
- */
- protected function setFileInclusion($is_directory, $file_name, $file_extension)
- {
- $skip = 0;
-
- if ($is_directory === 1) {
- return $skip;
- }
-
- if ($file_extension === 'php') {
-
- if ($this->testPHPClassExceptions($file_name) === false) {
- $skip = 1;
- }
- }
-
- return $skip;
- }
-
- /**
- * Set PHP Class
- *
- * @param string $file_name
- *
- * @return $this
- * @since 1.0
- */
- protected function testPHPClassExceptions($file_name)
- {
- if (strtolower(substr($file_name, 0, 4)) === 'hold') {
- } elseif (strtolower(substr($file_name, 0, 3)) === 'xxx') {
- } elseif (strtolower($this->base_name) === 'index') {
- } else {
- return true;
- }
-
- return false;
- }
-
- /**
- * Test Exclude Folders Definitions
- *
- * @param string $file_path
- * @param int $skip
- *
- * @return int
- * @since 1.0
- */
- protected function testExcludeFolders($file_path, $skip = 1)
- {
- if ($skip === 1) {
- return $skip;
- }
-
- if (substr($this->base_name, 0, 1) === '.') {
- return 1;
- }
-
- if (count($this->exclude_folders) === 0) {
- return $skip;
- }
-
- $skip = 0;
-
- foreach ($this->exclude_folders as $exclude) {
-
- if ($this->base_name === $exclude) {
- $skip = 1;
- break;
- } elseif (strpos($file_path, '/' . $exclude) === false) {
- } else {
- $skip = 1;
- break;
- }
- }
-
- return $skip;
- }
-
- /**
- * Set Path
- *
- * @param int $is_directory
- * @param string $file_path
- * @param string $file_name
- *
- * @return string
- * @since 1.0
- */
- protected function setPath($is_directory, $file_path, $file_name)
- {
- if ($is_directory === true) {
- return $file_path;
- }
-
- return substr($file_path, 0, strlen($file_path) - strlen($file_name) - 1);
- }
-
- /**
- * Set Qualified Namespace
- *
- * @param string $class_namespace_path
- * @param string $namespace_prefix
- *
- * @return string
- * @since 1.0
- */
- protected function setQNS($class_namespace_path, $namespace_prefix)
- {
- if ($class_namespace_path === '') {
- return $namespace_prefix;
- }
-
- $namespace_prefix = $this->addSlash($namespace_prefix);
-
- return $namespace_prefix . str_replace('/', '\\', $class_namespace_path);
- }
-
- /**
- * Set Namespace Object
- *
- * @param string $file_name
- * @param string $nspath
- * @param string $qns
- *
- * @return object
- * @since 1.0
- */
- protected function setNamespaceObject($file_name, $nspath, $qns)
- {
- $temp = new stdClass();
- $temp->file_name = $file_name;
- $temp->base_name = $this->base_name;
- $temp->path = $nspath;
- $temp->qns = $qns;
-
- return $temp;
- }
-
- /**
- * Get Resource Map Tags
- *
- * @param string $nspath
- * @param string $qns
- *
- * @return $this
- * @since 1.0
- */
- protected function mergeFQNSPaths($nspath, $qns)
- {
- if ($nspath === '') {
- return $this;
- }
-
- $qns = strtolower($qns);
-
- if (isset($this->resource_map[$qns])) {
- $paths = $this->mergeExistingFQNSPath($qns);
- } else {
- $paths = array();
- }
-
- $paths[] = $this->base_path . '/' . $nspath;
-
- $this->resource_map[$qns] = array_unique($paths);
-
- return $this;
- }
-
- /**
- * Merge Existing FQNS Path
- *
- * @param string $nspath
- * @param string $qns
- *
- * @return array
- * @since 1.0
- */
- protected function mergeExistingFQNSPath($qns)
- {
- $paths = array();
- $existing = $this->resource_map[$qns];
-
- if (is_array($existing)) {
- $paths = $existing;
- if (count($paths) === 0) {
- $paths = array();
- return $paths;
- }
- }
- return $paths;
- }
-
- /**
- * Set Class File Array Entry
- *
- * @param string $file_name
- * @param string $file_extension
- * @param string $nspath
- *
- * @return array
- * @since 1.0
- */
- protected function setClassfileArrayEntry($file_name, $file_extension, $qns, $nspath)
- {
- $qns = $this->addSlash($qns);
- $qns = $qns . $this->base_name;
- $nspath = $nspath . '/' . $file_name;
-
- if ($this->getReflectionObject($qns) === false) {
- return array(false, false);
- }
-
- if ($file_extension === 'php') {
- $this->class_files[$nspath] = $this->setNamespaceObject($file_name, $nspath, $qns);
- }
-
- return array($qns, $nspath);
- }
-}
diff --git a/Source/Scheme.php b/Source/Scheme.php
index 9e18c82..3eaa87c 100644
--- a/Source/Scheme.php
+++ b/Source/Scheme.php
@@ -3,7 +3,7 @@
* Scheme
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Resource;
@@ -16,9 +16,9 @@
* Scheme
*
* @package Molajo
- * @copyright 2014 Amy Stephen. All rights reserved.
+ * @copyright 2014-2015 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
- * @since 1.0
+ * @since 1.0.0
*/
class Scheme implements SchemeInterface
{
@@ -29,7 +29,7 @@ class Scheme implements SchemeInterface
* Adapter
*
* @var array
- * @since 1.0
+ * @since 1.0.0
*/
protected $scheme_array = array();
@@ -38,7 +38,7 @@ class Scheme implements SchemeInterface
*
* @param string $scheme_filename
*
- * @since 1.0
+ * @since 1.0.0
*/
public function __construct($scheme_filename)
{
@@ -51,7 +51,7 @@ public function __construct($scheme_filename)
* @param string $scheme
*
* @return object|array
- * @since 1.0
+ * @since 1.0.0
*/
public function getScheme($scheme = '')
{
@@ -70,7 +70,7 @@ public function getScheme($scheme = '')
* @param string $filename
*
* @return void
- * @since 1.0
+ * @since 1.0.0
* @throws \CommonApi\Exception\RuntimeException
*/
protected function readSchemes($filename)
@@ -141,7 +141,7 @@ protected function readSchemes($filename)
* @param bool $replace
*
* @return $this
- * @since 1.0
+ * @since 1.0.0
* @throws \CommonApi\Exception\RuntimeException
*/
public function setScheme($scheme_name, $adapter = 'File', array $extensions = array(), $replace = false)
diff --git a/composer.json b/composer.json
index b0762dc..8e2b3b8 100644
--- a/composer.json
+++ b/composer.json
@@ -3,7 +3,11 @@
"description": "Molajo Resource Services for PHP Applications",
"version": "1.0.0",
"type": "molajo-package",
- "keywords": ["resource", "commonapi", "molajo"],
+ "keywords": [
+ "resource",
+ "commonapi",
+ "molajo"
+ ],
"homepage": "http://github.com/Molajo/Resource",
"license": "MIT",
"authors": [
@@ -26,7 +30,6 @@
},
"autoload": {
"psr-4": {
- "Molajo\\Factories\\": "Factories/",
"Molajo\\Resource\\": "Source/"
}
},
diff --git a/coverage.clover b/coverage.clover
new file mode 100644
index 0000000..30d312c
--- /dev/null
+++ b/coverage.clover
@@ -0,0 +1,505 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+