Skip to content

Commit

Permalink
Fix some CS
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Rabaix committed May 3, 2012
1 parent 59285d5 commit df2df50
Show file tree
Hide file tree
Showing 54 changed files with 436 additions and 247 deletions.
26 changes: 14 additions & 12 deletions Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ protected function buildList()

$this->configureListFields($mapper);

foreach($this->getExtensions() as $extension) {
foreach ($this->getExtensions() as $extension) {
$extension->configureListFields($mapper);
}
}
Expand Down Expand Up @@ -709,7 +709,7 @@ public function buildDatagrid()
));
}

foreach($this->getExtensions() as $extension) {
foreach ($this->getExtensions() as $extension) {
$extension->configureDatagridFilters($mapper);
}
}
Expand Down Expand Up @@ -851,7 +851,7 @@ public function getBatchActions()

if ($this->hasRoute('delete') && $this->isGranted('DELETE')) {
$actions['delete'] = array(
'label' => $this->trans('action_delete', array(), 'SonataAdminBundle'),
'label' => $this->trans('action_delete', array(), 'SonataAdminBundle'),
'ask_confirmation' => true, // by default always true
);
}
Expand Down Expand Up @@ -934,6 +934,7 @@ public function getRoute($name)

/**
* @param $name
*
* @return bool
*/
public function hasRoute($name)
Expand All @@ -948,8 +949,8 @@ public function hasRoute($name)
* Generates the object url with the given $name
*
* @param string $name
* @param $object
* @param array $parameters
* @param $object
* @param array $parameters
*
* @return return a complete url
*/
Expand Down Expand Up @@ -1100,7 +1101,7 @@ public function defineFormBuilder(FormBuilder $formBuilder)

$this->configureFormFields($mapper);

foreach($this->getExtensions() as $extension) {
foreach ($this->getExtensions() as $extension) {
$extension->configureFormFields($mapper);
}
}
Expand Down Expand Up @@ -1365,11 +1366,11 @@ public function setShowGroups(array $showGroups)

/**
* @param string $group
* @param array $keys
* @param array $keys
*/
public function reorderShowGroup($group, array $keys)
{
$showGroups = $this->getShowGroups();
$showGroups = $this->getShowGroups();
$showGroups[$group]['fields'] = array_merge(array_flip($keys), $showGroups[$group]['fields']);
$this->setShowGroups($showGroups);
}
Expand Down Expand Up @@ -1469,7 +1470,7 @@ public function hasFormFieldDescription($name)
/**
* add a FieldDescription
*
* @param string $name
* @param string $name
* @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
*
* @return void
Expand Down Expand Up @@ -1866,6 +1867,7 @@ public function buildBreadcrumbs($action, MenuItemInterface $menu = null)
* set the current child status
*
* @param boolean $currentChild
*
* @return void
*/
public function setCurrentChild($currentChild)
Expand Down Expand Up @@ -2270,15 +2272,15 @@ public function id($entity)
*/
public function setValidator(ValidatorInterface $validator)
{
$this->validator = $validator;
$this->validator = $validator;
}

/**
* {@inheritdoc}
*/
public function getValidator()
{
return $this->validator;
return $this->validator;
}

/**
Expand Down Expand Up @@ -2377,7 +2379,7 @@ public function getRouteBuilder()
public function toString($object)
{
if (method_exists($object, '__toString')) {
return (string) $object;
return (string)$object;
}

return '';
Expand Down
8 changes: 5 additions & 3 deletions Admin/AdminExtensionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,18 @@ function configureRoutes(AdminInterface $admin, RouteCollection $collection);
function configureSideMenu(AdminInterface $admin, MenuItemInterface $menu, $action, AdminInterface $childAdmin = null);

/**
* @param AdminInterface $admin
* @param AdminInterface $admin
* @param \Sonata\AdminBundle\Validator\ErrorElement $errorElement
* @param $object
* @param $object
*
* @return void
*/
function validate(AdminInterface $admin, ErrorElement $errorElement, $object);

/**
* @param \Sonata\AdminBundle\Datagrid\ProxyQueryInterface $query
* @param string $context
* @param string $context
*
* @return void
*/
function configureQuery(AdminInterface $admin, ProxyQueryInterface $query, $context = 'list');
Expand Down
28 changes: 19 additions & 9 deletions Admin/AdminHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ public function __construct(Pool $pool)

/**
* @throws \RuntimeException
*
* @param \Symfony\Component\Form\FormBuilder $formBuilder
* @param $elementId
* @param $elementId
*
* @return \Symfony\Component\Form\FormBuilder
*/
public function getChildFormBuilder(FormBuilder $formBuilder, $elementId)
Expand All @@ -47,7 +49,8 @@ public function getChildFormBuilder(FormBuilder $formBuilder, $elementId)

/**
* @param \Symfony\Component\Form\FormView $formView
* @param $elementId
* @param $elementId
*
* @return null|\Symfony\Component\Form\FormView
*/
public function getChildFormView(FormView $formView, $elementId)
Expand All @@ -63,7 +66,9 @@ public function getChildFormView(FormView $formView, $elementId)

/**
* @deprecated
*
* @param string $code
*
* @return \Sonata\AdminBundle\Admin\AdminInterface
*/
public function getAdmin($code)
Expand All @@ -78,16 +83,18 @@ public function getAdmin($code)
* only for direct FieldDescription (not nested one)
*
* @throws \RuntimeException
*
* @param \Sonata\AdminBundle\Admin\AdminInterface $admin
* @param string $elementId
* @param string $elementId
*
* @return array
*/
public function appendFormFieldElement(AdminInterface $admin, $elementId)
{
// retrieve the subject
$formBuilder = $admin->getFormBuilder();

$form = $formBuilder->getForm();
$form = $formBuilder->getForm();
$form->bindRequest($admin->getRequest());

// get the field element
Expand All @@ -109,8 +116,8 @@ public function appendFormFieldElement(AdminInterface $admin, $elementId)
$data[$childFormBuilder->getName()] = array();
}

$objectCount = count($value);
$postCount = count($data[$childFormBuilder->getName()]);
$objectCount = count($value);
$postCount = count($data[$childFormBuilder->getName()]);

$fields = array_keys($fieldDescription->getAssociationAdmin()->getFormFieldDescriptions());

Expand All @@ -121,7 +128,7 @@ public function appendFormFieldElement(AdminInterface $admin, $elementId)
}

// add new elements to the subject
while($objectCount < $postCount) {
while ($objectCount < $postCount) {
// append a new instance into the object
$this->addNewInstance($form->getData(), $fieldDescription);
$objectCount++;
Expand All @@ -141,8 +148,9 @@ public function appendFormFieldElement(AdminInterface $admin, $elementId)
/**
* Add a new instance to the related FieldDescriptionInterface value
*
* @param object $object
* @param object $object
* @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
*
* @return void
*/
public function addNewInstance($object, FieldDescriptionInterface $fieldDescription)
Expand All @@ -163,11 +171,13 @@ public function addNewInstance($object, FieldDescriptionInterface $fieldDescript
* Camelize a string
*
* @static
*
* @param string $property
*
* @return string
*/
public function camelize($property)
{
return preg_replace(array('/(^|_| )+(.)/e', '/\.(.)/e'), array("strtoupper('\\2')", "'_'.strtoupper('\\1')"), $property);
return preg_replace(array('/(^|_| )+(.)/e', '/\.(.)/e'), array("strtoupper('\\2')", "'_'.strtoupper('\\1')"), $property);
}
}
13 changes: 7 additions & 6 deletions Admin/AdminInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ function setParentFieldDescription(FieldDescriptionInterface $parentFieldDescrip
* translate a message id
*
* @param string $id
* @param array $parameters
* @param null $domain
* @param null $locale
* @param array $parameters
* @param null $domain
* @param null $locale
*
* @return string the translated string
*/
Expand All @@ -192,16 +192,17 @@ function getRouterIdParameter();
*
* @return void
*/
function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription);
function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription);

/**
* add a list FieldDescription
*
* @param string $name
* @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
*
* @return void
*/
function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription);
function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription);

/**
* add a filter FieldDescription
Expand Down Expand Up @@ -233,7 +234,7 @@ function setSecurityHandler(SecurityHandlerInterface $securityHandler);
function getSecurityHandler();

/**
* @param string $name
* @param string $name
* @param object|null $object
*
* @return boolean
Expand Down
8 changes: 5 additions & 3 deletions Admin/BaseFieldDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function setName($name)
$this->name = $name;

if (!$this->getFieldName()) {
$this->setFieldName(substr(strrchr('.'.$name, '.') ,1));
$this->setFieldName(substr(strrchr('.' . $name, '.'), 1));
}
}

Expand Down Expand Up @@ -316,8 +316,8 @@ public function getFieldValue($object, $fieldName)
if ($this->getOption('code')) {
$getters[] = $this->getOption('code');
}
$getters[] = 'get'.$camelizedFieldName;
$getters[] = 'is'.$camelizedFieldName;
$getters[] = 'get' . $camelizedFieldName;
$getters[] = 'is' . $camelizedFieldName;


foreach ($getters as $getter) {
Expand Down Expand Up @@ -389,7 +389,9 @@ public function getMappingType()
* Camelize a string
*
* @static
*
* @param string $property
*
* @return string
*/
public static function camelize($property)
Expand Down
1 change: 1 addition & 0 deletions Admin/FieldDescriptionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function has($name)

/**
* @throws \InvalidArgumentException
*
* @param string $name
*
* @return FieldDescriptionInterface
Expand Down
Loading

0 comments on commit df2df50

Please sign in to comment.