Автор: Jabran Rafique (hello@jabran.me)
Пример #1
0
 /**
  * @param string|aray $model
  * @return \Lassi\App\Controller
  */
 public function __construct(Lassi $lassi = null, $models = null)
 {
     if ($lassi !== null) {
         $this->lassi = $lassi;
         $this->setApp($lassi->getApp());
     }
     if ($models !== null) {
         $this->useModel($models);
     }
     return $this;
 }
Пример #2
0
 /**
  * Set model(s) to use
  *
  * @param string|array $models
  *
  * @return $this
  */
 public function useModel($models)
 {
     if (is_array($models)) {
         return array_map(array($this, 'useModel'), $models);
     }
     if (is_scalar($models)) {
         $name = strtolower($models);
         $class = sprintf('\\Lassi\\Model\\%s', ucwords($name));
         $this->{$name} = new $class();
         $this->{$name}->setConnection($this->lassi->getEloquent());
     }
     return $this;
 }
Пример #3
0
 /**
  * Load framework app routes
  * @return void
  */
 private static function loadRoutes()
 {
     $routes = dirname(__FILE__) . '/routes.php';
     if (!file_exists($routes) || !is_readable($routes)) {
         throw new NotFoundException('Routes not found.');
     }
     // Get Slim instance
     $app = \Lassi\Lassi::getInstance()->getApp();
     require_once $routes;
 }
Пример #4
0
 public function __construct()
 {
     /**
      * Set app instance for parent class
      */
     parent::__construct(Lassi::getInstance());
     /**
      * Set a single model or an array of models
      */
     $this->useModel('user');
 }
Пример #5
0
<?php

use Lassi\Lassi;
/**
 * Bootstrap the boilerplate
 *
 * @author Jabran Rafique <*****@*****.**>
 * @license MIT License
 */
/** Restrict direct access */
defined('ROOT') or die('Unexpected request');
/**
 * Setup Lassi with Slim framework and Eloquent
 */
Lassi::bootstrap();
Пример #6
0
 public function testGetInstanceReturnsLassiInstance()
 {
     Util::setEnvVariables('.');
     $this->assertInstanceOf('Lassi\\Lassi', Lassi::getInstance());
 }