Skip to content

Commit

Permalink
add inline edition, add base edit template, fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
rande committed Jan 18, 2011
1 parent 2260432 commit a28e0ec
Show file tree
Hide file tree
Showing 41 changed files with 919 additions and 283 deletions.
54 changes: 35 additions & 19 deletions Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public function configure()
public function getBaseRoutePattern()
{

if(!$this->baseRoutePattern) {
if(preg_match('@(Application|Bundle)\\\([A-Za-z]*)\\\([A-Za-z]*)Bundle\\\(Entity|Document)\\\([A-Za-z]*)@', $this->getClass(), $matches)) {
if (!$this->baseRoutePattern) {
if (preg_match('@(Application|Bundle)\\\([A-Za-z]*)\\\([A-Za-z]*)Bundle\\\(Entity|Document)\\\([A-Za-z]*)@', $this->getClass(), $matches)) {

$this->baseRoutePattern = sprintf('/%s/%s/%s',
$this->urlize($matches[2], '-'),
Expand All @@ -128,8 +128,8 @@ public function getBaseRoutePattern()
*/
public function getBaseRouteName()
{
if(!$this->baseRouteName) {
if(preg_match('@(Application|Bundle)\\\([A-Za-z]*)\\\([A-Za-z]*)Bundle\\\(Entity|Document)\\\([A-Za-z]*)@', $this->getClass(), $matches)) {
if (!$this->baseRouteName) {
if (preg_match('@(Application|Bundle)\\\([A-Za-z]*)\\\([A-Za-z]*)Bundle\\\(Entity|Document)\\\([A-Za-z]*)@', $this->getClass(), $matches)) {

$this->baseRouteName = sprintf('admin_%s_%s_%s',
$this->urlize($matches[2]),
Expand Down Expand Up @@ -198,7 +198,7 @@ public function getUrls()

public function buildUrls()
{
if($this->loaded['urls']) {
if ($this->loaded['urls']) {
return;
}

Expand Down Expand Up @@ -273,7 +273,7 @@ public function getUrl($name)
{
$urls = $this->getUrls();

if(!isset($urls[$name])) {
if (!isset($urls[$name])) {
return false;
}

Expand All @@ -293,11 +293,11 @@ public function generateUrl($name, $params = array())
{
$url = $this->getUrl($name);

if(!$url) {
if (!$url) {
throw new \RuntimeException(sprintf('unable to find the url `%s`', $name));
}

if(!is_array($params)) {
if (!is_array($params)) {
$params = array();
}

Expand Down Expand Up @@ -336,6 +336,23 @@ public function getNewInstance()
return new $class;
}


/**
* attach an admin instance to the given FieldDescription
*
*/
public function attachAdminClass(FieldDescription $fieldDescription)
{
$pool = $this->getConfigurationPool();

$admin = $pool->getAdminByClass($fieldDescription->getTargetEntity());
if (!$admin) {
throw new \RuntimeException(sprintf('You must define an Admin class for the `%s` field', $name));
}

$fieldDescription->setAssociationAdmin($admin);
}

/**
* return the target objet
*
Expand All @@ -352,22 +369,22 @@ public function getObject($id)
public function buildFormGroups()
{

if($this->loaded['form_groups']) {
if ($this->loaded['form_groups']) {
return;
}

$this->loaded['form_groups'] = true;


if(!$this->formGroups) {
if (!$this->formGroups) {
$this->formGroups = array(
false => array('fields' => array_keys($this->formFields))
);
}

// normalize array
foreach($this->formGroups as $name => $group) {
if(!isset($this->formGroups[$name]['collapsed'])) {
foreach ($this->formGroups as $name => $group) {
if (!isset($this->formGroups[$name]['collapsed'])) {
$this->formGroups[$name]['collapsed'] = false;
}
}
Expand Down Expand Up @@ -410,7 +427,7 @@ public function configureFormFields()

public function getFilterDatagrid()
{
if(!$this->filterDatagrid) {
if (!$this->filterDatagrid) {

$this->filterDatagrid = new Datagrid(
$this->getClass(),
Expand Down Expand Up @@ -450,16 +467,15 @@ public function getRootCode()
*/
public function getRoot()
{
while($parent_field_description = $this->getParentFieldDescription()) {

if(!$parent_field_description) {
return $this;
}
$parentFieldDescription = $this->getParentFieldDescription();

if (!$parentFieldDescription) {

return $parent_field_description->getAdmin()->getRoot();
return $this;
}

return $this;
return $parentFieldDescription->getAdmin()->getRoot();
}

/**
Expand Down
Loading

0 comments on commit a28e0ec

Please sign in to comment.