Пример #1
0
 public function addModifiedTable(dmDoctrineTable $table)
 {
     $model = $table->getComponentName();
     if (!isset($this->modifiedTables[$model])) {
         $this->modifiedTables[$model] = $table;
     }
     return $this;
 }
Пример #2
0
 /**
  * Initializes the current dmContext instance.
  *
  * @param dmApplicationConfiguration $configuration  An dmApplicationConfiguration instance
  */
 public function initialize(sfApplicationConfiguration $configuration)
 {
     $this->checkProjectIsSetup();
     parent::initialize($configuration);
     sfConfig::set('dm_debug', $this->getRequest()->getParameter('dm_debug', false));
     // load the service container instance
     $this->loadServiceContainer();
     // configure the service container with its required dependencies
     $this->configureServiceContainer($this->serviceContainer);
     if (method_exists($this->configuration, 'configureServiceContainer')) {
         $this->configuration->configureServiceContainer($this->serviceContainer);
     }
     // connect the service container and its services to the event dispatcher
     $this->serviceContainer->connect();
     /*
      * dmForm requires service container...
      */
     dmForm::setServiceContainer($this->serviceContainer);
     /*
      * some classes needs the event dispatcher to communicate
      * and the service container...
      */
     dmDoctrineQuery::setModuleManager($this->getModuleManager());
     dmDoctrineTable::setServiceContainer($this->serviceContainer);
     $this->helper = $this->serviceContainer->getService('helper');
     // notify that context is ready
     $this->dispatcher->notify(new sfEvent($this, 'dm.context.loaded'));
 }
Пример #3
0
 protected function getModuleManager()
 {
     if (null === $this->moduleManager) {
         $this->configuration->getConfigCache()->registerConfigHandler('config/dm/modules.yml', 'dmModuleManagerConfigHandler');
         $mm = (include $this->configuration->getConfigCache()->checkConfig('config/dm/modules.yml'));
         dmModule::setManager($mm);
         dmDoctrineTable::setModuleManager($mm);
         dmDoctrineQuery::setModuleManager($mm);
         $this->moduleManager = $mm;
     }
     return $this->moduleManager;
 }
Пример #4
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;
 }
Пример #5
0
 protected function getAvailableIdsByLocalAlias(dmDoctrineTable $refTable)
 {
     $availableIds = array();
     foreach ($refTable->getRelationHolder()->getLocals() as $relationAlias => $relation) {
         $tmp = dmDb::pdo('SELECT t.id FROM ' . $relation->getTable()->getTableName() . ' t')->fetchAll(PDO::FETCH_NUM);
         if (empty($tmp)) {
             throw new dmRecordException();
         }
         foreach ($tmp as $t) {
             $availableIds[$relationAlias][$t[0]] = $t[0];
         }
     }
     return $availableIds;
 }
Пример #6
0
 public static function setModuleManager(dmModuleManager $moduleManager)
 {
     self::$moduleManager = $moduleManager;
 }
Пример #7
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));
 }
Пример #8
0
 protected function getRandomId(dmDoctrineTable $table)
 {
     $id = $table->createQuery('t')->select('t.id, RANDOM() AS rand')->orderBy('rand')->limit(1)->fetchValue();
     if (!$id) {
         $recordLoremizer = new self($this->getOptions());
         $id = $recordLoremizer->execute($table->create())->saveGet()->get('id');
     }
     return $id;
 }
Пример #9
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);
 }