From a9688954239e30d6208d954b469564fa8ca3aabb Mon Sep 17 00:00:00 2001
From: Qiang Xue <qiang.xue@gmail.com>
Date: Tue, 21 May 2013 22:42:21 -0400
Subject: [PATCH] Added composer extension.

---
 extensions/composer/composer.json                   | 27 +++++++++++++++++++++++++++
 extensions/composer/yii/composer/InstallHandler.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+)
 create mode 100644 extensions/composer/composer.json
 create mode 100644 extensions/composer/yii/composer/InstallHandler.php

diff --git a/extensions/composer/composer.json b/extensions/composer/composer.json
new file mode 100644
index 0000000..49f99fe
--- /dev/null
+++ b/extensions/composer/composer.json
@@ -0,0 +1,27 @@
+{
+	"name": "yiisoft/yii2-composer",
+	"description": "The composer integration for the Yii framework",
+	"keywords": ["yii", "composer", "install", "update"],
+	"type": "library",
+	"license": "BSD-3-Clause",
+	"support": {
+		"issues": "https://github.com/yiisoft/yii2/issues?state=open",
+		"forum": "http://www.yiiframework.com/forum/",
+		"wiki": "http://www.yiiframework.com/wiki/",
+		"irc": "irc://irc.freenode.net/yii",
+		"source": "https://github.com/yiisoft/yii2"
+	},
+	"authors": [
+		{
+			"name": "Qiang Xue",
+			"email": "qiang.xue@gmail.com"
+		}
+	],
+	"minimum-stability": "dev",
+	"require": {
+		"yiisoft/yii2": "dev-master"
+	},
+	"autoload": {
+		"psr-0": { "yii\\composer": "" }
+	}
+}
diff --git a/extensions/composer/yii/composer/InstallHandler.php b/extensions/composer/yii/composer/InstallHandler.php
new file mode 100644
index 0000000..e9d4f51
--- /dev/null
+++ b/extensions/composer/yii/composer/InstallHandler.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright (c) 2008 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+namespace yii\composer;
+
+use Composer\Script\CommandEvent;
+
+/**
+ * InstallHandler is called by Composer after it installs/updates the current package.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @since 2.0
+ */
+class InstallHandler
+{
+	/**
+	 * Sets the correct permissions of files and directories.
+	 * @param CommandEvent $event
+	 */
+	public static function setPermissions($event)
+	{
+		$options = array_merge(array(
+			'writable' => array(),
+			'executable' => array(),
+		), $event->getComposer()->getPackage()->getExtra());
+
+		foreach ((array)$options['writable'] as $path) {
+			echo "Setting writable: $path ...";
+			if (is_dir($path)) {
+				chmod($path, 0777);
+				echo "done\n";
+			} else {
+				echo "The directory was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path;
+				return;
+			}
+		}
+
+		foreach ((array)$options['executable'] as $path) {
+			echo "Setting executable: $path ...";
+			if (is_dir($path)) {
+				chmod($path, 0755);
+				echo "done\n";
+			} else {
+				echo "The file was not found: " . getcwd() . DIRECTORY_SEPARATOR . $path;
+				return;
+			}
+		}
+	}
+}
--
libgit2 0.27.1