Ejemplo n.º 1
0
 public static function isControllerExists($controllerName, $namespace = null)
 {
     if (empty($namespace)) {
         $namespace = self::$_activeNamespace;
     }
     $fullControllerName = ucfirst($namespace) . '\\Controllers\\' . ucfirst(Inflector::camelize($controllerName));
     return class_exists($fullControllerName);
 }
Ejemplo n.º 2
0
 public function initialize()
 {
     $this->_storePath = self::$_baseStoreLocation . $this->_modelName . '/';
     $this->publishMethod('loadFiles');
     $this->publishMethod('deleteFile');
     $this->publishMethod('attachFileFromPath');
     $this->publishMethod('attachFilesFromArray');
     $this->publishMethod('setFieldNameForAlias');
     $this->publishMethod('skipFileAliasForSave');
     foreach (array_keys($this->_config) as $alias) {
         $this->publishMethod('get' . Inflector::camelize($alias));
     }
 }
Ejemplo n.º 3
0
 /**
  * Generates default database model structure
  */
 public function modelAction()
 {
     $name = ucfirst(Inflector::camelize($this->getFirstParamOrAsk('Enter model name')));
     $path = DC::getEnvironment()->getUserClassesRoot() . 'db/';
     $mo = ModelOperator::getInstance($path);
     if ($mo->getModelStructure($name)) {
         $this->warning('model ' . $name . ' is already exists', '~ model exists, skipping:');
         return true;
     }
     $mo->generateBasicStructure($name);
     $mo->saveModelStructure($name);
     $this->notify($path . 'structure/' . $name . '.yml', '+ model created');
 }
Ejemplo n.º 4
0
 /**
  * @param $tag\
  * @param $token
  * @return BaseBlock
  */
 private function getBlockObject($tag, $token)
 {
     $namespace = isset($this->_blocks[$tag]['namespace']) ? $this->_blocks[$tag]['namespace'] : '\\Solve\\Slot\\Blocks\\';
     $blockClassName = $namespace . Inflector::camelize($tag . 'Block');
     /**
      * @var BaseBlock $blockObject
      */
     $blockObject = new $blockClassName($token, $this);
     return $blockObject;
 }
Ejemplo n.º 5
0
 public function offsetSet($offset, $value)
 {
     if (method_exists($this, 'set' . Inflector::camelize($offset))) {
         $this->{'set' . Inflector::camelize($offset)}($value);
     }
     $this->_data[$offset] = $value;
     $this->_changedData[$offset] = $value;
     if (array_key_exists($offset, $this->_invokedGetters)) {
         $this->_invokedGetters[$offset] = $value;
     }
 }
Ejemplo n.º 6
0
Archivo: Slot.php Proyecto: solve/slot
 public function registerBlock($block, $namespace = '\\Solve\\Slot\\Blocks\\')
 {
     $className = Inflector::camelize($block . 'Block');
     $r = new \ReflectionClass($namespace . $className);
     $doc = $r->getDocComment();
     $config = array('paired' => strpos($doc, '@paired') !== false, 'runtime' => strpos($doc, '@runtime') !== false, 'namespace' => $namespace);
     $this->_compiler->registerBlock($block, $config);
 }
Ejemplo n.º 7
0
 /**
  * @param $modelName
  * @param $abilityName
  * @return BaseModelAbility
  * @throws \Exception
  */
 public static function getAbilityInstanceForModel($modelName, $abilityName)
 {
     $abilityClass = '\\Solve\\Database\\Models\\Abilities\\' . Inflector::camelize($abilityName) . 'Ability';
     if (!class_exists($abilityClass)) {
         throw new \Exception('Ability ' . $abilityName . ' not found');
     }
     $abilityInstance = call_user_func(array($abilityClass, 'getInstanceForModel'), $modelName);
     self::cacheAbilitiesMethods($modelName, $abilityName, $abilityInstance);
     return $abilityInstance;
 }
Ejemplo n.º 8
0
 /**
  * @param mixed $offset
  * @param Model $value
  * @throws \Exception
  */
 public function offsetSet($offset, $value)
 {
     if (method_exists($this, 'set' . Inflector::camelize($offset))) {
         $this->{'set' . Inflector::camelize($offset)}($value);
     }
     if (is_null($offset)) {
         if (!is_object($value) || $value->isNew()) {
             throw new \Exception('Trying to add empty or non-object item to collection');
         }
         $offset = count($this->_data);
         if (array_key_exists($value->getID(), $this->_pk_map)) {
             throw new \Exception('Object with id ' . $value[$this->_primaryKey] . ' already exists in collection');
         }
         $this->_pk_map[$value->getID()] = $offset;
     }
     $this->_data[$offset] = $value;
 }
Ejemplo n.º 9
0
 public function testCamlize()
 {
     $this->assertEquals('HelloWorld', Inflector::camelize('hello world'), 'camelize');
     $this->assertEquals('HelloBigWorld', Inflector::camelize('hello_ big   world'), 'camelize underscore and space');
 }
Ejemplo n.º 10
0
 public function detectApplication()
 {
     DC::getEventDispatcher()->dispatchEvent('route.buildRequest', Request::getIncomeRequest());
     /**
      * @var ArrayStorage $appList
      */
     $appList = DC::getProjectConfig('applications');
     if (empty($appList)) {
         throw new \Exception('Empty application list');
     }
     $defaultAppName = DC::getProjectConfig('defaultApplication', 'frontend');
     $this->_name = $defaultAppName;
     $uri = (string) Request::getIncomeRequest()->getUri();
     $uriParts = explode('/', $uri);
     $webRoot = DC::getRouter()->getWebRoot();
     if (strlen($webRoot) > 1) {
         if (strpos($uri, substr($webRoot, 1)) === 0) {
             $uriParts = explode('/', substr($uri, strlen($webRoot)));
         }
     }
     if (!empty($uriParts) && (count($uriParts) > 0 && $uriParts[0] != '/')) {
         foreach ($appList as $appName => $appParams) {
             if ($appName == $defaultAppName) {
                 continue;
             }
             $appUri = !empty($appParams['uri']) ? $appParams['uri'] : $appName;
             if (strpos($uriParts[0], $appUri) === 0) {
                 array_shift($uriParts);
                 Request::getIncomeRequest()->setUri((strlen($webRoot) > 1 ? $webRoot . '/' : '') . implode('/', $uriParts));
                 $this->_name = $appName;
                 break;
             }
         }
     }
     $this->_config = DC::getProjectConfig('applications/' . $this->_name);
     if (!is_array($this->_config)) {
         $this->_config = array('uri' => $this->_name);
     }
     if (empty($this->_config['path'])) {
         $this->_config['path'] = Inflector::camelize($this->_name) . '/';
     }
     $this->_namespace = Inflector::camelize($this->_name);
     $this->_root = DC::getEnvironment()->getApplicationRoot() . $this->_config['path'];
     DC::getAutoloader()->registerNamespacePath($this->_namespace, DC::getEnvironment()->getApplicationRoot());
     ControllerService::setActiveNamespace($this->_namespace);
     return $this->_name;
 }
Ejemplo n.º 11
0
 private static function _prepareActionName($string)
 {
     return lcfirst(Inflector::camelize($string));
 }