Fontis_ComposerAutoloader - Version 1.0.0

Version Notes

Initial release.

Download this release

Release Info

Developer Fontis
Extension Fontis_ComposerAutoloader
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Fontis/ComposerAutoloader/Helper/Data.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Composer Autoloader
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Fontis
13
+ * @package Fontis_ComposerAutoloader
14
+ * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Fontis_ComposerAutoloader_Helper_Data extends Mage_Core_Helper_Abstract
19
+ {
20
+ const AUTOLOAD_FILENAME = 'autoload.php';
21
+ const DEFAULT_PATH = '{{libdir}}/fontis/vendor';
22
+
23
+ /**
24
+ * The location of the vendor directory on the machine the site is running on.
25
+ * It always comes without a trailing slash.
26
+ *
27
+ * @return string
28
+ */
29
+ public function getVendorDirectoryPath()
30
+ {
31
+ $path = (string) Mage::getConfig()->getNode('global/composer_autoloader/path');
32
+ if (!$path) {
33
+ $path = self::DEFAULT_PATH;
34
+ }
35
+ $path = str_replace('/', DS, $path);
36
+ $path = str_replace('{{basedir}}', Mage::getBaseDir(), $path);
37
+ $path = str_replace('{{libdir}}', Mage::getBaseDir('lib'), $path);
38
+ $path = rtrim($path, DS);
39
+ return realpath($path);
40
+ }
41
+
42
+ /**
43
+ * @param string|null $path Path to vendor directory. Pass null to use the configured value.
44
+ * @param string|null $filename Filename of autoload file. Pass null to use the default (autoload.php).
45
+ */
46
+ public function registerAutoloader($path = null, $filename = null)
47
+ {
48
+ if ($path === null) {
49
+ $path = $this->getVendorDirectoryPath();
50
+ }
51
+ if ($filename === null) {
52
+ $filename = self::AUTOLOAD_FILENAME;
53
+ }
54
+ if (file_exists($path . DS . $filename)) {
55
+ require_once($path . DS . $filename);
56
+ }
57
+ }
58
+ }
app/code/community/Fontis/ComposerAutoloader/Model/Observer.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Composer Autoloader
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Fontis
13
+ * @package Fontis_ComposerAutoloader
14
+ * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Fontis_ComposerAutoloader_Model_Observer
19
+ {
20
+ /**
21
+ * @var bool
22
+ */
23
+ protected static $added = false;
24
+
25
+ /**
26
+ * Register the Composer autoloader
27
+ * @param Varien_Event_Observer $observer
28
+ */
29
+ public function addComposerAutoloader(Varien_Event_Observer $observer)
30
+ {
31
+ if (self::$added === false) {
32
+ /** @var $helper Fontis_ComposerAutoloader_Helper_Data */
33
+ $helper = Mage::helper('fontis_composerautoloader');
34
+ $helper->registerAutoloader();
35
+ self::$added = true;
36
+ }
37
+ }
38
+ }
app/code/community/Fontis/ComposerAutoloader/etc/config.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Fontis Composer Autoloader
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category Fontis
14
+ * @package Fontis_ComposerAutoloader
15
+ * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Fontis_ComposerAutoloader>
22
+ <version>1.0.0</version>
23
+ </Fontis_ComposerAutoloader>
24
+ </modules>
25
+ <global>
26
+ <helpers>
27
+ <fontis_composerautoloader>
28
+ <class>Fontis_ComposerAutoloader_Helper</class>
29
+ </fontis_composerautoloader>
30
+ </helpers>
31
+ <models>
32
+ <fontis_composerautoloader>
33
+ <class>Fontis_ComposerAutoloader_Model</class>
34
+ </fontis_composerautoloader>
35
+ </models>
36
+ <events>
37
+ <controller_front_init_before>
38
+ <observers>
39
+ <fontis_composer_autoloader>
40
+ <type>singleton</type>
41
+ <class>fontis_composerautoloader/observer</class>
42
+ <method>addComposerAutoloader</method>
43
+ </fontis_composer_autoloader>
44
+ </observers>
45
+ </controller_front_init_before>
46
+ <add_new_autoloader>
47
+ <observers>
48
+ <fontis_composer_autoloader>
49
+ <type>singleton</type>
50
+ <class>fontis_composerautoloader/observer</class>
51
+ <method>addComposerAutoloader</method>
52
+ </fontis_composer_autoloader>
53
+ </observers>
54
+ </add_new_autoloader>
55
+ </events>
56
+ </global>
57
+ </config>
app/etc/fontis_composerautoloader.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version='1.0' encoding="utf-8" ?>
2
+ <!--
3
+ /**
4
+ * Fontis Composer Autoloader
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category Fontis
14
+ * @package Fontis_ComposerAutoloader
15
+ * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <global>
21
+ <composer_autoloader>
22
+ <path>{{libdir}}/fontis/vendor</path>
23
+ </composer_autoloader>
24
+ </global>
25
+ </config>
26
+
app/etc/modules/Fontis_ComposerAutoloader.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Fontis Composer Autoloader
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category Fontis
14
+ * @package Fontis_ComposerAutoloader
15
+ * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Fontis_ComposerAutoloader>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ </Fontis_ComposerAutoloader>
25
+ </modules>
26
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Fontis_ComposerAutoloader</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Easily add the Composer autoloader to Magento.</summary>
10
+ <description>Adds support for the Composer autoloader into Magento, allowing you to easily make use of Composer libraries in your extension.</description>
11
+ <notes>Initial release.</notes>
12
+ <authors><author><name>Fontis</name><user>fontis</user><email>magento@fontis.com.au</email></author></authors>
13
+ <date>2015-06-16</date>
14
+ <time>00:18:56</time>
15
+ <contents><target name="magecommunity"><dir name="Fontis"><dir name="ComposerAutoloader"><dir name="Helper"><file name="Data.php" hash="6e4fb2409c5a0c6a95eeaa7d36f4dc05"/></dir><dir name="Model"><file name="Observer.php" hash="541dede0eb020d93121a88cc4ec00c35"/></dir><dir name="etc"><file name="config.xml" hash="f24e6035e92e7360a304016c0b40c5d5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Fontis_ComposerAutoloader.xml" hash="eae521993be4ee9227d40c7a3862ff58"/></dir><dir name="."><file name="fontis_composerautoloader.xml" hash="0d20fc0b666c1a976b2a2df8a6000cf4"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>