Ejemplo n.º 1
0
 /**
  * Initialize the class
  *
  * @static
  * @access public
  * @param Dotink\Inkwell\IW $app The application instance loading the class
  * @param array $config The configuration array for the class
  * @return boolean TRUE on success, FALSE on failure
  */
 public static function __init($app, array $config = array())
 {
     self::$databases = $app['databases'];
     self::$rootDirectory = $app->getRoot(__CLASS__);
     foreach ($app['config']->getByType('array', 'Model') as $eid => $model_config) {
         if (!isset($model_config['class'])) {
             continue;
         }
         if (empty($model_config['reflect'])) {
             if (isset($model_config['schema'])) {
                 ModelConfiguration::store($model_config['class'], $model_config['schema']);
             }
             continue;
         }
         $database_name = $model_config['reflect'];
         if (!isset(self::$databases[$database_name])) {
             throw new Flourish\ProgrammerException('Cannot reflect model %s to database %s, database not configured', $model_config['class'], $database_name);
         }
         if (empty($model_config['schema']['repo'])) {
             //
             // TODO: Centralize
             //
             $class_parts = explode('\\', $model_config['class']);
             $short_name = array_pop($class_parts);
             $namespace = implode('\\', $class_parts);
             $repository = ModelConfiguration::makeRepositoryName($short_name);
         } else {
             $repository = $model_config['schema']['repo'];
         }
         ModelConfiguration::reflect($model_config['class'], self::$databases[$database_name], $repository);
     }
     return TRUE;
 }
Ejemplo n.º 2
0
 /**
  * Generates or validates an etag in cache
  *
  * @static
  * @access private
  * @param string $cache_id The cache id for the resource
  * @param string $etag The etag for the resource
  * @param boolean $validate Whether or not we should just validate
  * @return boolean TRUE if validating and the etag matches, FALSE otherwise
  */
 private static function etag($cache_id, $etag, $validate = FALSE)
 {
     if (isset(self::$app['cache'])) {
         $cache_key = md5(self::$app->getRoot() . __CLASS__ . 'ETAGS' . $cache_id);
         if ($validate) {
             return self::$app['cache']->get($cache_key) == $etag;
         } else {
             self::$app['cache']->set($cache_key, $etag);
         }
     }
     return FALSE;
 }
Ejemplo n.º 3
0
 /**
  * Initialize the class
  *
  * @static
  * @access public
  * @param Dotink\Inkwell\IW $app The application instance loading the class
  * @param array $config The configuration array for the class
  * @return boolean TRUE on success, FALSE on failure
  */
 public static function __init($app, array $config = array())
 {
     self::$defaultRoot = $app->getRoot(__CLASS__);
     if (isset($config['helper_directory'])) {
         self::$helperDirectory = $app->getRoot(NULL, $config['helper_directory']);
     }
     if (isset($config['cache_directory'])) {
         self::$cacheDirectory = $config['cache_directory'];
     }
     if (isset($config['extension_map']) && is_array($config['extension_map'])) {
         self::$extensionMap = array_merge(self::$extensionMap, $config['extension_map']);
     }
     if (isset($config['asset_filters']) && is_array($config['asset_filters'])) {
         self::$assetFilters = array_merge_recursive(self::$assetFilters, $config['asset_filters']);
     }
     self::$app = $app;
 }
Ejemplo n.º 4
0
 /**
  * Initialize the class
  *
  * @static
  * @access public
  * @param Dotink\Inkwell\IW $app The application instance loading the class
  * @param array $config The configuration array for the class
  * @return boolean TRUE on success, FALSE on failure
  */
 public static function __init($app, array $config = array())
 {
     self::$app = $app;
     self::$root = $app->getRoot(__CLASS__, self::DEFAULT_ROOT_DIRECTORY);
     foreach ($app['config']->getByType('array', 'Library') as $eid => $library_config) {
         if (!empty($library_config['auto_scaffold'])) {
             self::$autoScaffoldClasses[] = $library_config['class'];
         }
     }
     if (isset($config['scope']) && is_array($config['scope'])) {
         self::$defaultScope = $config['scope'];
     }
 }