Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
314e3a5
Refactoring builder parser: no changes, just reducing nesting
sescandell Dec 24, 2015
f67e0eb
CamelCase
sescandell Dec 24, 2015
e0feb9c
Go back to credentials: ListBuilderAction
sescandell Dec 24, 2015
7606396
Manage ListTemplates
sescandell Dec 24, 2015
7b74a1a
Update nestedlist templates
sescandell Dec 24, 2015
c105bc1
Update actions templates
sescandell Dec 24, 2015
e1817fe
Update edit action templates
sescandell Dec 24, 2015
c0ca52b
Update Edit template templates
sescandell Dec 24, 2015
a2b13ae
Update forms
sescandell Dec 24, 2015
71d239b
Update Excel action template.
sescandell Dec 24, 2015
8ea96bd
Update filters type form
sescandell Dec 24, 2015
3b2acd8
Update new action template
sescandell Dec 24, 2015
d44ea5b
Update show action templates
sescandell Dec 24, 2015
d63363d
Update show template template
sescandell Dec 24, 2015
d89be91
Move to echo_if_granted in templates
sescandell Dec 27, 2015
f7fc179
Allow JMS Security Extra Bundle as an option for credentials
sescandell Dec 27, 2015
fe94ed8
Fix credentials checks with new Twig filter: clean
sescandell Dec 27, 2015
3be9252
Fix tests
sescandell Dec 27, 2015
0ca64cd
Adding tests
sescandell Dec 27, 2015
95f4bcb
Adding tests environments
sescandell Dec 27, 2015
8c1c48b
Remove useless variables for travis
sescandell Dec 27, 2015
22cf90b
Adding PHP7.0 to travis
sescandell Dec 28, 2015
f55dafb
Remove useless array_merge calls
sescandell Dec 28, 2015
d7e292a
Rewrite GenerateAdminAdminCommand
sescandell Dec 28, 2015
c0ffd3a
Remove useless command: only one is enough for admin pages generation
sescandell Dec 28, 2015
40df502
FIX Command mistakes
sescandell Dec 28, 2015
077e51d
FIX Generator command
sescandell Dec 28, 2015
6ad8381
FIX Command: TODO, fix generation
sescandell Dec 28, 2015
918ee1e
FIX GenerateAdminAdminCommand
sescandell Jan 2, 2016
f50f917
Rename GenerateAdminAdminCommand to GenerateAdminCommand
sescandell Jan 2, 2016
5a7ffe3
Minor changes
sescandell Jan 2, 2016
92d78b8
Remove error displayed whereas it's not
sescandell Jan 2, 2016
3df7447
FIX columns check
sescandell Jan 2, 2016
da6e1e8
FIX credentials checks
sescandell Jan 2, 2016
d108e1d
Correctly clean credentials for if_one_granted
sescandell Jan 2, 2016
3830b40
FIX Excel action template
sescandell Jan 2, 2016
352343d
Update form credentials check... Should we use Voter?
sescandell Jan 2, 2016
c4925d5
Take into account credentials from params builders for generic actions
sescandell Jan 3, 2016
f9bb0c5
Improve credentials checks on form: allowing a field to be displayed …
sescandell Jan 3, 2016
737bb3c
Rewriting doc
sescandell Jan 3, 2016
d2a65e3
Remove deprecated calls. Plan to dump Symfony version to 2.8 min
sescandell Jan 3, 2016
7cc706e
Fix wrong template
sescandell Jan 3, 2016
3473b9a
Remove dependency on ContainerAware for Guessers: removed deprecated …
sescandell Jan 3, 2016
4ae4d4a
FIX previous commit: wrong service updated
sescandell Jan 3, 2016
3d9eb7f
FIX wrong service name for field guesser orm
sescandell Jan 3, 2016
a765e71
Update field guesser service registration
sescandell Jan 3, 2016
e940adf
Remove dependency on Container for menu builder
sescandell Jan 3, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ php:
- 5.3
- 5.4
- 5.5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add PHP 5.6 and 7.0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in #22cf90b

Thanks,


env:
- SYMFONY_VERSION=origin/2.6
- 5.6
- 7.0

before_script:
- composer self-update
Expand Down
11 changes: 11 additions & 0 deletions Builder/Admin/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ public function setColumnClass($columnClass)
}

/**
* @param Column $column
* @param string $optionName
* @param string $default
*
* @return string
*/
protected function getFieldOption(Column $column, $optionName, $default = null)
{
Expand Down Expand Up @@ -405,6 +409,13 @@ protected function setUserActionConfiguration(Action $action)
$action->setProperty($option, $value);
}
}

if ('generic' == $action->getType()) {
// Let's try to get credentials from builder for consistency
if ($credentials = $this->generator->getFromYaml(sprintf('builders.%s.params.credentials', $action->getName()))) {
$action->setCredentials($credentials);
}
}
}

protected function addAction(Action $action)
Expand Down
18 changes: 9 additions & 9 deletions Builder/Admin/ListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ protected function addFilterColumn(Column $column)
$this->filterColumns[$column->getName()] = $column;
}

public function getFilterColumnGroups()
public function getFilterColumnsCredentials()
{
$groups = array();
$credentials = array();

foreach ($this->getFilterColumns() as $column) {
$columnGroups = $column->getFiltersGroups();
// If one column has no Group constraint, we always
// have to display the filter panel
if (empty($columnGroups)) {
foreach($this->getFilterColumns() as $column) {
if (! $filterCredentials = $column->getFiltersCredentials()) {
// If one column has no Credentials constraint, we always
// have to display the filter panel
return array();
}
$groups = array_merge($groups, $columnGroups);

$credentials[] = $filterCredentials;
}

return $groups;
return $credentials;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion Builder/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public function getVariables()
* (non-PHPdoc)
* @see Builder/Admingenerator\GeneratorBundle\Builder.BuilderInterface::hasVariable()
* @param string $key
* @return bool
*/
public function hasVariable($key)
{
Expand Down Expand Up @@ -169,7 +170,7 @@ public function getModelClass()
/**
* Set the generator.
*
* @param \Admingenerator\GeneratorBundle\Builder\Generator $generator A generator.
* @param \TwigGenerator\Builder\Generator $generator A generator.
*/
public function setGenerator(GenericBaseGenerator $generator)
{
Expand Down
101 changes: 54 additions & 47 deletions Builder/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,44 +118,50 @@ public function addBuilder(BuilderInterface $builder)
protected function mergeParameters(array $global, array $builder)
{
foreach ($global as $param => &$value) {
if (array_key_exists($param, $builder)) {
if (in_array($param, array('fields', 'actions', 'object_actions', 'batch_actions'))) {
// Grab builder configuration only if defined
if (!is_null($builder[$param])) {
$configurations = array();
foreach ($builder[$param] as $name => $configuration) {
if (is_array($configuration) || is_null($configuration)) {
if (!is_null($value) && array_key_exists($name, $value)) {
$configurations[$name] = $configuration
? $this->mergeConfiguration($value[$name], $configuration) // Override definition
: $value[$name]; // Configuration is null => use global definition
} else {
// New definition (new field, new action) from builder
$configurations[$name] = $configuration;
}
} else {
throw new \InvalidArgumentException(
sprintf('Invalid %s "%s" builder definition for %s', $param, $name, $this->getFromYaml('params.model'))
);
}
}

if (in_array($param, array('actions', 'object_actions', 'batch_actions'))) {
// Actions list comes from builder
$value = $configurations;
} else {
// All fields are still available in a builder
$value = array_merge($value ?:array(), $configurations);
}
}
if (!array_key_exists($param, $builder)) {
continue;
}

if (!in_array($param, array('fields', 'actions', 'object_actions', 'batch_actions'))) {
if (is_array($value)) {
$value = $this->recursiveReplace($value, $builder[$param]);
} else {
$value = $builder[$param];
}

continue;
}

// Grab builder configuration only if defined
if (is_null($builder[$param])) {
continue;
}

$configurations = array();
foreach ($builder[$param] as $name => $configuration) {
if (!is_array($configuration) && !is_null($configuration)) {
throw new \InvalidArgumentException(
sprintf('Invalid %s "%s" builder definition for %s', $param, $name, $this->getFromYaml('params.model'))
);
}

if (!is_null($value) && array_key_exists($name, $value)) {
$configurations[$name] = $configuration
? $this->mergeConfiguration($value[$name], $configuration) // Override definition
: $value[$name]; // Configuration is null => use global definition
} else {
if (is_array($value)) {
$value = $this->recursiveReplace($value, $builder[$param]);
} else {
$value = $builder[$param];
}
// New definition (new field, new action) from builder
$configurations[$name] = $configuration;
}
}

if (in_array($param, array('actions', 'object_actions', 'batch_actions'))) {
// Actions list comes from builder
$value = $configurations;
} else {
// All fields are still available in a builder
$value = array_merge($value ?:array(), $configurations);
}
}

// If builder doesn't have actions/object_actions/batch_actions remove it from merge.
Expand All @@ -177,20 +183,21 @@ protected function mergeParameters(array $global, array $builder)
protected function mergeConfiguration(array $global, array $builder)
{
foreach ($global as $name => &$value) {
if (array_key_exists($name, $builder)) {
if (is_null($builder[$name])) {
continue;
}
if (!array_key_exists($name, $builder) || is_null($builder[$name])) {
continue;
}

if (is_array($value)) {
if (!is_array($builder[$name])) {
throw new \InvalidArgumentException('Invalid generator');
}
$value = array_replace($value, $builder[$name]);
} else {
$value = $builder[$name];
}
if (!is_array($value)) {
$value = $builder[$name];

continue;
}

if (!is_array($builder[$name])) {
throw new \InvalidArgumentException('Invalid generator');
}

$value = array_replace($value, $builder[$name]);
}

return array_merge($global, array_diff_key($builder, $global));
Expand Down
Loading