コード例 #1
0
 /**
  * Underscore to camelcase table name to namespaced table gateway classname,
  * e.g. directus_users => \Directus\Db\TableGateway\DirectusUsersTableGateway
  */
 public static function makeTableGatewayFromTableName($acl, $table, $adapter)
 {
     $tableGatewayClassName = Formatting::underscoreToCamelCase($table) . "TableGateway";
     $tableGatewayClassName = __NAMESPACE__ . "\\{$tableGatewayClassName}";
     if (class_exists($tableGatewayClassName)) {
         return new $tableGatewayClassName($acl, $adapter);
     }
     return new self($acl, $table, $adapter);
 }
コード例 #2
0
 /**
  * HELPER FUNCTIONS
  */
 public static function makeRowGatewayFromTableName($acl, $table, $adapter, $pkFieldName = 'id')
 {
     // Underscore to camelcase table name to namespaced row gateway classname,
     // e.g. directus_users => \Directus\Db\RowGateway\DirectusUsersRowGateway
     $rowGatewayClassName = Formatting::underscoreToCamelCase($table) . "RowGateway";
     $rowGatewayClassName = __NAMESPACE__ . "\\{$rowGatewayClassName}";
     if (class_exists($rowGatewayClassName)) {
         return new $rowGatewayClassName($acl, $pkFieldName, $table, $adapter);
     }
     return new self($acl, $pkFieldName, $table, $adapter);
 }
コード例 #3
0
 /**
  * @param $table
  * @param $adapter
  * @param string $primaryKeyColumn
  *
  * @return BaseRowGateway
  */
 public static function makeRowGatewayFromTableNameSkipAcl($table, $adapter, $primaryKeyColumn = 'id')
 {
     // Underscore to camelcase table name to namespaced row gateway classname,
     // e.g. directus_users => \Directus\Db\RowGateway\DirectusUsersRowGateway
     $rowGatewayClassName = Formatting::underscoreToCamelCase($table) . 'RowGateway';
     $rowGatewayClassName = __NAMESPACE__ . '\\' . $rowGatewayClassName;
     if (class_exists($rowGatewayClassName)) {
         return new $rowGatewayClassName($primaryKeyColumn, $table, $adapter);
     }
     return new self($primaryKeyColumn, $table, $adapter);
 }
コード例 #4
0
ファイル: FormattingTest.php プロジェクト: hyrmedia/directus
 public function testUnderscoreToCamelCase()
 {
     $this->assertEquals(Formatting::underscoreToCamelCase('hello_world'), 'HelloWorld');
 }