protected function _installComponent($manifest, $output, $path, $schema) { $name = \KService::get('koowa:filter.cmd')->sanitize($manifest->name[0]); $name = 'com_' . strtolower($name); $components = \KService::get('repos:cli.component', array('resources' => 'components')); //find or create a component $component = $components->findOrAddNew(array('option' => $name, 'parent' => 0), array('data' => array('params' => ''))); //remove any child component $components->getQuery()->option($name)->parent('0', '>')->destroy(); $admin_menu = $manifest->administration->menu; $site_menu = $manifest->menu; $component->setData(array('name' => (string) $manifest->name[0], 'enabled' => 1, 'link' => '', 'adminMenuLink' => '', 'adminMenuAlt' => '', 'adminMenuImg' => '')); if ($site_menu) { $component->setData(array('link' => 'option=' . $name)); } elseif ($admin_menu) { $component->setData(array('link' => 'option=' . $name, 'adminMenuLink' => 'option=' . $name, 'adminMenuAlt' => (string) $admin_menu, 'adminMenuImg' => 'js/ThemeOffice/component.png')); } //first time installing the component then //run the schema if ($component->isNew()) { $schema = true; } $output->writeLn('<info>...installing ' . str_replace('com_', '', $name) . ' component</info>'); $component->saveEntity(); if ($schema && file_exists($path . '/schemas/schema.sql')) { $output->writeLn('<info>...running schema for ' . str_replace('com_', '', $name) . ' component</info>'); $queries = dbparse(file_get_contents($path . '/schemas/schema.sql')); foreach ($queries as $query) { \KService::get('koowa:database.adapter.mysqli')->execute($query); } } }
/** * executes a sql file * * @param string $file */ function dbexecfile($file) { $queries = dbparse(file_get_contents($file)); dbexec($queries); }