/** * {@inheritdoc} */ public function createView(TableInterface $table, TableView $parent = null) { $options = $table->getConfig()->getOptions(); $view = $this->newView($parent); $this->buildView($view, $table, $options); foreach ($table as $name => $child) { /* @var TableInterface $child */ $view->children[$name] = $child->createView($view); } $this->finishView($view, $table, $options); return $view; }
/** * {@inheritdoc} */ public function buildView(TableView $view, TableInterface $table, array $options) { $config = $table->getConfig(); $name = $table->getName(); $blockName = $options['block_name'] ?: $table->getName(); if ($view->parent) { if ('' !== ($parentFullName = $view->parent->vars['full_name'])) { $id = sprintf('%s_%s', $view->parent->vars['id'], $name); $fullName = sprintf('%s[%s]', $parentFullName, $name); $uniqueBlockPrefix = sprintf('%s_%s', $view->parent->vars['unique_block_prefix'], $blockName); } else { $id = $name; $fullName = $name; $uniqueBlockPrefix = '_' . $blockName; } } else { $id = $name; $fullName = $name; $uniqueBlockPrefix = '_' . $blockName; // Strip leading underscores and digits. These are allowed in // form names, but not in HTML4 ID attributes. // http://www.w3.org/TR/html401/struct/global.html#adef-id $id = ltrim($id, '_0123456789'); } $blockPrefixes = array(); for ($type = $config->getType(); null !== $type; $type = $type->getParent()) { array_unshift($blockPrefixes, $type->getName()); } $blockPrefixes[] = $uniqueBlockPrefix; $view->vars = array_replace($view->vars, array('type' => $config->getType()->getName(), 'table' => $view, 'id' => $id, 'name' => $name, 'full_name' => $fullName, 'disabled' => $table->isDisabled(), 'attr' => $options['attr'], 'block_prefixes' => $blockPrefixes, 'unique_block_prefix' => $uniqueBlockPrefix, 'cache_key' => $uniqueBlockPrefix . '_' . $table->getConfig()->getType()->getName())); }