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]; }
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; } }
/** * @param array|Config $config */ public function __construct() { $this->config = \Rails::getService('rails.config')['assets']; }
public function t($key, array $options = [], $locale = null) { return \Rails::getService('i18n')->translate($key, $options, $locale); }