+
+ /**
+ * Render installer hook
+ * @param array $configure
+ * @return string
+ */
+ private static function loadHook($configure, $dependencies) {
+ return include __DIR__."/../pharext_install.tpl.php";
+ }
+
+ /**
+ * Create installer hook
+ * @return resource
+ */
+ private function generateHooks() {
+ $dependencies = $this->sxe->xpath("/pecl:package/pecl:dependencies/pecl:required/pecl:package");
+ foreach ($dependencies as $key => $dep) {
+ if (($glob = glob("{$this->path}/{$dep->name}-*.ext.phar*"))) {
+ usort($glob, function($a, $b) {
+ return version_compare(
+ substr($a, strpos(".ext.phar", $a)),
+ substr($b, strpos(".ext.phar", $b))
+ );
+ });
+ yield realpath($this->path."/".end($glob));
+ } else {
+ unset($dependencies[$key]);
+ }
+ }
+ $configure = $this->sxe->xpath("/pecl:package/pecl:extsrcrelease/pecl:configureoption");
+ if ($configure) {
+ $fd = tmpfile();
+ ob_start(function($s) use($fd){
+ fwrite($fd, $s);
+ return null;
+ });
+ self::loadHook($configure, $dependencies);
+ ob_end_flush();
+ rewind($fd);
+ yield "pharext_install.php" => $fd;
+ }
+ }