Ejemplo n.º 1
0
 public static function getInstance()
 {
     if (is_null(self::$serviceLocator)) {
         self::$serviceLocator = new self();
     }
     return self::$serviceLocator;
 }
Ejemplo n.º 2
0
Archivo: Base.php Proyecto: no22/gongo
 /**
  * emailValidator
  * 
  * @return object
  */
 public function emailValidator()
 {
     if (is_null($this->emailValidator)) {
         $this->emailValidator = Gongo_Locator::get('Gongo_Str_Email');
     }
     return $this->emailValidator;
 }
Ejemplo n.º 3
0
Archivo: App.php Proyecto: no22/gongo
 static function initializeApplication($app, $path = null)
 {
     if (!is_null($path) && is_null(self::$appRootPath)) {
         self::$appRootPath = $path;
         if (is_null(self::$environment)) {
             self::$environment = Gongo_App_Environment::get(self::$appRootPath);
         }
         if (is_null(self::cfg())) {
             self::cfg(self::$environment->config);
         }
         // Locator
         $locator = Gongo_Locator::getInstance();
         $locator->config(self::$environment->config);
         $gongoBuilderClass = self::cfg()->Locator->Gongo_Builder;
         if ($gongoBuilderClass) {
             $locator->injectBuilder($gongoBuilderClass);
             self::$environment = Gongo_App_Environment::get(self::$appRootPath, true);
             self::cfg(self::$environment->config);
         }
         $errorReporting = self::cfg()->Error->error_reporting;
         if ($errorReporting) {
             error_reporting($errorReporting);
         }
         // autoloader
         spl_autoload_register('Gongo_App::autoload');
         // preload
         self::preload();
     }
     if (is_null(self::$application)) {
         self::$application = $app;
     }
     return $app;
 }
Ejemplo n.º 4
0
Archivo: Str.php Proyecto: no22/gongo
 static function getInstance()
 {
     if (is_null(self::$singleton)) {
         self::$singleton = Gongo_Locator::get('Gongo_Str_Base');
     }
     return self::$singleton;
 }
Ejemplo n.º 5
0
Archivo: Log.php Proyecto: no22/gongo
 static function get($path = null)
 {
     if (is_null(self::$log)) {
         $path = is_null($path) ? 'log.txt' : $path;
         self::$log = Gongo_Locator::get('Gongo_Log', $path);
     }
     return self::$log;
 }
Ejemplo n.º 6
0
 static function get($cfg = null)
 {
     if (is_null(self::$config)) {
         $cfg = is_null($cfg) ? dirname(__FILE__) . '/config.ini' : $cfg;
         self::$config = Gongo_Locator::get('Gongo_Config', $cfg);
     }
     return self::$config;
 }
Ejemplo n.º 7
0
Archivo: Base.php Proyecto: no22/gongo
 public function __get($key)
 {
     if ($key === '_') {
         if (is_null($this->__)) {
             return null;
         }
         $aComponents = $this->___initializeComponents();
         return $this->_ = Gongo_Locator::get('Gongo_Container', $aComponents);
     }
     return null;
 }
Ejemplo n.º 8
0
 public function instance($name, $eager = null)
 {
     list($component, $dependency, $lazy) = $this->services[$name];
     $args = array();
     foreach ($dependency as $service) {
         $args[] = $this->instance($service, $eager);
     }
     if (!is_null($eager)) {
         return $eager ? Gongo_Locator::make($component, $args) : Gongo_Locator::makeLazy($component, $args);
     }
     return $lazy ? Gongo_Locator::makeLazy($component, $args) : Gongo_Locator::make($component, $args);
 }
Ejemplo n.º 9
0
 public function filter($app, $src = null, $dst = null, $cast = false, $strict = false, $unset = true)
 {
     $filters = empty($this->options->filter) ? null : $this->options->filter;
     $src = is_null($src) ? $app->post : $src;
     $src = is_array($src) ? Gongo_Locator::get($this->options->defaultEntityClass, $src) : $src;
     $dst = is_null($dst) ? $src : $dst;
     $dst = is_array($dst) ? Gongo_Locator::get($this->options->defaultEntityClass, $dst) : $dst;
     if ($this->__filter) {
         return $this->filter->convert($src, $dst, $filters, $cast, $strict, $unset);
     }
     return $this->converter->convert($src, $dst, $filters, $cast, $strict, $unset);
 }
Ejemplo n.º 10
0
Archivo: Path.php Proyecto: no22/gongo
 function _twig()
 {
     return Gongo_Locator::get('Gongo_App_Path_Twig', $this);
 }
Ejemplo n.º 11
0
 public function initPath()
 {
     return Gongo_Locator::get('Gongo_App_Path_Mustache', Gongo_App::$environment->path, $this->templateType);
 }
Ejemplo n.º 12
0
 function __construct($path)
 {
     $this->path = $path;
     Gongo_Locator::load($this->libraryPath, 'Smarty');
     Smarty::muteExpectedErrors();
 }
Ejemplo n.º 13
0
 public function initFactory($aComponents = array())
 {
     $this->factory = Gongo_Locator::getInstance();
     $this->initializeComponents($aComponents);
 }
Ejemplo n.º 14
0
 function init()
 {
     Gongo_Locator::load($this->libraryPath, 'HamlParser');
 }
Ejemplo n.º 15
0
Archivo: Db.php Proyecto: no22/gongo
 function __get($name)
 {
     $className = $this->className($name);
     return Gongo_Locator::get($className, $this);
 }
Ejemplo n.º 16
0
 function init()
 {
     Gongo_Locator::load($this->libraryPath, 'Fammel');
 }
Ejemplo n.º 17
0
 function pages($args = array(), $hash = null, $short = true)
 {
     $range = $this->options->range;
     $last = $this->lastPage();
     $first = $this->firstPage();
     $page = $this->currentPage();
     $left = max($page - $range, $first);
     $right = min($page + $range, $last);
     if ($page <= $range) {
         $extend = $range - ($page - $left);
         $right = min($page + $range + $extend, $last);
     } else {
         if ($page + $range > $last) {
             $extend = $range - ($last - $page);
             $left = max($page - $range - $extend, $first);
         }
     }
     $pages = array();
     if ($last <= $first) {
         return $pages;
     }
     for ($i = $left; $i <= $right; $i++) {
         $bean = Gongo_Locator::get('Gongo_Bean');
         $bean->no = $i + 1;
         $bean->url = $this->buildUrl($i, $args, $hash, $short);
         $bean->current = $i == $page;
         $pages[$i] = $bean;
     }
     return $pages;
 }
Ejemplo n.º 18
0
 function __call($name, $args)
 {
     return Gongo_Locator::make('Gongo_' . $name, $args);
 }
Ejemplo n.º 19
0
 function init()
 {
     Gongo_Locator::load($this->libraryPath, 'PHPTAL');
 }
Ejemplo n.º 20
0
 function newBuilder()
 {
     return Gongo_Locator::get($this->defaultBuilder)->namedScopes($this->namedScopes());
 }
Ejemplo n.º 21
0
 function getRelationMapperInstance($class)
 {
     return Gongo_Locator::get($class, $this->db());
 }
Ejemplo n.º 22
0
Archivo: Fn.php Proyecto: no22/gongo
 static function property($obj)
 {
     return Gongo_Locator::get('Gongo_Fn_Property', $obj);
 }
Ejemplo n.º 23
0
Archivo: Ini.php Proyecto: no22/gongo
 public function parse()
 {
     return Gongo_Locator::get('Gongo_Bean', parse_ini_file($this->path, true));
 }
Ejemplo n.º 24
0
Archivo: core.php Proyecto: no22/gongo
 static function iter($path)
 {
     return Sloth::iter(Gongo_Locator::get('DirectoryIterator', $path));
 }
Ejemplo n.º 25
0
Archivo: GoQL.php Proyecto: no22/gongo
 public function __call($sName, $aArgs)
 {
     if (isset($this->_clause[$sName])) {
         return call_user_func(array($this, $this->_clause[$sName][1]), $this->_clause[$sName][0], $aArgs);
     }
     if (isset($this->_namedScopes[$sName])) {
         $this->setQuery($this->_namedScopes[$sName]);
         $methodName = isset($this->_query['method']) ? $this->_query['method'] : $this->_defaultMethod;
         $methodName = is_array($methodName) ? $methodName[0] : $methodName;
         return call_user_func_array(array($this, $methodName), $aArgs);
     }
     if ($sName[0] === '_') {
         $sName = substr($sName, 1);
         if (isset($this->_namedScopes[$sName])) {
             $query = $this->_namedScopes[$sName];
             $params = isset($query['params']) ? $query['params'] : null;
             return call_user_func(array($this->setQuery($this->_namedScopes[$sName]), '___bindParams'), $aArgs, $params);
         }
     }
     throw Gongo_Locator::get('Gongo_Db_GoQlException', "{$sName} was not found in GoQL method.");
 }
Ejemplo n.º 26
0
Archivo: Bean.php Proyecto: no22/gongo
 public function ___($ary = array())
 {
     $className = get_class($this);
     return Gongo_Locator::get($className, $ary);
 }
Ejemplo n.º 27
0
 function __construct($path)
 {
     $this->path = $path;
     Gongo_Locator::load($this->libraryPath, 'Smarty');
 }
Ejemplo n.º 28
0
 function _pdoBuilder()
 {
     return Gongo_Locator::get('Gongo_App_DB_PDO_Builder');
 }