public function __construct(Config $config) { $this->capsule = new Capsule(); $this->capsule->addConnection($config->get('database')); $this->capsule->setEventDispatcher(new Dispatcher(new Container())); $this->capsule->setAsGlobal(); $this->capsule->bootEloquent(); }
private function __construct() { \Frame\Loader::registerAutoLoad(); \Frame\Loader::registerNamespace('Frame', dirname(__FILE__) . DIRECTORY_SEPARATOR); $this->_config = \Frame\Config::getInstance(); $this->_controller = \Frame\FrontController::getInstance(); }
private static function increment($key) { $order = \Frame\Config::get('order'); if ($key == str_repeat(substr($order, -1), strlen($key))) { return str_repeat(substr($order, 0, 1), strlen($key)); } for ($i = 1; $i <= strlen($key); $i++) { if (substr($key, -$i, 1) != substr($order, -1)) { $key = substr($key, 0, strlen($key) - $i) . substr($order, strpos($order, substr($key, -$i, 1)) + 1, 1) . str_repeat(substr($order, 0, 1), $i - 1); return $key; } } }
/** * Load up our router * * @param Klein\Klein $klein * @param Config $config */ public function __construct(Klein\Klein $klein, Config $config) { $this->routes = $config->get('routes'); $this->klein = $klein; $this->routes($this->routes); }
private static function getSteps($class, $functions) { $steps = array(); $functions = explode('.', $functions); foreach ($functions as $function) { $step = $class::$function(); $step['parent'] = $class; if (!isset($step['parent_column'])) { $step['parent_column'] = $class::$primary_key; } $class = $step['child']; if (!isset($step['child_column'])) { $step['child_column'] = $class::$primary_key; } $step['function'] = $function; if ($step['type'] == 'manyMany') { $db = \Frame\Config::get('database.' . arrayGet($step, 'config', 'default')); $db['connection'] = arrayGet($step, 'config', 'default'); $connection = \Frame\Connection::get($db); $builder = new \Frame\Builder($connection, $db, $step['link']['link_table'], arrayGet($step, 'link.link_primary_key', "{$step['link']['link_table']}_id"), null); $steps[] = array('type' => 'oneMany', 'function' => $step['function'], 'parent' => $step['parent'], 'parent_column' => $step['parent_column'], 'child_instance' => $builder, 'child_column' => arrayGet($step, 'link.link_parent_column', $step['parent_column'])); $steps[] = array('type' => 'manyOne', 'function' => 'pivot', 'parent_instance' => $builder, 'parent_column' => arrayGet($step, 'link.link_parent_column', $step['child_column']), 'child' => $step['child'], 'child_column' => $step['child_column']); } else { $steps[] = $step; } } $last_step = $steps[count($steps) - 1]; $step = array('parent_column' => $last_step['child_column']); if (isset($last_step['child_instance'])) { $step['parent_instance'] = $last_step['child_instance']; } else { $step['parent'] = $last_step['child']; } $steps[] = $step; return $steps; }
private static function config() { \Frame\Config::init(); }