public function getComponentClassName($component, $parameters)
 {
     // Attempt to load an application component
     $type = $parameters['type'];
     $camelType = Text::ucamelize($type);
     $namespaces = $parameters['namespaces'];
     $className = Text::ucamelize($component) . $camelType;
     $class = "\\{$namespaces[0]}\\{$type}s\\{$component}\\{$className}";
     if (class_exists($class)) {
         return $class;
     }
     // Attempt to load a core dependency
     $class = "\\ntentan\\{$namespaces[1]}\\{$className}";
     if (class_exists($class)) {
         return $class;
     }
     // Attempt to load plugin dependency
     $componentPaths = explode(".", $component);
     $className = Text::ucamelize(array_pop($componentPaths));
     $class = "\\ntentan\\extensions\\" . implode("\\", $componentPaths) . "\\{$type}s\\{$className}{$camelType}";
     if (class_exists($class)) {
         return $class;
     }
     throw new exceptions\ComponentNotFoundException("[{$component}] {$type} not found");
 }
Exemple #2
0
 private static function getDriverClassName($driver)
 {
     if ($driver == null) {
         throw new exceptions\DatabaseDriverException("Please provide a valid driver name in your database config file");
     }
     return '\\ntentan\\atiaa\\drivers\\' . Text::ucamelize($driver) . "Driver";
 }
Exemple #3
0
 public function getModelClassName($model, $context)
 {
     if ($context == Relationship::BELONGS_TO) {
         $model = Text::pluralize($model);
     }
     return $this->getWyfClassName($model, 'models');
 }
Exemple #4
0
 private static function getMinifier($minifier)
 {
     $array = explode('.', $minifier);
     $minifierName = end($array);
     $class = __NAMESPACE__ . "\\minifiers\\" . reset($array) . '\\' . \ntentan\utils\Text::ucamelize($minifierName) . "Minifier";
     $instance = new $class();
     return $instance;
 }
Exemple #5
0
 public static function getDriverAdapterClassName()
 {
     $driver = Config::get('ntentan:db.driver', false);
     if ($driver) {
         return __NAMESPACE__ . '\\adapters\\' . Text::ucamelize(Config::get('ntentan:db.driver')) . 'Adapter';
     }
     throw new NibiiException("Please specify a driver");
 }
 public function runSetup()
 {
     if ($this->options['foreign_key'] == null) {
         $this->options['foreign_key'] = Text::singularize($this->setupTable) . '_id';
     }
     if ($this->options['local_key'] == null) {
         $this->options['local_key'] = $this->setupPrimaryKey[0];
     }
 }
 public function runSetup()
 {
     $model = InjectionContainer::resolve(Nibii::getClassName($this->options['model'], self::BELONGS_TO));
     if ($this->options['foreign_key'] == null) {
         $this->options['foreign_key'] = $model->getDescription()->getPrimaryKey()[0];
     }
     if ($this->options['local_key'] == null) {
         $this->options['local_key'] = Text::singularize($model->getTable()) . '_id';
     }
 }
Exemple #8
0
 public function __construct()
 {
     parent::__construct();
     $this->addOperation('edit');
     $this->addOperation('delete');
     TemplateEngine::appendPath(realpath(__DIR__ . '/../../views/crud'));
     TemplateEngine::appendPath(realpath(__DIR__ . '/../../views/forms'));
     View::set('entities', $this->getWyfName());
     View::set('entity', Text::singularize($this->getWyfName()));
     View::set('has_add_operation', true);
     View::set('form_template', str_replace('.', '_', $this->getWyfPackage()) . '_form');
 }
Exemple #9
0
 public static function start($store = '')
 {
     // setup the default store
     if ($store == '') {
         $store = Ntentan::$config[Ntentan::$context]['sessions.container'];
     }
     // Exit on the special none store means sessions are not needed
     if ($store == 'none') {
         return;
     }
     if ($store != '') {
         $handlerClass = "ntentan\\sessions\\stores\\" . Text::ucamelize($store) . 'Store';
         self::$handler = new $handlerClass();
         $configExpiry = Ntentan::$config[Ntentan::$context]['sessions.lifespan'];
         self::$lifespan = $configExpiry > 0 ? $configExpiry : self::$lifespan;
         session_set_save_handler(array(self::$handler, 'open'), array(self::$handler, 'close'), array(self::$handler, 'read'), array(self::$handler, 'write'), array(self::$handler, 'destroy'), array(self::$handler, 'gc'));
         register_shutdown_function('session_write_close');
     }
     session_start();
 }
Exemple #10
0
 private static function getController($routeArray, $basePath, $namespace, $controllerPath = "")
 {
     $path = array_shift($routeArray);
     $controllerClass = Text::ucamelize($path) . 'Controller';
     $controllerFile = "{$basePath}/controllers/{$controllerClass}.php";
     if ($path == "" && !empty($routeArray)) {
         return self::getController($routeArray, $basePath, $namespace, $controllerPath);
     } else {
         if (is_dir("{$basePath}/{$path}") && !empty($routeArray)) {
             // enter directories to find nested controllers
             return self::getController($routeArray, "{$basePath}/{$path}", "{$namespace}\\{$path}", "{$controllerPath}/{$path}");
         } else {
             if (file_exists($controllerFile)) {
                 // return controller info
                 return ['controller' => "{$namespace}\\controllers\\{$controllerClass}", 'action' => array_shift($routeArray), 'id' => implode('/', $routeArray), 'controller_path' => substr("{$controllerPath}/{$path}", 1)];
             } else {
                 return false;
             }
         }
     }
 }
 public function runSetup()
 {
     if (isset($this->options['through'])) {
         $junctionModelName = $this->options['through'];
     } else {
         $junctionModelName = Nibii::joinModels($this->setupName, $this->options['model']);
     }
     $this->options['junction_model'] = $junctionModelName;
     $foreignModel = Nibii::load($this->options['model']);
     if ($this->options['foreign_key'] == null) {
         $this->options['foreign_key'] = $foreignModel->getDescription()->getPrimaryKey()[0];
     }
     if ($this->options['local_key'] == null) {
         $this->options['local_key'] = $this->setupPrimaryKey[0];
     }
     if (!isset($this->options['junction_local_key'])) {
         $this->options['junction_local_key'] = Text::singularize($this->setupTable) . '_id';
     }
     if (!isset($this->options['junction_foreign_key'])) {
         $this->options['junction_foreign_key'] = Text::singularize($foreignModel->getTable()) . '_id';
     }
 }
Exemple #12
0
 public function executeControllerAction($action, $params)
 {
     $name = $this->getName();
     $path = Text::camelize($action);
     $return = null;
     $invokeParameters = [];
     if ($methodDetails = $this->getMethod($path)) {
         panie\InjectionContainer::bind(controllers\ModelBinderInterface::class)->to($methodDetails['binder']);
         $method = new \ReflectionMethod($this, $methodDetails['name']);
         honam\TemplateEngine::prependPath("views/{$name}");
         if (View::getTemplate() == null) {
             View::setTemplate("{$name}_{$action}" . '.tpl.php');
         }
         $methodParameters = $method->getParameters();
         foreach ($methodParameters as $methodParameter) {
             $this->bindParameter($invokeParameters, $methodParameter, $params);
         }
         $method->invokeArgs($this, $invokeParameters);
         $return = View::out();
         echo $return;
         return;
     } else {
         foreach ($this->loadedComponents as $component) {
             //@todo Look at how to prevent this from running several times
             if ($component->hasMethod($path)) {
                 $component->executeControllerAction($path, $params);
                 return;
             }
         }
     }
     throw new exceptions\ControllerActionNotFoundException($this, $path);
 }
Exemple #13
0
 /**
  * Initialize the caching engine.
  * Reads the current configuration to determine the caching backend to use.
  */
 public static function init()
 {
     $backend = Config::get('ntentan:cache.backend', 'volatile');
     self::$backendClass = '\\ntentan\\kaikai\\backends\\' . Text::ucamelize($backend) . 'Cache';
 }
Exemple #14
0
 private static function getEngineClass($engine)
 {
     return "ntentan\\honam\\template_engines\\" . \ntentan\utils\Text::ucamelize($engine);
 }
Exemple #15
0
 public function __call($function, $arguments)
 {
     if (substr($function, 0, 5) == "open_") {
         $container = __NAMESPACE__ . "\\form\\" . Text::ucamelize(substr($function, 5, strlen($function)));
         $containerClass = new ReflectionClass($container);
         $containerObject = $containerClass->newInstanceArgs($arguments);
         $return = $containerObject->renderHead();
     } elseif (substr($function, 0, 6) == "close_") {
         $container = __NAMESPACE__ . "\\form\\" . Text::ucamelize(substr($function, 6, strlen($function)));
         $containerClass = new ReflectionClass($container);
         $containerObject = $containerClass->newInstanceArgs($arguments);
         $return = $containerObject->renderFoot();
     } elseif (substr($function, 0, 4) == "get_") {
         $element = __NAMESPACE__ . "\\form\\" . Text::ucamelize(substr($function, 4, strlen($function)));
         $elementClass = new ReflectionClass($element);
         $elementObject = $elementClass->newInstanceArgs($arguments);
         $name = $elementObject->getName();
         if (isset($this->data[$name])) {
             $elementObject->setValue($this->data[$name]);
         }
         if (isset($this->errors[$name])) {
             $elementObject->setErrors($this->errors[$name]);
         }
         $return = $elementObject;
     } elseif (substr($function, 0, 4) == "add_") {
         $element = __NAMESPACE__ . "\\form\\" . Text::ucamelize(substr($function, 4, strlen($function)));
         $elementClass = new ReflectionClass($element);
         $elementObject = $elementClass->newInstanceArgs($arguments);
         $return = $this->container->add($elementObject);
     } else {
         throw new \ntentan\honam\exceptions\HelperException("Function *{$function}* not found in form helper.");
     }
     return $return;
 }
Exemple #16
0
 public function runDynamicMethod($arguments)
 {
     switch ($this->pendingMethod['method']) {
         case 'filterBy':
             $this->getQueryParameters()->addFilter(Text::deCamelize($this->pendingMethod['variable']), $arguments);
             return $this->wrapper;
         case 'sort':
             $this->getQueryParameters()->addSort(Text::deCamelize($this->pendingMethod['variable']), $this->pendingMethod['direction']);
             return $this->wrapper;
         case 'fetch':
             $parameters = $this->getQueryParameters();
             $parameters->addFilter(Text::deCamelize($this->pendingMethod['variable']), $arguments);
             if ($this->pendingMethod['first'] === 'First') {
                 $parameters->setFirstOnly(true);
             }
             return $this->doFetch();
     }
 }
Exemple #17
0
 public function __set($name, $value)
 {
     $this->dataSet = true;
     $this->modelData[Text::deCamelize($name)] = $value;
 }
 private function getSigninServiceObject($serviceType)
 {
     $serviceTypeClass = "\\ntentan\\extensions\\social\\components\\signin\\" . Text::ucamelize($serviceType) . "Signin";
     return new $serviceTypeClass();
 }
Exemple #19
0
 public function getControllerClassName($name)
 {
     return sprintf('\\%s\\controllers\\%sController', Ntentan::getNamespace(), utils\Text::ucamelize($name));
 }
Exemple #20
0
 public function __toString()
 {
     $type = $this->renderWithType == '' ? \ntentan\utils\Text::deCamelize($this->getType()) : $this->renderWithType;
     return TemplateEngine::render("wyf_inputs_forms_{$type}.tpl.php", $this->getTemplateVariables());
 }
Exemple #21
0
 public function testUnCamelCase()
 {
     $this->assertEquals('camel_case', Text::deCamelize("camelCase", '_'));
     $this->assertEquals('camel.case.joe', Text::deCamelize("CamelCaseJoe", '.'));
 }