Пример #1
0
 public function getUnderscored($className)
 {
     if (!isset($this->propsByClassUnderscored[$className])) {
         $attrsNames = [];
         foreach ($this->get($className) as $attrName => $value) {
             $underscoredName = \Rails::getService('inflector')->underscore($attrName)->toString();
             $attrsNames[$underscoredName] = $value;
         }
         # TODO: cache accordingly.
         $this->propsByClassUnderscored[$className] = $attrsNames;
     }
     return $this->propsByClassUnderscored[$className];
 }
Пример #2
0
 public function setProperties()
 {
     $this->migrationTemplate = 'migration.php';
     $fileName = $this->arg('name');
     $inflector = \Rails::getService('inflector');
     $this->migrationClassName = $inflector->camelize($fileName);
     switch (true) {
         // case (preg_match('/^(add|remove)_.*_(?:to|from)_(.*)/', $fileName, $m)):
         // $this->migrationAction = $m[1];
         // $this->tableName = $inflector->pluralize($m[2]);
         // break;
         // case (is_int(strpos($fileName, 'join_table'))):
         // break;
         case strpos($fileName, 'create_') === 0:
             $this->tableName = substr($fileName, 7);
             $this->migrationTemplate = 'create_table_migration.php';
             break;
     }
 }
Пример #3
0
 /**
  * @param array|Config $config
  */
 public function __construct()
 {
     $this->config = \Rails::getService('rails.config')['assets'];
 }
Пример #4
0
 public function t($key, array $options = [], $locale = null)
 {
     return \Rails::getService('i18n')->translate($key, $options, $locale);
 }