Пример #1
0
 public function getCommandName()
 {
     if (is_null($this->action) || is_null($this->resource)) {
         return null;
     }
     return Sonata_Utils::camelize($this->action) . Sonata_Utils::camelize($this->resource);
 }
Пример #2
0
<?php

/**
 * This file is part of the Sonata RESTful PHP framework
 * (c) 2009-2010 Pascal Cremer <*****@*****.**>
 *
 * @author Pascal Cremer <*****@*****.**>
 */
require_once dirname(__FILE__) . '/bootstrap.php';
$t = new LimeTest();
// @Test: ::camelize()
$t->is(Sonata_Utils::camelize('foo_bar_baz'), 'FooBarBaz', 'The string was camelized correctly');
$t->is(Sonata_Utils::camelize('foo_bar_baz', true), 'fooBarBaz', 'The string was camelized correctly, starting lower-case');
$t->is(Sonata_Utils::camelize('foo _ bar _baz'), 'FooBarBaz', 'Whitespaces are ignored');
$t->is(Sonata_Utils::camelize(''), '', 'Empty strings are retuned untouched');
// @Test: ::underscore()
$t->is(Sonata_Utils::underscore('FooBar'), 'foo_bar', 'The string was underscored correctly');
$t->is(Sonata_Utils::underscore('myFooBar'), 'my_foo_bar', 'It even works for camelized strings that start lower-case');
$t->is(Sonata_Utils::underscore('Foo Bar-!/#Baz'), 'foo_bar_baz', 'Whitespaces and non-digit characters are ignored');
$t->is(Sonata_Utils::underscore(''), '', 'Empty strings are retuned untouched');
// @Test: ::slugify()
$t->is(Sonata_Utils::slugify('Here be dragons!'), 'here-be-dragons', 'The string was slugified correctly');
$t->is(Sonata_Utils::slugify('Hérè be drägons!'), 'here-be-dragons', 'Transforms UTF-8 characters correctly');
$t->is(Sonata_Utils::slugify(''), 'n-a', '\'n-a\' is returned for empty strings');
Пример #3
0
 public function getControllerClassName(Sonata_Request $request)
 {
     $resource = $request->getParameter('resource');
     if (!$resource) {
         return null;
     }
     return ucfirst(Sonata_Utils::camelize($resource)) . 'Controller';
 }