Example #1
0
 /**
  * @param dmDoctrineTable $table
  * @param string $fieldName
  * @param string $label
  * @return dmFormDoctrine
  */
 protected function updateNestedSetWidget(dmDoctrineTable $table, $fieldName = null, $label = null)
 {
     if ($table->isNestedSet()) {
         if (null === $fieldName) {
             $fieldName = 'nested_set_parent_id';
         }
         // create if not exists
         if (!$this->widgetSchema[$fieldName] instanceof sfWidgetFormDoctrineChoice) {
             $this->widgetSchema[$fieldName] = new sfWidgetFormDoctrineChoice(array('model' => $table->getComponentName()));
         }
         if (!$this->validatorSchema[$fieldName] instanceof sfValidatorDoctrineChoice) {
             $this->validatorSchema[$fieldName] = new sfValidatorDoctrineChoice(array('model' => $table->getComponentName()));
         }
         if (null !== $label) {
             $this->widgetSchema[$fieldName]->setLabel('$label');
         }
         // set sorting
         $orderBy = 'lft';
         if ($table->getTemplate('NestedSet')->getOption('hasManyRoots', false)) {
             $orderBy = $table->getTemplate('NestedSet')->getOption('rootColumnName', 'root_id') . ', ' . $orderBy;
         }
         $options = array('method' => 'getNestedSetIndentedName', 'order_by' => array($orderBy, ''));
         if ($fieldName == 'nested_set_parent_id') {
             $options['add_empty'] = '~';
             $this->validatorSchema[$fieldName]->setOptions(array_merge($this->validatorSchema[$fieldName]->getOptions(), array('required' => false)));
         }
         $this->widgetSchema[$fieldName]->setOptions(array_merge($this->widgetSchema[$fieldName]->getOptions(), $options));
     }
     return $this;
 }
Example #2
0
 public function addModifiedTable(dmDoctrineTable $table)
 {
     $model = $table->getComponentName();
     if (!isset($this->modifiedTables[$model])) {
         $this->modifiedTables[$model] = $table;
     }
     return $this;
 }
Example #3
0
 protected function shouldProcessMarkdown(dmDoctrineTable $table, $field)
 {
     $key = $table->getComponentName() . '.' . $field;
     if ($this->hasCache($cacheKey = 'should_process_markdown_%s', $key)) {
         return $this->getCache($cacheKey);
     }
     return $this->setCache($cacheKey, $table->hasField($field) && $table->isMarkdownColumn($field));
 }
Example #4
0
 protected static function shouldProcessMarkdown(dmDoctrineTable $table, $field)
 {
     $key = $table->getComponentName() . '.' . $field;
     if (isset(self::$shouldProcessMarkdownCache[$key])) {
         return self::$shouldProcessMarkdownCache[$key];
     }
     return self::$shouldProcessMarkdownCache[$key] = $table->hasField($field) && $table->isMarkdownColumn($field);
 }