/**
  * @param Application $app
  */
 public function register(Application $app)
 {
     $app->singleton('mailer', function () {
         $mailer = new \Cygnite\Common\Mail\Mailer();
         $mailer->setSwiftMailer(new \Swift_Mailer($mailer->getTransportInstance()));
         return $mailer;
     });
 }
Example #2
0
 /**
  * @return mixed
  */
 public static function make()
 {
     if (is_null(static::$view)) {
         $app = App::instance();
         static::$view = $app->resolve('cygnite.mvc.view.view');
     }
     return static::$view;
 }
Example #3
0
 public function setUp()
 {
     $_SERVER['HTTP_HOST'] = 'localhost';
     $_SERVER['REQUEST_URI'] = '/';
     $app = Application::instance();
     $app['router'] = new Router();
     Url::setBase("/cygnite/index.php/user");
 }
Example #4
0
 public function testDependencyInjection()
 {
     $loader = m::mock("Cygnite\\Foundation\\Autoloader");
     $app = Application::getInstance($loader);
     $router = new \Cygnite\Base\Router\Router();
     $url = new \Cygnite\Common\UrlManager\Url($router);
     $madeUrl = $app->make('\\Cygnite\\Common\\UrlManager\\Url');
     $this->assertEquals($url, $madeUrl);
 }
Example #5
0
 public function setUp()
 {
     $this->app = Application::instance();
     $this->app['url'] = new \Cygnite\Common\UrlManager\Url();
     $this->app['request'] = \Cygnite\Http\Requests\Request::createFromGlobals();
     $this->app['router'] = new \Cygnite\Base\Router\Router($this->app['request']);
     $this->app['router']->setApplication($this->app);
     $this->app['url']->setApplication($this->app);
     $this->url = $this->app['url'];
 }
Example #6
0
 public function __construct()
 {
     $this->emailConfig = Config::get('global.config', 'emailConfiguration');
     try {
         Application::import('vendor' . DS . $this->emailConfig['swift_mailer_path']);
     } catch (Exception $ex) {
         throw new Exception($ex->getMessage());
     }
     //set transport type protocol
     $this->setTransportType($this->emailConfig['protocol']);
 }
Example #7
0
 public function testCreateEventInstance()
 {
     $eventInstance = Event::create();
     $event = m::mock("\\Cygnite\\Base\\EventHandler\\Event");
     $loader = m::mock("Cygnite\\Foundation\\Autoloader");
     $app = Application::getInstance($loader);
     $this->assertInstanceOf('Cygnite\\Foundation\\Application', $app);
     $app->event = $event;
     $this->assertEquals($event, $app->event);
     $this->assertInstanceOf('\\Cygnite\\Base\\EventHandler\\Event', $eventInstance);
 }
Example #8
0
 private function setUpAssetConfig()
 {
     $app = Application::instance();
     $app['router'] = new \Cygnite\Base\Router\Router();
     $_SERVER['REQUEST_URI'] = '/hello/user/';
     $_SERVER['HTTP_HOST'] = 'localhost';
     $configuration = ['global.config' => ['encoding' => 'utf-8']];
     Config::$config = $configuration;
     Url::setBase('/cygnite/');
     //$app['router']->getBaseUrl()
 }
Example #9
0
 public function setUp()
 {
     $this->app = Application::instance();
     $this->app['request'] = \Cygnite\Http\Requests\Request::createFromGlobals();
     $this->app['router'] = new \Cygnite\Base\Router\Router($this->app['request']);
     $this->app['router']->setApplication($this->app);
     $this->app['request']->server->add('SCRIPT_NAME', '/index.php');
     $this->app['request']->server->add('REQUEST_METHOD', 'GET');
     $this->app['request']->server->add('SERVER_PROTOCOL', 'HTTP/1.1');
     $this->router = $this->app['router'];
 }
Example #10
0
 /**
  * Fire shutdown method of middleware class.
  *
  * @param $request
  * @param $response
  */
 public function shutdown($request, $response)
 {
     $routeMiddlewares = $this->router->getRouteMiddlewares();
     $middlewares = array_merge(array_filter([$routeMiddlewares]), $this->middleware);
     foreach ($middlewares as $middleware) {
         list($name, $parameters) = $this->pipeline->parsePipeString($middleware);
         $instance = $this->app->make($name);
         if (method_exists($instance, 'shutdown')) {
             $instance->shutdown($request, $response);
         }
     }
 }
Example #11
0
 private function setUpAssetConfig()
 {
     $loader = m::mock("Cygnite\\Foundation\\Autoloader");
     $app = Application::getInstance($loader);
     $app['router'] = m::mock("Cygnite\\Base\\Router\\Router");
     $_SERVER['REQUEST_URI'] = '/hello/user/';
     $_SERVER['HTTP_HOST'] = 'localhost';
     $configuration = ['global.config' => ['encoding' => 'utf-8']];
     Config::$config = $configuration;
     Url::setBase('/cygnite/');
     //$app['router']->getBaseUrl()
 }
Example #12
0
 public function testMakeClass()
 {
     $this->app = Application::instance();
     $this->app['url'] = new \Cygnite\Common\UrlManager\Url();
     $this->app['request'] = \Cygnite\Http\Requests\Request::createFromGlobals();
     $this->app['router'] = new \Cygnite\Base\Router\Router($this->app['request']);
     $this->app['router']->setApplication($this->app);
     $this->app['url']->setApplication($this->app);
     $madeUrl = $this->container->make('\\Cygnite\\Common\\UrlManager\\Url');
     $madeUrl->setApplication($this->app);
     $this->assertEquals($this->app['url'], $madeUrl);
 }
Example #13
0
 /**
  * @return bool
  */
 public function terminate()
 {
     /**------------------------------------------------------------------
      * Throw Exception is default controller
      * has not been set in configuration
      * ------------------------------------------------------------------
      */
     if (is_null(Config::get('global.config', "default_controller"))) {
         trigger_error("Default controller not found ! Please set the default\n                            controller in configs/application" . EXT);
     }
     Application::import(APPPATH . '.routes');
 }
 /**
  * We will run Cygnite Console Application
  */
 public function run()
 {
     $app = CygniteApplication::instance();
     $console = new ConsoleApplication($app, $this->version);
     /*
     | We will also register Application Console commands
     | User can register multiple commands apart from core
     | commands and run on the fly
     */
     $appConsoleBootStrap = $app->make('\\Apps\\Console\\BootStrapConsoleApplication');
     $appConsoleCommands = $appConsoleBootStrap->register();
     $console->setCommand($appConsoleCommands)->registerCommands()->run();
 }
Example #15
0
 private function setUpAssetConfig()
 {
     $app = Application::instance();
     $app['url'] = new \Cygnite\Common\UrlManager\Url();
     $app['request'] = \Cygnite\Http\Requests\Request::createFromGlobals();
     $app['router'] = new \Cygnite\Base\Router\Router($app['request']);
     $app['url']->setApplication($app);
     $app['request']->server->add('REQUEST_URI', '/hello/user');
     $app['request']->server->add('HTTP_HOST', 'localhost');
     $configuration = ['global.config' => ['encoding' => 'utf-8']];
     Config::$config = $configuration;
     Url::setBase('cygnite/');
     //$app['router']->getBaseUrl()
 }
Example #16
0
 public function setUp()
 {
     $this->app = Application::instance();
     $this->app['url'] = new \Cygnite\Common\UrlManager\Url();
     $this->app['request'] = \Cygnite\Http\Requests\Request::createFromGlobals();
     $this->app['router'] = new \Cygnite\Base\Router\Router($this->app['request']);
     $this->app['router']->setApplication($this->app);
     $this->app['url']->setApplication($this->app);
     $this->app['request']->server->add('HTTP_HOST', 'localhost');
     $this->app['request']->server->add('REQUEST_URI', '/');
     /*
             $app = Application::instance();
             $app['router'] = new Router;*/
     Url::setBase('/cygnite/index.php/user');
 }
 /**
  * Register the HASH Service Provider.
  *
  * @param Application $app
  */
 public function register(Application $app)
 {
     $app['hash'] = $app->share(function ($c) {
         return new BCrypt();
     });
 }
Example #18
0
 /**
  * We will return proxy objects from container.
  *
  * @return Container
  */
 public static function app()
 {
     return Application::instance();
 }
Example #19
0
 /**
  * Add wildcards to the given URI.
  *
  * @param  string  $uri
  * @return string
  */
 public function addUriWildcards($uri, $reflection, $method)
 {
     $refAction = $reflection->getReflectionClass()->getMethod($method);
     $app = Application::instance();
     $parameter = '';
     $patterns = $app->router->getPattern();
     $arguments = new \CachingIterator(new \ArrayIterator($refAction->getParameters()));
     foreach ($arguments as $key => $param) {
         if (!$param->isOptional()) {
             if (array_key_exists('{:' . $param->getName() . '}', $patterns)) {
                 $slash = $arguments->hasNext() ? '/' : '';
                 $parameter .= '{:' . $param->getName() . '}' . $slash;
             }
         }
     }
     return $uri . '/' . $parameter;
 }
Example #20
0
 function app($callback = null)
 {
     return App::instance($callback);
 }
 public function register(Application $app)
 {
     $app->singleton('auth', function ($c) {
         return new Auth($c['auth.provider']);
     });
 }
Example #22
0
            <hr class="featurette-divider">

            <div class="footer" >
                <div class="footer-inner-left"> </div>
                <div class="footer-inner" align="center">
                    <div class="footerrow tweets"  >
                        <p style="font-size: 16px;">If you are exploring Cygnite Framework for the first time,
                            you should read the <br><a href="http://www.cygniteframework.com/2013/07/quickstart.html">Quick Guide</a> </p>
                        <p style="font-size: 18px;">You will love the simplicity of Cygnite Framework</p>
                    </div>

                    <div class="footerrow" align="center" style="clear:both;padding-top: 0px;">
                        <div class="footer-hr"></div>

<?php 
echo \Cygnite\Foundation\Application::poweredBy();
?>
                    </div>
                </div>
                <div class="footer-inner-right"> </div>
                <div class="clear"> </div>
            </div>

            <!-- ================================================== -->
            <!-- Placed at the end of the document so the pages load faster -->
<?php 
echo Asset::script('assets/js/cygnite/jquery.js');
?>

<style type="text/css">
Example #23
0
 /**
  * @param $func
  * @param $pattern
  * @throws \Exception
  * @return mixed
  */
 protected function mapStaticRoutes($pattern, $func)
 {
     $app = null;
     $app = App::instance();
     return $app['router']->get($pattern, $func);
 }
Example #24
0
 /**
  * Sets up the tests
  */
 public function setUp()
 {
     $this->app = Application::instance();
     $this->pipeline = new Pipeline($this->app);
 }
Example #25
0
 /** Return Url Instance
  *
  * @return static
  */
 public static function make()
 {
     $app = App::instance();
     return new static($app['router']);
 }
Example #26
0
 /**
  * Run the debugger to handle all exception and
  * display stack trace
  *
  *
  */
 public function run()
 {
     $handler = $this;
     $this->setCollapsePaths();
     //Add new panel to debug bar
     $this->addPanel(function ($e) use($handler) {
         if (!is_null($path = $handler->assetsPath())) {
             $contents = $handler->includeAssets($path);
         }
         if (!is_null($e)) {
             if ($handler->enableLogging == true) {
                 $this->log($e);
             }
             return array('tab' => $handler->name, 'panel' => '<h1>
                     <span class="heading-blue">
                     <a href="http://www.cygniteframework.com">' . $handler->name . ' </a>
                     </span>
                     </h1>
                     <p> Version : ' . Application::version() . ' </p>
                     <style type="text/css" class="tracy-debug">' . $contents . '</style>');
         }
     });
     $this->addPanel(function ($e) {
         if (!$e instanceof \PDOException) {
             return;
         }
         if (isset($e->queryString)) {
             $sql = $e->queryString;
         }
         return isset($sql) ? array('tab' => 'SQL', 'panel' => $sql) : NULL;
     });
 }
 /**
  * Get Application instance
  *
  * @return App
  */
 private function getApplication()
 {
     return App::instance();
 }
 public function register(Application $app)
 {
     $app['payment.api'] = $app->share(function ($c) {
         //return new PayPal();
     });
 }
Example #29
0
 /**
  * @param $arguments
  * @return object
  * @throws \Exception
  */
 private function callController($arguments)
 {
     $params = array();
     if (isset($arguments[1])) {
         $params = $arguments[1];
     }
     $this->setUpControllerAndMethodName($arguments);
     $file = CYGNITE_BASE . strtolower(str_replace('\\', DS, $this->namespace)) . $this->controller . EXT;
     if (!is_readable($file)) {
         throw new \Exception("Route " . array_pop($arguments) . " not found. ");
     }
     //include $file;
     $router = $this;
     // Get the instance of controller from Cygnite Container
     // and inject all dependencies into controller dynamically
     // It's cool. You can write powerful rest api using restful
     // routing
     return Application::instance(function ($app) use($router) {
         // make and return instance of controller
         $instance = $app->make($router->controllerWithNS);
         // inject all properties of controller defined in definition
         $app->propertyInjection($instance, $router->controllerWithNS);
         return $instance->{$router->method}();
     });
 }
Example #30
0
 /**
  * @return bool
  */
 public function terminate()
 {
     /**-------------------------------------------------------------------
      * Check if it is running via cli and return false
      * -------------------------------------------------------------------
      */
     $filename = preg_replace('#(\\?.*)$#', '', $_SERVER['REQUEST_URI']);
     if (php_sapi_name() === 'cli-server' && is_file($filename)) {
         return false;
     }
     Application::import('apps.routes');
 }